{
  "openapi": "3.1.0",
  "info": {
    "title": "Revdoku API",
    "version": "2.0.0",
    "description": "Email mailboxes for people and AI agents, with private file storage. Create mailboxes, read and reply to email, and store files. Guide: https://revdoku.com/api.md. Create an account at https://app.revdoku.com/users/sign_up."
  },
  "servers": [
    {
      "url": "https://api.revdoku.com",
      "description": "Revdoku application API"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "Authentication",
      "description": "Sign-in helpers for the CLI and AI agents. Backend applications use an API key from the dashboard."
    },
    {
      "name": "Accounts",
      "description": "Connection status, granted accounts and limits."
    },
    {
      "name": "Mailboxes",
      "description": "Create, read, archive and delete mailboxes."
    },
    {
      "name": "Email settings",
      "description": "Addresses, aliases, allowed senders, webhooks and live subscriptions."
    },
    {
      "name": "Emails",
      "description": "List, read, reply to and delete email."
    },
    {
      "name": "Files",
      "description": "Upload, read, organize and restore files."
    },
    {
      "name": "Email domains",
      "description": "Custom domains for mailbox addresses."
    }
  ],
  "paths": {
    "/v1/agent_auth/request_code": {
      "post": {
        "operationId": "requestSignInCode",
        "tags": [
          "Authentication"
        ],
        "summary": "Email a sign-in code",
        "description": "Sends a six-digit code to an existing account email. The response is the same for every address, so it never reveals whether an account exists. Create new accounts in the browser at https://app.revdoku.com/users/sign_up.",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "account_id": {
                    "type": "string",
                    "description": "Select another granted account for this request."
                  },
                  "reason": {
                    "$ref": "#/components/schemas/ActionReason"
                  }
                },
                "required": [
                  "email"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/CodeRequested"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/agent_auth/verify_code": {
      "post": {
        "operationId": "verifySignInCode",
        "tags": [
          "Authentication"
        ],
        "summary": "Exchange a sign-in code for an API key",
        "description": "Creates an AI agent connection for an account owner or administrator. Accounts with two-factor authentication must use browser sign-in.",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "code": {
                    "type": "string",
                    "description": "Six digits; spaces are ignored."
                  },
                  "label": {
                    "type": "string",
                    "description": "Connection name shown in Account access."
                  },
                  "permission_scope": {
                    "type": "string",
                    "enum": [
                      "mailbox_read",
                      "mailbox_write",
                      "mailbox_admin"
                    ],
                    "default": "mailbox_admin"
                  },
                  "mailbox_access": {
                    "type": "string",
                    "enum": [
                      "all",
                      "selected"
                    ],
                    "default": "all"
                  },
                  "mailbox_ids": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Required when mailbox_access is selected."
                  },
                  "mailbox_permissions": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string",
                      "enum": [
                        "read",
                        "write"
                      ]
                    },
                    "description": "Optional access per selected mailbox ID: read or write. Without an entry, a mailbox gets write, or read when permission_scope is mailbox_read."
                  },
                  "account_id": {
                    "type": "string",
                    "description": "Select another granted account for this request."
                  },
                  "reason": {
                    "$ref": "#/components/schemas/ActionReason"
                  }
                },
                "required": [
                  "email",
                  "code"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/AgentConnection"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/agent_auth/exchange_grant": {
      "post": {
        "operationId": "exchangeConnectionGrant",
        "tags": [
          "Authentication"
        ],
        "summary": "Exchange a one-time dashboard connection code for an API key",
        "description": "The dashboard creates the one-time code when a signed-in administrator copies a connection prompt.",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "grant_token": {
                    "type": "string"
                  },
                  "label": {
                    "type": "string"
                  },
                  "account_id": {
                    "type": "string",
                    "description": "Select another granted account for this request."
                  },
                  "reason": {
                    "$ref": "#/components/schemas/ActionReason"
                  }
                },
                "required": [
                  "grant_token"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/AgentConnection"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/agent_auth/browser_login_link": {
      "post": {
        "operationId": "createBrowserLink",
        "tags": [
          "Authentication"
        ],
        "summary": "Create a dashboard link for the user",
        "description": "Returns a dashboard URL for a path such as /mailboxes. The user signs in normally; the link grants no access.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "redirect_path": {
                    "type": "string",
                    "default": "/mailboxes"
                  },
                  "account_id": {
                    "type": "string",
                    "description": "Select another granted account for this request."
                  },
                  "reason": {
                    "$ref": "#/components/schemas/ActionReason"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/BrowserLink"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/status": {
      "get": {
        "operationId": "getStatus",
        "tags": [
          "Accounts"
        ],
        "summary": "Read the connection and selected account",
        "description": "Works with every API key, including mailbox-scoped keys. Read quotas with GET /v1/account/limits.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AccountId"
          },
          {
            "$ref": "#/components/parameters/Reason"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/Status"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/accounts": {
      "get": {
        "operationId": "listAccounts",
        "tags": [
          "Accounts"
        ],
        "summary": "List accounts granted to this credential",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountList"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      },
      "post": {
        "operationId": "createClientAccount",
        "tags": [
          "Accounts"
        ],
        "summary": "Create a client account",
        "description": "Requires an agency owner credential with client-account access. The credential default does not change; send the new account_id on later requests.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1
                  },
                  "client_name": {
                    "type": "string",
                    "maxLength": 100,
                    "description": "Optional client person or business name."
                  },
                  "account_id": {
                    "type": "string",
                    "description": "Granted agency account that owns the new client account."
                  },
                  "reason": {
                    "$ref": "#/components/schemas/ActionReason"
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "account"
                      ],
                      "properties": {
                        "account": {
                          "$ref": "#/components/schemas/AccountIdentity"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/accounts/{account_id}": {
      "get": {
        "operationId": "getAccount",
        "tags": [
          "Accounts"
        ],
        "summary": "Read one granted account",
        "parameters": [
          {
            "$ref": "#/components/parameters/AccountPathId"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "account"
                      ],
                      "properties": {
                        "account": {
                          "$ref": "#/components/schemas/AccountIdentity"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/account/limits": {
      "get": {
        "operationId": "getAccountLimits",
        "tags": [
          "Accounts"
        ],
        "summary": "Read effective account limits",
        "description": "Values come from the plan and account overrides. Zero means no allowance; null means no cap. Storage, mailbox and email traffic allowances are shared within a billing group.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AccountId"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "account_id",
                        "limits"
                      ],
                      "properties": {
                        "account_id": {
                          "type": "string"
                        },
                        "limits": {
                          "$ref": "#/components/schemas/AccountLimits"
                        },
                        "usage": {
                          "type": "object",
                          "properties": {
                            "mailbox_creations": {
                              "type": "object",
                              "properties": {
                                "monthly_limit": {
                                  "type": [
                                    "integer",
                                    "null"
                                  ]
                                },
                                "used": {
                                  "type": "integer"
                                },
                                "remaining": {
                                  "type": [
                                    "integer",
                                    "null"
                                  ]
                                },
                                "resets_at": {
                                  "type": "string",
                                  "format": "date-time"
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/account/email_domains": {
      "get": {
        "operationId": "listEmailDomains",
        "tags": [
          "Email domains"
        ],
        "summary": "List custom email domains",
        "description": "Requires a full-account owner or administrator credential.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AccountId"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/EmailDomainList"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      },
      "post": {
        "operationId": "createEmailDomain",
        "tags": [
          "Email domains"
        ],
        "summary": "Connect a custom email domain",
        "description": "Claims an exact hostname and returns the DNS records to publish. Never change DNS without the domain owner's authorization.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "hostname": {
                    "type": "string"
                  },
                  "account_id": {
                    "type": "string",
                    "description": "Select another granted account for this request."
                  },
                  "reason": {
                    "$ref": "#/components/schemas/ActionReason"
                  }
                },
                "required": [
                  "hostname"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "domain"
                      ],
                      "properties": {
                        "domain": {
                          "$ref": "#/components/schemas/EmailDomain"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/account/email_domains/check": {
      "post": {
        "operationId": "checkEmailDomain",
        "tags": [
          "Email domains"
        ],
        "summary": "Check a hostname for conflicting DNS",
        "description": "Makes no claim and changes no DNS. If the root domain already receives email, use an unused subdomain such as inbox.example.com.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "hostname": {
                    "type": "string"
                  },
                  "account_id": {
                    "type": "string",
                    "description": "Select another granted account for this request."
                  },
                  "reason": {
                    "$ref": "#/components/schemas/ActionReason"
                  }
                },
                "required": [
                  "hostname"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/EmailDomainCheck"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/account/email_domains/{domain_id}": {
      "get": {
        "operationId": "getEmailDomain",
        "tags": [
          "Email domains"
        ],
        "summary": "Read a custom email domain",
        "parameters": [
          {
            "$ref": "#/components/parameters/DomainId"
          },
          {
            "$ref": "#/components/parameters/AccountId"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "domain"
                      ],
                      "properties": {
                        "domain": {
                          "$ref": "#/components/schemas/EmailDomain"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      },
      "delete": {
        "operationId": "deleteEmailDomain",
        "tags": [
          "Email domains"
        ],
        "summary": "Remove an unused custom email domain",
        "description": "Send the domain hostname and confirm=true. A domain that mailbox addresses still use returns EMAIL_DOMAIN_IN_USE.",
        "parameters": [
          {
            "$ref": "#/components/parameters/DomainId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "hostname": {
                    "type": "string"
                  },
                  "confirm": {
                    "type": "boolean",
                    "const": true
                  },
                  "account_id": {
                    "type": "string",
                    "description": "Select another granted account for this request."
                  },
                  "reason": {
                    "$ref": "#/components/schemas/ActionReason"
                  }
                },
                "required": [
                  "hostname",
                  "confirm"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/DeleteResult"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/account/email_domains/{domain_id}/verify": {
      "post": {
        "operationId": "verifyEmailDomain",
        "tags": [
          "Email domains"
        ],
        "summary": "Check DNS and provider setup again",
        "description": "Queues the check and returns the current state. Read the domain again to see the result.",
        "parameters": [
          {
            "$ref": "#/components/parameters/DomainId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "account_id": {
                    "type": "string",
                    "description": "Select another granted account for this request."
                  },
                  "reason": {
                    "$ref": "#/components/schemas/ActionReason"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "domain"
                      ],
                      "properties": {
                        "domain": {
                          "$ref": "#/components/schemas/EmailDomain"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/mailboxes": {
      "get": {
        "operationId": "listMailboxes",
        "tags": [
          "Mailboxes"
        ],
        "summary": "List mailboxes",
        "description": "Lists active mailboxes by default, newest first. Counts and pages cover only mailboxes this credential can access. Reads no email content.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AccountId"
          },
          {
            "$ref": "#/components/parameters/Reason"
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "active",
                "archived",
                "all"
              ],
              "default": "active"
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 500
            },
            "description": "Case-insensitive text in the mailbox ID, or in the title or address when the key can see the address."
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/MailboxList"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      },
      "post": {
        "operationId": "createMailbox",
        "tags": [
          "Mailboxes"
        ],
        "summary": "Create a mailbox",
        "description": "Waits until the address can receive email. On Free, email.username is a prefix with a permanent 4-character random suffix; paid plans get the exact name. If confirmation does not finish, EMAIL_NOT_READY returns the created mailbox_id in error.details: read that mailbox instead of creating another. The title defaults to email.username; a title that another active mailbox uses returns 409 MAILBOX_TITLE_TAKEN. Never retry a creation automatically.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "mailbox": {
                    "$ref": "#/components/schemas/MailboxCreate"
                  },
                  "account_id": {
                    "type": "string",
                    "description": "Select another granted account for this request."
                  },
                  "reason": {
                    "$ref": "#/components/schemas/ActionReason"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "mailbox"
                      ],
                      "properties": {
                        "mailbox": {
                          "$ref": "#/components/schemas/Mailbox"
                        }
                      }
                    }
                  }
                },
                "example": {
                  "success": true,
                  "data": {
                    "mailbox": {
                      "id": "bkt_example",
                      "email": {
                        "address": "acme.orders.k7m2@revdokumail.com",
                        "receiving_enabled": true,
                        "sending_enabled": true
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                },
                "example": {
                  "success": false,
                  "error": {
                    "code": "UNAUTHORIZED",
                    "message": "Authentication required",
                    "request_id": "req_example"
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/mailboxes/{mailbox_id}": {
      "get": {
        "operationId": "getMailbox",
        "tags": [
          "Mailboxes"
        ],
        "summary": "Read a mailbox",
        "description": "Reading never changes the mailbox. Read address settings, emails and files through their own endpoints.",
        "parameters": [
          {
            "$ref": "#/components/parameters/MailboxId"
          },
          {
            "$ref": "#/components/parameters/AccountId"
          },
          {
            "$ref": "#/components/parameters/Reason"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "mailbox"
                      ],
                      "properties": {
                        "mailbox": {
                          "$ref": "#/components/schemas/Mailbox"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      },
      "patch": {
        "operationId": "updateMailbox",
        "tags": [
          "Mailboxes"
        ],
        "summary": "Update a mailbox title, description or metadata",
        "description": "metadata must be a JSON object. It replaces the stored object; {} clears it. Send expected_metadata_version from your last read; a stale value changes nothing and returns MAILBOX_METADATA_CONFLICT. Titles are unique among active mailboxes; a used title returns 409 MAILBOX_TITLE_TAKEN.",
        "parameters": [
          {
            "$ref": "#/components/parameters/MailboxId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "mailbox": {
                    "$ref": "#/components/schemas/MailboxUpdate"
                  },
                  "expected_metadata_version": {
                    "type": "string"
                  },
                  "account_id": {
                    "type": "string",
                    "description": "Select another granted account for this request."
                  },
                  "reason": {
                    "$ref": "#/components/schemas/ActionReason"
                  }
                },
                "required": [
                  "mailbox"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "mailbox"
                      ],
                      "properties": {
                        "mailbox": {
                          "$ref": "#/components/schemas/Mailbox"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      },
      "delete": {
        "operationId": "deleteMailbox",
        "tags": [
          "Mailboxes"
        ],
        "summary": "Permanently delete an archived mailbox",
        "description": "Archive the mailbox first. Send delete.confirmation from the mailbox read after the user confirms. Large mailboxes finish deleting in the background.",
        "parameters": [
          {
            "$ref": "#/components/parameters/MailboxId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "confirmation": {
                    "type": "string"
                  },
                  "account_id": {
                    "type": "string",
                    "description": "Select another granted account for this request."
                  },
                  "reason": {
                    "$ref": "#/components/schemas/ActionReason"
                  }
                },
                "required": [
                  "confirmation"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/DeleteResult"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/mailboxes/{mailbox_id}/archive": {
      "post": {
        "operationId": "archiveMailbox",
        "tags": [
          "Mailboxes"
        ],
        "summary": "Archive a mailbox",
        "description": "Archived mailboxes keep their files and emails and become read-only.",
        "parameters": [
          {
            "$ref": "#/components/parameters/MailboxId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ActionRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "mailbox"
                      ],
                      "properties": {
                        "mailbox": {
                          "$ref": "#/components/schemas/Mailbox"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/mailboxes/{mailbox_id}/unarchive": {
      "post": {
        "operationId": "unarchiveMailbox",
        "tags": [
          "Mailboxes"
        ],
        "summary": "Unarchive a mailbox",
        "parameters": [
          {
            "$ref": "#/components/parameters/MailboxId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ActionRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "mailbox"
                      ],
                      "properties": {
                        "mailbox": {
                          "$ref": "#/components/schemas/Mailbox"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/mailboxes/{mailbox_id}/email": {
      "get": {
        "operationId": "getMailboxEmailSettings",
        "tags": [
          "Email settings"
        ],
        "summary": "Read address settings",
        "description": "Requires mailbox write permission.",
        "parameters": [
          {
            "$ref": "#/components/parameters/MailboxId"
          },
          {
            "$ref": "#/components/parameters/AccountId"
          },
          {
            "$ref": "#/components/parameters/Reason"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/MailboxEmailSettings"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/mailboxes/{mailbox_id}/email/rotate": {
      "post": {
        "operationId": "changeMailboxAddress",
        "tags": [
          "Email settings"
        ],
        "summary": "Change the primary address",
        "description": "Requires a paid plan and mailbox admin permission. Send the current address as expected_address. Omit username for a generated name. A custom-domain change returns 202; read the settings until assignment.status is active or failed. For account owners and administrators the old address becomes an alias unless keep_old_as_alias is false. Without a free alias slot the request returns EMAIL_ALIAS_LIMIT; send false to retire the old address.",
        "parameters": [
          {
            "$ref": "#/components/parameters/MailboxId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "confirm": {
                    "type": "boolean",
                    "const": true
                  },
                  "expected_address": {
                    "type": "string",
                    "description": "Current address from your last settings read. A different current address returns EMAIL_ADDRESS_CHANGED."
                  },
                  "username": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 64
                  },
                  "domain": {
                    "type": "string",
                    "description": "Available platform domain, a ready domain of this account, or platform."
                  },
                  "keep_old_as_alias": {
                    "type": "boolean",
                    "description": "Keep the old address as an alias. Defaults to true for account owners and administrators while the old domain still receives email, otherwise false. Keeping it needs a free alias slot and an account owner or administrator."
                  },
                  "account_id": {
                    "type": "string",
                    "description": "Select another granted account for this request."
                  },
                  "reason": {
                    "$ref": "#/components/schemas/ActionReason"
                  }
                },
                "required": [
                  "confirm",
                  "expected_address"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/MailboxEmailSettings"
                    }
                  }
                }
              }
            }
          },
          "202": {
            "description": "Change pending",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/MailboxEmailSettings"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/mailboxes/{mailbox_id}/email/aliases": {
      "post": {
        "operationId": "createEmailAlias",
        "tags": [
          "Email settings"
        ],
        "summary": "Add an alias address",
        "description": "Requires a paid plan and a full-account owner or administrator with mailbox-admin permission. The primary address stays unchanged.",
        "parameters": [
          {
            "$ref": "#/components/parameters/MailboxId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "username": {
                    "type": "string"
                  },
                  "domain": {
                    "type": "string"
                  },
                  "account_id": {
                    "type": "string",
                    "description": "Select another granted account for this request."
                  },
                  "reason": {
                    "$ref": "#/components/schemas/ActionReason"
                  }
                },
                "required": [
                  "username"
                ]
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/MailboxEmailSettings"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/mailboxes/{mailbox_id}/email/aliases/{alias_id}": {
      "delete": {
        "operationId": "deleteEmailAlias",
        "tags": [
          "Email settings"
        ],
        "summary": "Remove an alias address",
        "description": "Stops new and queued deliveries to the alias. Saved emails stay.",
        "parameters": [
          {
            "$ref": "#/components/parameters/MailboxId"
          },
          {
            "$ref": "#/components/parameters/AliasId"
          },
          {
            "$ref": "#/components/parameters/AccountId"
          },
          {
            "$ref": "#/components/parameters/Reason"
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/DeleteResult"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/mailboxes/{mailbox_id}/email/allowlist": {
      "patch": {
        "operationId": "updateEmailAllowlist",
        "tags": [
          "Email settings"
        ],
        "summary": "Replace the allowed senders",
        "description": "Requires an account owner or administrator with mailbox-admin permission. Send sender_allowlist.version from the settings read as expected_version.",
        "parameters": [
          {
            "$ref": "#/components/parameters/MailboxId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sender_allowlist": {
                    "type": "object",
                    "required": [
                      "enabled",
                      "entries"
                    ],
                    "properties": {
                      "enabled": {
                        "type": "boolean"
                      },
                      "entries": {
                        "type": "array",
                        "maxItems": 500,
                        "items": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "expected_version": {
                    "type": "string"
                  },
                  "account_id": {
                    "type": "string",
                    "description": "Select another granted account for this request."
                  },
                  "reason": {
                    "$ref": "#/components/schemas/ActionReason"
                  }
                },
                "required": [
                  "sender_allowlist",
                  "expected_version"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "sender_allowlist"
                      ],
                      "properties": {
                        "sender_allowlist": {
                          "$ref": "#/components/schemas/EmailSenderAllowlist"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/mailboxes/{mailbox_id}/email/webhook": {
      "get": {
        "operationId": "getEmailWebhook",
        "tags": [
          "Email settings"
        ],
        "summary": "Read the email webhook",
        "description": "Requires mailbox-admin permission. webhook is null when no webhook is set. The signing secret is never returned here.",
        "parameters": [
          {
            "$ref": "#/components/parameters/MailboxId"
          },
          {
            "$ref": "#/components/parameters/AccountId"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "webhook"
                      ],
                      "properties": {
                        "webhook": {
                          "anyOf": [
                            {
                              "$ref": "#/components/schemas/Webhook"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      },
      "put": {
        "operationId": "setEmailWebhook",
        "tags": [
          "Email settings"
        ],
        "summary": "Set the email webhook",
        "description": "Requires mailbox-admin permission and a public HTTPS URL. A new URL or rotate_secret=true creates a new signing secret, returns it once and cancels pending deliveries. The same URL without rotate_secret returns the webhook without a secret.",
        "parameters": [
          {
            "$ref": "#/components/parameters/MailboxId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "webhook_url": {
                    "type": "string",
                    "format": "uri",
                    "maxLength": 2048
                  },
                  "rotate_secret": {
                    "type": "boolean",
                    "default": false
                  },
                  "account_id": {
                    "type": "string",
                    "description": "Select another granted account for this request."
                  },
                  "reason": {
                    "$ref": "#/components/schemas/ActionReason"
                  }
                },
                "required": [
                  "webhook_url"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "webhook"
                      ],
                      "properties": {
                        "webhook": {
                          "$ref": "#/components/schemas/WebhookWithSecret"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      },
      "delete": {
        "operationId": "deleteEmailWebhook",
        "tags": [
          "Email settings"
        ],
        "summary": "Remove the email webhook",
        "description": "Cancels queued deliveries. A delivery already in progress can finish. Returns the mailbox ID, also when no webhook is set.",
        "parameters": [
          {
            "$ref": "#/components/parameters/MailboxId"
          },
          {
            "$ref": "#/components/parameters/AccountId"
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/DeleteResult"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/mailboxes/{mailbox_id}/email/subscription": {
      "get": {
        "operationId": "getEmailSubscription",
        "tags": [
          "Email settings"
        ],
        "summary": "Get a live email subscription ticket",
        "description": "Requires mailbox read permission. Connect to websocket_url with email_subscription_token=TOKEN within 60 seconds, then subscribe to EmailReceivedChannel. Catch up with the email list cursor after every connect.",
        "parameters": [
          {
            "$ref": "#/components/parameters/MailboxId"
          },
          {
            "$ref": "#/components/parameters/AccountId"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "subscription"
                      ],
                      "properties": {
                        "subscription": {
                          "$ref": "#/components/schemas/EmailSubscription"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/mailboxes/{mailbox_id}/emails": {
      "get": {
        "operationId": "listEmails",
        "tags": [
          "Emails"
        ],
        "summary": "List emails",
        "description": "Requires mailbox read permission. Lists received email by default. To poll, list in ascending order, save pagination.next_cursor after every page (including an empty page) and send it next time with the same filters. Listing never marks email read.",
        "parameters": [
          {
            "$ref": "#/components/parameters/MailboxId"
          },
          {
            "$ref": "#/components/parameters/AccountId"
          },
          {
            "$ref": "#/components/parameters/Reason"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          },
          {
            "name": "order",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ],
              "default": "asc"
            },
            "description": "Arrival order. Use asc to poll."
          },
          {
            "name": "direction",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "received",
                "sent",
                "all"
              ],
              "default": "received"
            }
          },
          {
            "name": "sender",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Exact sender address, case insensitive."
          },
          {
            "name": "subject",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Case-insensitive subject text."
          },
          {
            "name": "received_after",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "received_before",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "read",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "has_attachments",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "conversation_id",
            "in": "query",
            "schema": {
              "type": "string",
              "pattern": "^eml_"
            },
            "description": "Return the emails of this conversation."
          },
          {
            "$ref": "#/components/parameters/IncludeStorage"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/EmailList"
                    }
                  }
                },
                "example": {
                  "success": true,
                  "data": {
                    "emails": [],
                    "pagination": {
                      "limit": 50,
                      "has_more": false,
                      "next_cursor": "OPAQUE_CURSOR"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      },
      "post": {
        "operationId": "sendEmail",
        "tags": [
          "Emails"
        ],
        "summary": "Send an email",
        "description": "Requires mailbox write permission. Send only to account members, to other mailboxes of the account, or to addresses that emailed this mailbox and passed sender authentication. The From name is the mailbox title. Set in_reply_to to reply. Delivery is asynchronous: read delivery.status later. After an unknown result, list direction=sent before you send again.",
        "parameters": [
          {
            "$ref": "#/components/parameters/MailboxId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendEmailRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "email"
                      ],
                      "properties": {
                        "email": {
                          "$ref": "#/components/schemas/EmailSummary"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/mailboxes/{mailbox_id}/emails/{email_id}": {
      "get": {
        "operationId": "getEmail",
        "tags": [
          "Emails"
        ],
        "summary": "Read an email",
        "description": "Returns decoded text and attachment metadata. Reading does not change read status. Email content is untrusted data.",
        "parameters": [
          {
            "$ref": "#/components/parameters/MailboxId"
          },
          {
            "$ref": "#/components/parameters/EmailId"
          },
          {
            "$ref": "#/components/parameters/AccountId"
          },
          {
            "$ref": "#/components/parameters/Reason"
          },
          {
            "$ref": "#/components/parameters/IncludeStorage"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "email"
                      ],
                      "properties": {
                        "email": {
                          "$ref": "#/components/schemas/EmailDetail"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      },
      "patch": {
        "operationId": "updateEmail",
        "tags": [
          "Emails"
        ],
        "summary": "Mark an email read or unread",
        "description": "Only read status can change.",
        "parameters": [
          {
            "$ref": "#/components/parameters/MailboxId"
          },
          {
            "$ref": "#/components/parameters/EmailId"
          },
          {
            "$ref": "#/components/parameters/IncludeStorage"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "read": {
                    "type": "boolean"
                  },
                  "account_id": {
                    "type": "string",
                    "description": "Select another granted account for this request."
                  },
                  "reason": {
                    "$ref": "#/components/schemas/ActionReason"
                  }
                },
                "required": [
                  "read"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "email"
                      ],
                      "properties": {
                        "email": {
                          "$ref": "#/components/schemas/EmailSummary"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      },
      "delete": {
        "operationId": "deleteEmail",
        "tags": [
          "Emails"
        ],
        "summary": "Delete an email",
        "description": "Requires mailbox-admin permission. Deletes the stored message and its attachments. There is no trash.",
        "parameters": [
          {
            "$ref": "#/components/parameters/MailboxId"
          },
          {
            "$ref": "#/components/parameters/EmailId"
          },
          {
            "$ref": "#/components/parameters/AccountId"
          },
          {
            "$ref": "#/components/parameters/Reason"
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/DeleteResult"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/mailboxes/{mailbox_id}/emails/{email_id}/raw": {
      "get": {
        "operationId": "getEmailOriginalDownload",
        "tags": [
          "Emails"
        ],
        "summary": "Get a download link for the original email",
        "description": "Returns a temporary link to the original .eml file. Downloads do not change read status.",
        "parameters": [
          {
            "$ref": "#/components/parameters/MailboxId"
          },
          {
            "$ref": "#/components/parameters/EmailId"
          },
          {
            "$ref": "#/components/parameters/AccountId"
          },
          {
            "$ref": "#/components/parameters/Reason"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "download"
                      ],
                      "properties": {
                        "download": {
                          "$ref": "#/components/schemas/Download"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/mailboxes/{mailbox_id}/emails/{email_id}/attachments/{attachment_id}": {
      "get": {
        "operationId": "getEmailAttachmentDownload",
        "tags": [
          "Emails"
        ],
        "summary": "Get a download link for an attachment",
        "description": "Returns a temporary link. No extraction or analysis is done.",
        "parameters": [
          {
            "$ref": "#/components/parameters/MailboxId"
          },
          {
            "$ref": "#/components/parameters/EmailId"
          },
          {
            "$ref": "#/components/parameters/AttachmentId"
          },
          {
            "$ref": "#/components/parameters/AccountId"
          },
          {
            "$ref": "#/components/parameters/Reason"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "download"
                      ],
                      "properties": {
                        "download": {
                          "$ref": "#/components/schemas/Download"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/direct_uploads": {
      "post": {
        "operationId": "prepareFileUpload",
        "tags": [
          "Files"
        ],
        "summary": "Prepare a file upload (step 1 of 3)",
        "description": "Returns a storage URL. Then PUT the bytes to direct_upload.url with exactly direct_upload.headers and no API key (step 2), and save the file with POST /v1/mailboxes/{mailbox_id}/files (step 3). Identical content at the same path returns skipped=true and duplicate=true without an upload.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PrepareFileUploadRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/PreparedFileUpload"
                    }
                  }
                }
              }
            }
          },
          "200": {
            "description": "Identical content; nothing to upload",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/PreparedFileUpload"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/mailboxes/{mailbox_id}/files": {
      "get": {
        "operationId": "listFiles",
        "tags": [
          "Files"
        ],
        "summary": "List files",
        "description": "Lists current files, including stored emails under _email/. Listing never marks files read.",
        "parameters": [
          {
            "$ref": "#/components/parameters/MailboxId"
          },
          {
            "$ref": "#/components/parameters/AccountId"
          },
          {
            "$ref": "#/components/parameters/Reason"
          },
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Case-insensitive text in the path."
          },
          {
            "name": "folder",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "List one folder. An empty value lists the root."
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/FileList"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      },
      "post": {
        "operationId": "saveUploadedFile",
        "tags": [
          "Files"
        ],
        "summary": "Save an uploaded file (step 3 of 3)",
        "description": "Saves the uploaded blob at path. An existing path gets a new version.",
        "parameters": [
          {
            "$ref": "#/components/parameters/MailboxId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveUploadedFileRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/SavedFile"
                    }
                  }
                }
              }
            }
          },
          "200": {
            "description": "Existing file kept",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/SavedFile"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/mailboxes/{mailbox_id}/files/by_path": {
      "get": {
        "operationId": "getFileByPath",
        "tags": [
          "Files"
        ],
        "summary": "Find a file by path",
        "description": "Returns file metadata only. Read content with the download endpoint. The disposition and content_url parameters return INVALID_ARGUMENT.",
        "parameters": [
          {
            "$ref": "#/components/parameters/MailboxId"
          },
          {
            "name": "path",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/AccountId"
          },
          {
            "$ref": "#/components/parameters/Reason"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "file"
                      ],
                      "properties": {
                        "file": {
                          "$ref": "#/components/schemas/MailboxFile"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/mailboxes/{mailbox_id}/files/append_text": {
      "post": {
        "operationId": "appendText",
        "tags": [
          "Files"
        ],
        "summary": "Append text to a file",
        "description": "Appends UTF-8 text to an existing text file and creates a new version. A missing file returns MAILBOX_FILE_NOT_FOUND.",
        "parameters": [
          {
            "$ref": "#/components/parameters/MailboxId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "path": {
                    "type": "string"
                  },
                  "content": {
                    "type": "string"
                  },
                  "newline_before": {
                    "type": "boolean",
                    "default": true
                  },
                  "expected_mailbox_version": {
                    "type": "string",
                    "description": "Mailbox version_id from your last read."
                  },
                  "account_id": {
                    "type": "string",
                    "description": "Select another granted account for this request."
                  },
                  "reason": {
                    "$ref": "#/components/schemas/ActionReason"
                  }
                },
                "required": [
                  "path",
                  "content"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/AppendTextResult"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/mailboxes/{mailbox_id}/files/{file_id}": {
      "get": {
        "operationId": "getFile",
        "tags": [
          "Files"
        ],
        "summary": "Read file metadata",
        "description": "Reading metadata never marks the file read.",
        "parameters": [
          {
            "$ref": "#/components/parameters/MailboxId"
          },
          {
            "$ref": "#/components/parameters/FileId"
          },
          {
            "$ref": "#/components/parameters/AccountId"
          },
          {
            "$ref": "#/components/parameters/Reason"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "file"
                      ],
                      "properties": {
                        "file": {
                          "$ref": "#/components/schemas/MailboxFile"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      },
      "delete": {
        "operationId": "deleteFile",
        "tags": [
          "Files"
        ],
        "summary": "Delete a file",
        "description": "Requires mailbox-admin permission. Files under _email/ return EMAIL_PATH_READ_ONLY; delete the email instead.",
        "parameters": [
          {
            "$ref": "#/components/parameters/MailboxId"
          },
          {
            "$ref": "#/components/parameters/FileId"
          },
          {
            "$ref": "#/components/parameters/AccountId"
          },
          {
            "$ref": "#/components/parameters/Reason"
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/DeleteResult"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/mailboxes/{mailbox_id}/files/{file_id}/download": {
      "get": {
        "operationId": "getFileDownload",
        "tags": [
          "Files"
        ],
        "summary": "Get a download link for a file",
        "description": "Returns a temporary link and marks this version read. Send version_id for an older version.",
        "parameters": [
          {
            "$ref": "#/components/parameters/MailboxId"
          },
          {
            "$ref": "#/components/parameters/FileId"
          },
          {
            "name": "version_id",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/AccountId"
          },
          {
            "$ref": "#/components/parameters/Reason"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/FileDownload"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/mailboxes/{mailbox_id}/files/{file_id}/rename": {
      "post": {
        "operationId": "renameFile",
        "tags": [
          "Files"
        ],
        "summary": "Rename or move a file in the same mailbox",
        "description": "Changes the path without uploading the content again.",
        "parameters": [
          {
            "$ref": "#/components/parameters/MailboxId"
          },
          {
            "$ref": "#/components/parameters/FileId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "new_path": {
                    "type": "string"
                  },
                  "account_id": {
                    "type": "string",
                    "description": "Select another granted account for this request."
                  },
                  "reason": {
                    "$ref": "#/components/schemas/ActionReason"
                  }
                },
                "required": [
                  "new_path"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/PathOperationResult"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/mailboxes/{mailbox_id}/files/{file_id}/move": {
      "post": {
        "operationId": "moveFile",
        "tags": [
          "Files"
        ],
        "summary": "Move a file",
        "description": "Works in the same mailbox or into target_mailbox_id. Content is not uploaded again. Send target_path for an exact path or target_folder to keep the name.",
        "parameters": [
          {
            "$ref": "#/components/parameters/MailboxId"
          },
          {
            "$ref": "#/components/parameters/FileId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "target_mailbox_id": {
                    "type": "string"
                  },
                  "target_path": {
                    "type": "string"
                  },
                  "target_folder": {
                    "type": "string"
                  },
                  "account_id": {
                    "type": "string",
                    "description": "Select another granted account for this request."
                  },
                  "reason": {
                    "$ref": "#/components/schemas/ActionReason"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/PathOperationResult"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/mailboxes/{mailbox_id}/files/{file_id}/copy": {
      "post": {
        "operationId": "copyFile",
        "tags": [
          "Files"
        ],
        "summary": "Copy a file",
        "description": "Works in the same mailbox or into target_mailbox_id. Content is not uploaded again. Send target_path for an exact path or target_folder to keep the name.",
        "parameters": [
          {
            "$ref": "#/components/parameters/MailboxId"
          },
          {
            "$ref": "#/components/parameters/FileId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "target_mailbox_id": {
                    "type": "string"
                  },
                  "target_path": {
                    "type": "string"
                  },
                  "target_folder": {
                    "type": "string"
                  },
                  "account_id": {
                    "type": "string",
                    "description": "Select another granted account for this request."
                  },
                  "reason": {
                    "$ref": "#/components/schemas/ActionReason"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/PathOperationResult"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/mailboxes/{mailbox_id}/files/{file_id}/versions": {
      "get": {
        "operationId": "listFileVersions",
        "tags": [
          "Files"
        ],
        "summary": "List file versions",
        "description": "Newest first.",
        "parameters": [
          {
            "$ref": "#/components/parameters/MailboxId"
          },
          {
            "$ref": "#/components/parameters/FileId"
          },
          {
            "$ref": "#/components/parameters/AccountId"
          },
          {
            "$ref": "#/components/parameters/Reason"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/FileVersionList"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/mailboxes/{mailbox_id}/files/{file_id}/versions/{version_id}/restore": {
      "post": {
        "operationId": "restoreFileVersion",
        "tags": [
          "Files"
        ],
        "summary": "Restore a file version",
        "description": "Creates a new current version with the content of the selected version. History is kept. Requires a plan with version restore.",
        "parameters": [
          {
            "$ref": "#/components/parameters/MailboxId"
          },
          {
            "$ref": "#/components/parameters/FileId"
          },
          {
            "$ref": "#/components/parameters/VersionId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ActionRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/RestoredFileVersion"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/mailboxes/{mailbox_id}/upload_sessions": {
      "post": {
        "operationId": "createUploadSession",
        "tags": [
          "Files"
        ],
        "summary": "Start a batch upload",
        "description": "Starts an upload session for many files and returns storage targets for the first files. The session locks the mailbox for other writers; incoming email still arrives. Send files in batches with POST .../uploads, PUT the bytes to each upload.url, save each batch with POST .../finalize_batch, then call POST .../finalize. Unsaved uploads are discarded when the session expires.",
        "parameters": [
          {
            "$ref": "#/components/parameters/MailboxId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "files": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "$ref": "#/components/schemas/UploadSessionFile"
                    },
                    "description": "Optional first batch. Send the rest with POST .../uploads."
                  },
                  "expected_file_count": {
                    "type": "integer",
                    "minimum": 1,
                    "description": "Total files you will upload in this session. Used for progress."
                  },
                  "client_session_key": {
                    "type": "string",
                    "maxLength": 128,
                    "description": "Your own key for this batch. Repeating it with the same credential while the session is pending returns that session instead of a new one."
                  },
                  "existing_file_policy": {
                    "type": "string",
                    "enum": [
                      "replace",
                      "skip"
                    ],
                    "default": "replace",
                    "description": "skip keeps existing files at the same paths."
                  },
                  "expected_mailbox_version": {
                    "type": "string",
                    "description": "Mailbox version_id from your last read. A different current version returns MAILBOX_VERSION_CONFLICT."
                  },
                  "account_id": {
                    "type": "string",
                    "description": "Select another granted account for this request."
                  },
                  "reason": {
                    "$ref": "#/components/schemas/ActionReason"
                  }
                }
              },
              "example": {
                "expected_file_count": 2,
                "client_session_key": "backup-2026-10-11",
                "files": [
                  {
                    "path": "reports/q3.pdf",
                    "byte_size": 48213,
                    "content_type": "application/pdf",
                    "checksum": "rL0Y20zC+Fzt72VPzMSk2A==",
                    "sha256": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/UploadSessionResult"
                    }
                  }
                },
                "example": {
                  "success": true,
                  "data": {
                    "mailbox_upload_session": {
                      "id": "bus_example",
                      "mailbox_id": "bkt_example",
                      "status": "pending",
                      "base_mailbox_version_id": "bktrv_example",
                      "target_mailbox_version_id": null,
                      "uploads_expire_at": "2026-10-11T14:00:00Z",
                      "session_closed_at": null,
                      "files_count": 2,
                      "pending_files_count": 2,
                      "uploaded_files_count": 0,
                      "finalized_files_count": 0,
                      "skipped_files_count": 0,
                      "skipped_code_counts": {},
                      "failed_files_count": 0
                    },
                    "uploads": [
                      {
                        "input_index": 0,
                        "path": "reports/q3.pdf",
                        "name": "q3.pdf",
                        "signed_blob_id": "eyJfcmFpbHMi...",
                        "upload": {
                          "url": "https://storage.example/upload",
                          "headers": {
                            "Content-Type": "application/pdf",
                            "Content-MD5": "rL0Y20zC+Fzt72VPzMSk2A=="
                          }
                        }
                      }
                    ],
                    "uploaded": [],
                    "uploaded_count": 0,
                    "uploaded_truncated": false,
                    "created_count": 0,
                    "updated_count": 0,
                    "skipped": [],
                    "skipped_count": 0,
                    "skipped_truncated": false
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/mailboxes/{mailbox_id}/upload_sessions/{session_id}/uploads": {
      "post": {
        "operationId": "addUploadSessionFiles",
        "tags": [
          "Files"
        ],
        "summary": "Get storage targets for a batch",
        "description": "Returns upload.url and upload.headers for each file that needs bytes. Repeating a path returns a fresh target, for example after a failed PUT. Files with identical content are skipped.",
        "parameters": [
          {
            "$ref": "#/components/parameters/MailboxId"
          },
          {
            "name": "session_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^bus_"
            },
            "description": "mailbox_upload_session.id from the create response."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "files"
                ],
                "properties": {
                  "files": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "$ref": "#/components/schemas/UploadSessionFile"
                    }
                  },
                  "account_id": {
                    "type": "string",
                    "description": "Select another granted account for this request."
                  },
                  "reason": {
                    "$ref": "#/components/schemas/ActionReason"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/UploadSessionResult"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/mailboxes/{mailbox_id}/upload_sessions/{session_id}/finalize_batch": {
      "post": {
        "operationId": "saveUploadSessionBatch",
        "tags": [
          "Files"
        ],
        "summary": "Save uploaded files",
        "description": "Saves up to limit files whose bytes were uploaded. Call it after each batch to keep each request short. DIRECT_UPLOAD_NOT_FOUND names a file whose bytes are missing in error.details.path; upload it again and retry.",
        "parameters": [
          {
            "$ref": "#/components/parameters/MailboxId"
          },
          {
            "name": "session_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^bus_"
            },
            "description": "mailbox_upload_session.id from the create response."
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "limit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 40,
                    "default": 40,
                    "description": "Files to save in this request."
                  },
                  "account_id": {
                    "type": "string",
                    "description": "Select another granted account for this request."
                  },
                  "reason": {
                    "$ref": "#/components/schemas/ActionReason"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/UploadSessionResult"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/mailboxes/{mailbox_id}/upload_sessions/{session_id}/finalize": {
      "post": {
        "operationId": "finalizeUploadSession",
        "tags": [
          "Files"
        ],
        "summary": "Finish or cancel a batch upload",
        "description": "complete=true saves the remaining uploaded files, creates one mailbox version and releases the lock. A 202 response with finalize_pending=true means more files remain: call finalize again after Retry-After. complete=false cancels the session and discards its unsaved files. Finalizing a finished session returns it unchanged.",
        "parameters": [
          {
            "$ref": "#/components/parameters/MailboxId"
          },
          {
            "name": "session_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^bus_"
            },
            "description": "mailbox_upload_session.id from the create response."
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "complete": {
                    "type": "boolean",
                    "default": true,
                    "description": "false cancels the session."
                  },
                  "account_id": {
                    "type": "string",
                    "description": "Select another granted account for this request."
                  },
                  "reason": {
                    "$ref": "#/components/schemas/ActionReason"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/UploadSessionResult"
                    }
                  }
                }
              }
            }
          },
          "202": {
            "description": "More files remain; call finalize again",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "data"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/UploadSessionResult"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Authorization: Bearer YOUR_API_KEY. Create a key in the dashboard under Account → Access."
      }
    },
    "schemas": {
      "ActionReason": {
        "type": [
          "string",
          "null"
        ],
        "maxLength": 2000,
        "description": "Optional purpose for this action. AI agents should explain intentional reads and changes when known; omit when unknown. Do not include secrets, file contents, or transcripts."
      },
      "Pagination": {
        "type": "object",
        "description": "One page of a list. Request the next page with cursor=next_cursor and the same filters. Cursors are opaque strings: do not build or decode them.",
        "required": [
          "limit",
          "has_more",
          "next_cursor"
        ],
        "properties": {
          "limit": {
            "type": "integer",
            "minimum": 1,
            "maximum": 200
          },
          "has_more": {
            "type": "boolean",
            "description": "True when another page exists."
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ],
            "description": "Cursor for the next page; null on the last page. Email lists always return a cursor so that you can poll for new mail."
          }
        }
      },
      "DeleteResult": {
        "type": "object",
        "required": [
          "deleted",
          "id"
        ],
        "properties": {
          "deleted": {
            "type": "boolean",
            "const": true
          },
          "id": {
            "type": "string",
            "description": "ID of the deleted resource. A webhook delete returns the mailbox ID."
          }
        }
      },
      "Download": {
        "type": "object",
        "description": "Temporary download link. Fetch url without an API key. Request a new link after it expires.",
        "required": [
          "url",
          "filename",
          "content_type",
          "expires_in",
          "size_bytes"
        ],
        "properties": {
          "url": {
            "type": "string",
            "format": "uri"
          },
          "filename": {
            "type": "string"
          },
          "content_type": {
            "type": [
              "string",
              "null"
            ]
          },
          "expires_in": {
            "type": "integer",
            "const": 900,
            "description": "Seconds until the link expires."
          },
          "size_bytes": {
            "type": "integer",
            "minimum": 0,
            "format": "int64"
          }
        }
      },
      "ErrorCode": {
        "type": "string",
        "description": "Documented values of error.code. Treat an unknown code as a generic failure for its HTTP status.",
        "enum": [
          "ACCOUNT_ACCESS_UNAVAILABLE",
          "ACCOUNT_ADMIN_REQUIRED",
          "ACCOUNT_CONNECTION_LIMIT_REACHED",
          "ACCOUNT_FILE_LIMIT_EXCEEDED",
          "ACCOUNT_READ_ONLY",
          "ACCOUNT_SELECTOR_CONFLICT",
          "ACCOUNT_SUSPENDED",
          "AGENCY_ACCOUNT_REQUIRED",
          "AGENT_CONNECTION_LIMIT_REACHED",
          "CLIENT_ACCOUNT_LIMIT_REACHED",
          "CONFLICT",
          "CONTENT_SEARCH_DISABLED",
          "DATABASE_BUSY_RETRY",
          "DIRECT_UPLOAD_ACCOUNT_MISMATCH",
          "DIRECT_UPLOAD_ALREADY_ATTACHED",
          "DIRECT_UPLOAD_ENCRYPTED",
          "DIRECT_UPLOAD_NOT_FOUND",
          "DIRECT_UPLOAD_PURPOSE_MISMATCH",
          "DIRECT_UPLOAD_REQUIRED",
          "DUPLICATE_FILE_VERSION",
          "EMAIL_ACCOUNT_DISABLED",
          "EMAIL_ADDRESS_CHANGED",
          "EMAIL_ALIAS_LIMIT",
          "EMAIL_ALLOWLIST_CHANGED",
          "EMAIL_ALLOWLIST_INVALID",
          "EMAIL_ALLOWLIST_UNAVAILABLE",
          "EMAIL_ALREADY_EXISTS",
          "EMAIL_ASSIGNMENT_EXPIRED",
          "EMAIL_ASSIGNMENT_FORBIDDEN",
          "EMAIL_ASSIGNMENT_PENDING",
          "EMAIL_ASSIGNMENT_UNAVAILABLE",
          "EMAIL_ATTACHMENT_NOT_FOUND",
          "EMAIL_CHANGED",
          "EMAIL_DNS_CONFLICT",
          "EMAIL_DNS_TEMPORARY",
          "EMAIL_DOMAINS_UNAVAILABLE",
          "EMAIL_DOMAINS_UNCONFIGURED",
          "EMAIL_DOMAINS_UPGRADE_REQUIRED",
          "EMAIL_DOMAIN_CONFIRMATION_REQUIRED",
          "EMAIL_DOMAIN_INVALID",
          "EMAIL_DOMAIN_IN_USE",
          "EMAIL_DOMAIN_NOT_READY",
          "EMAIL_DOMAIN_NOT_REGISTERED",
          "EMAIL_DOMAIN_RATE_LIMIT",
          "EMAIL_DOMAIN_UNAVAILABLE",
          "EMAIL_INDEX_BUILDING",
          "EMAIL_LABELING_PENDING",
          "EMAIL_LOOP_DETECTED",
          "EMAIL_MAILBOX_UNAVAILABLE",
          "EMAIL_NAMES_UNAVAILABLE",
          "EMAIL_NAMES_UPGRADE_REQUIRED",
          "EMAIL_NAME_FORBIDDEN",
          "EMAIL_NAME_INVALID",
          "EMAIL_NOT_READY",
          "EMAIL_OWNERSHIP_PENDING",
          "EMAIL_PATH_READ_ONLY",
          "EMAIL_PROVIDER_DNS_PENDING",
          "EMAIL_PROVIDER_PENDING",
          "EMAIL_PROVIDER_TEMPORARY",
          "EMAIL_READ_STATUS_UNAVAILABLE",
          "EMAIL_RECEIVING_PAUSED",
          "EMAIL_RECIPIENT_CAPACITY",
          "EMAIL_RECIPIENT_NOT_ALLOWED",
          "EMAIL_RECIPIENT_UNAVAILABLE",
          "EMAIL_ROTATION_LIMIT",
          "EMAIL_ROTATION_UNAVAILABLE",
          "EMAIL_SENDING_UNAVAILABLE",
          "EMAIL_SEND_LIMIT_REACHED",
          "EMAIL_SEND_RATE_LIMITED",
          "EMAIL_TOO_LARGE",
          "EMAIL_UNAVAILABLE",
          "EMAIL_WITHHELD",
          "EMPTY_FILE",
          "FILE_LOCKED",
          "FILE_TOO_LARGE",
          "FILE_VERSION_ALREADY_CURRENT",
          "FILE_VERSION_ENCRYPTION_MISMATCH",
          "FILE_VERSION_NOT_RESTORABLE",
          "FORBIDDEN",
          "INTERNAL_ERROR",
          "INVALID_ARGUMENT",
          "INVALID_CHECKSUM",
          "INVALID_CODE",
          "INVALID_DIRECT_UPLOAD",
          "INVALID_GRANT",
          "INVALID_SHA256",
          "INVALID_TEXT_ENCODING",
          "LOCKED",
          "MAILBOXES_NOT_FOUND",
          "MAILBOX_ACCESS_DENIED",
          "MAILBOX_ACCOUNT_CHANGED",
          "MAILBOX_ALREADY_ARCHIVED",
          "MAILBOX_ARCHIVED",
          "MAILBOX_CREATION_LIMIT_REACHED",
          "MAILBOX_DELETE_ADMIN_REQUIRED",
          "MAILBOX_DELETE_BUSY",
          "MAILBOX_DELETE_CONFIRMATION_REQUIRED",
          "MAILBOX_DELETE_ENQUEUE_FAILED",
          "MAILBOX_DELETE_IN_PROGRESS",
          "MAILBOX_FILE_DELETE_ENQUEUE_FAILED",
          "MAILBOX_FILE_LIMIT_EXCEEDED",
          "MAILBOX_FILE_NOT_FOUND",
          "MAILBOX_FILE_PATH_EXISTS",
          "MAILBOX_FILE_VERSION_NOT_FOUND",
          "MAILBOX_LIMIT_REACHED",
          "MAILBOX_LOCKED",
          "MAILBOX_METADATA_CONFLICT",
          "MAILBOX_TITLE_TAKEN",
          "MAILBOX_MOVING",
          "MAILBOX_NOT_ARCHIVED",
          "MAILBOX_NOT_FOUND",
          "MAILBOX_PERMISSION_DENIED",
          "MAILBOX_PUBLICATION_ACTIVE",
          "MAILBOX_PUBLICATION_SUSPENDED",
          "MAILBOX_TOO_LARGE",
          "MAILBOX_UNAVAILABLE",
          "MAILBOX_UPLOAD_EXISTING_FILE_SKIPPED",
          "MAILBOX_UPLOAD_FILE_ALREADY_FINALIZED",
          "MAILBOX_UPLOAD_FILE_FAILED",
          "MAILBOX_UPLOAD_FILE_SKIPPED",
          "MAILBOX_UPLOAD_SESSION_CANCELED",
          "MAILBOX_UPLOAD_SESSION_EXPIRED",
          "MAILBOX_UPLOAD_SESSION_INCOMPLETE",
          "MAILBOX_UPLOAD_SESSION_LOCK_LOST",
          "MAILBOX_UPLOAD_SESSION_NOT_PENDING",
          "MAILBOX_UPLOAD_SHA256_MISMATCH",
          "MAILBOX_UPLOAD_SIZE_MISMATCH",
          "MAILBOX_VERSION_CONFLICT",
          "MIME_TYPE_MISMATCH",
          "NOT_FOUND",
          "OTP_RATE_LIMITED",
          "PAYLOAD_TOO_LARGE",
          "PROHIBITED_FILE_EXTENSION",
          "PROJECT_STORAGE_QUOTA_EXCEEDED",
          "RATE_LIMIT_EXCEEDED",
          "SERVICE_UNAVAILABLE",
          "STORAGE_QUOTA_EXCEEDED",
          "UNAUTHORIZED",
          "UNSUPPORTED_MIME",
          "UNSUPPORTED_TEXT_APPEND_TYPE",
          "UPLOAD_RATE_LIMIT_EXCEEDED",
          "VERSION_ROLLBACK_UNAVAILABLE"
        ]
      },
      "ApiError": {
        "type": "object",
        "properties": {
          "success": {
            "const": false
          },
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "minLength": 1,
                "description": "Stable error identifier. See ErrorCode for the documented values. Invalid input always returns INVALID_ARGUMENT with HTTP 422."
              },
              "message": {
                "type": "string",
                "minLength": 1
              },
              "details": {
                "oneOf": [
                  {
                    "type": "object",
                    "additionalProperties": true
                  },
                  {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "field": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "field",
                        "message"
                      ]
                    }
                  }
                ]
              },
              "request_id": {
                "type": "string"
              },
              "docs_url": {
                "type": "string",
                "format": "uri"
              },
              "timestamp": {
                "type": "string",
                "format": "date-time"
              },
              "recoverable": {
                "type": "boolean"
              },
              "next_action": {
                "type": "string"
              },
              "browser_url": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ]
          }
        },
        "required": [
          "success",
          "error"
        ],
        "not": {
          "anyOf": [
            {
              "required": [
                "data"
              ]
            },
            {
              "required": [
                "error_message"
              ]
            }
          ]
        }
      },
      "AccountIdentity": {
        "type": "object",
        "required": [
          "id",
          "name",
          "account_kind",
          "client_name",
          "agency_account"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string",
            "description": "Account name, separate from the client person or business."
          },
          "account_kind": {
            "type": "string",
            "enum": [
              "standard",
              "agency",
              "client"
            ]
          },
          "client_name": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 100,
            "description": "Client person or business name, or null when unset."
          },
          "agency_account": {
            "type": [
              "object",
              "null"
            ],
            "description": "Parent agency only when granted to this credential. Null does not make a client independent.",
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            }
          },
          "region": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "read_only"
            ]
          },
          "permissions": {
            "type": "object",
            "properties": {
              "scope": {
                "type": "string",
                "enum": [
                  "mailbox_read",
                  "mailbox_write",
                  "mailbox_admin"
                ]
              },
              "mailbox_access": {
                "type": "string",
                "enum": [
                  "all",
                  "selected"
                ]
              },
              "can_create_mailboxes": {
                "type": "boolean"
              }
            }
          }
        }
      },
      "AccountList": {
        "type": "object",
        "required": [
          "accounts",
          "default_account_id",
          "pagination"
        ],
        "properties": {
          "accounts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AccountIdentity"
            }
          },
          "default_account_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Account used when a request does not send account_id."
          },
          "pagination": {
            "$ref": "#/components/schemas/Pagination"
          }
        }
      },
      "AccountLimits": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "max_mailboxes",
          "max_mailbox_creations_per_month",
          "max_files_per_mailbox",
          "max_current_files",
          "max_storage_bytes",
          "max_file_size_bytes",
          "max_pdf_size_bytes",
          "max_file_versions_per_file",
          "max_email_domains",
          "max_received_emails_per_month",
          "max_received_email_bytes_per_month",
          "max_received_email_message_bytes",
          "max_sent_emails_per_month",
          "max_email_address_rotations_per_month",
          "max_account_members",
          "max_api_keys",
          "max_agent_connections",
          "api_rate_limit_requests_per_minute",
          "audit_retention_days",
          "max_email_aliases_per_mailbox"
        ],
        "properties": {
          "max_mailboxes": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "max_mailbox_creations_per_month": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "max_files_per_mailbox": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "max_current_files": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "max_storage_bytes": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "format": "int64"
          },
          "max_file_size_bytes": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "format": "int64"
          },
          "max_pdf_size_bytes": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "format": "int64"
          },
          "max_file_versions_per_file": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "max_email_domains": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "max_received_emails_per_month": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "max_received_email_bytes_per_month": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "format": "int64"
          },
          "max_received_email_message_bytes": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "format": "int64"
          },
          "max_sent_emails_per_month": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "description": "Sent-email recipients per billing period, shared by the billing group. Each recipient counts once."
          },
          "max_email_address_rotations_per_month": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "max_account_members": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "max_api_keys": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "max_agent_connections": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "api_rate_limit_requests_per_minute": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "audit_retention_days": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "max_email_aliases_per_mailbox": {
            "type": "integer",
            "minimum": 0,
            "description": "Active retained email addresses per mailbox; Free always has zero."
          }
        }
      },
      "Connection": {
        "type": "object",
        "properties": {
          "api_key_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "label": {
            "type": [
              "string",
              "null"
            ]
          },
          "token_type": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "api",
              null
            ]
          },
          "scope": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "mailbox_read",
              "mailbox_write",
              "mailbox_admin",
              null
            ]
          },
          "expires_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "last_used_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "mailbox_access": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "all",
              "selected",
              null
            ]
          },
          "mailbox_ids": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "denied_mailbox_ids": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "mailbox_permissions": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "permissions": {
            "type": "object",
            "properties": {
              "read": {
                "type": "boolean"
              },
              "write": {
                "type": "boolean"
              },
              "admin": {
                "type": "boolean"
              }
            }
          },
          "agent": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": true
          },
          "transport": {
            "type": [
              "string",
              "null"
            ]
          },
          "renewal": {
            "type": "object",
            "properties": {
              "recommended": {
                "type": "boolean"
              },
              "next_action": {
                "type": "string"
              },
              "browser_url": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      },
      "Status": {
        "type": "object",
        "properties": {
          "connected": {
            "type": "boolean"
          },
          "account": {
            "type": "object",
            "additionalProperties": true,
            "description": "Selected account identity and state."
          },
          "default_account_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "accounts": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "server_version": {
            "type": "string"
          },
          "client_version": {
            "type": "string",
            "description": "Current CLI and skill release."
          },
          "features": {
            "type": "object",
            "properties": {
              "email_domains": {
                "type": "boolean"
              }
            }
          },
          "connection": {
            "$ref": "#/components/schemas/Connection"
          },
          "user": {
            "type": "object",
            "description": "The signed-in person behind this credential.",
            "properties": {
              "id": {
                "type": "string"
              },
              "email": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            }
          },
          "dashboard_url": {
            "type": "string",
            "format": "uri",
            "description": "Dashboard link for the selected account. It grants no access."
          }
        },
        "required": [
          "connected",
          "account",
          "connection"
        ]
      },
      "MailboxAction": {
        "type": "object",
        "properties": {
          "allowed": {
            "type": "boolean"
          },
          "blocked_reason": {
            "type": "string"
          },
          "required_action": {
            "type": "string"
          },
          "confirmation": {
            "type": "string",
            "description": "Delete only: send this value as confirmation in DELETE /v1/mailboxes/{mailbox_id} after the user confirms."
          }
        },
        "required": [
          "allowed"
        ]
      },
      "MailboxEmail": {
        "type": "object",
        "description": "Receiving and sending state of a mailbox. Counts read the email index without reading content.",
        "required": [
          "message_count",
          "unread_count",
          "last_received_at",
          "receiving_enabled",
          "sending_enabled"
        ],
        "properties": {
          "address": {
            "type": "string",
            "description": "Primary address. Present when the credential has write access to the mailbox. Show it after the title."
          },
          "message_count": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "minimum": 0,
            "description": "Emails currently stored. Null while the email index is being prepared."
          },
          "unread_count": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "minimum": 0,
            "description": "Stored emails with shared unread status. Null while the email index is being prepared."
          },
          "last_received_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Receipt time of the latest saved email; null before the first email."
          },
          "receiving_enabled": {
            "type": "boolean",
            "description": "Whether the mailbox can receive email now."
          },
          "blocked_reason": {
            "type": "string",
            "description": "Why receiving is unavailable. Omitted when receiving_enabled is true."
          },
          "sending_enabled": {
            "type": "boolean",
            "description": "Whether the mailbox can send replies now."
          },
          "sending_blocked_reason": {
            "type": "string",
            "description": "Why sending is unavailable. Omitted when sending_enabled is true."
          }
        }
      },
      "MailboxLock": {
        "type": "object",
        "required": [
          "locked"
        ],
        "properties": {
          "locked": {
            "type": "boolean"
          },
          "locked_until": {
            "type": "string",
            "format": "date-time"
          },
          "kind": {
            "type": "string",
            "description": "For example mailbox_delete while a permanent delete runs."
          },
          "message": {
            "type": "string"
          },
          "progress": {
            "type": "object",
            "additionalProperties": true
          },
          "locked_by": {
            "$ref": "#/components/schemas/FileActor"
          },
          "locked_by_api_key": {
            "$ref": "#/components/schemas/FileKey"
          }
        }
      },
      "Mailbox": {
        "type": "object",
        "description": "A mailbox: one receiving address with private file storage. Label it as title (email.address), or by email.address alone when title is null. Use id in API calls.",
        "required": [
          "id",
          "account_id",
          "email",
          "archived",
          "version_id",
          "version_number",
          "metadata_version",
          "archive",
          "unarchive",
          "delete"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^bkt_"
          },
          "account_id": {
            "type": "string"
          },
          "title": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 255,
            "description": "Mailbox title chosen by people. Defaults to the email username given at creation. Null when unset or when the caller cannot see email.address."
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true,
            "description": "Your application data. PATCH replaces the whole object."
          },
          "metadata_version": {
            "type": "string",
            "description": "Send as expected_metadata_version on PATCH. Changes only when description or metadata changes."
          },
          "email": {
            "$ref": "#/components/schemas/MailboxEmail"
          },
          "archived": {
            "type": "boolean"
          },
          "archived_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "lock": {
            "$ref": "#/components/schemas/MailboxLock"
          },
          "storage_bytes": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "files_count": {
            "type": "integer",
            "format": "int64",
            "minimum": 0,
            "description": "Current files, including stored emails and attachments."
          },
          "version_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Current mailbox file-tree version. Send as expected_mailbox_version on file writes to detect concurrent changes."
          },
          "version_number": {
            "type": "integer",
            "minimum": 0
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "updated_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "dashboard_url": {
            "type": "string",
            "format": "uri",
            "description": "Opens the mailbox for signed-in members. It does not grant access."
          },
          "archive": {
            "$ref": "#/components/schemas/MailboxAction"
          },
          "unarchive": {
            "$ref": "#/components/schemas/MailboxAction"
          },
          "delete": {
            "$ref": "#/components/schemas/MailboxAction"
          }
        }
      },
      "MailboxCounts": {
        "type": "object",
        "description": "Exact authorized mailbox totals after query filtering, before status filtering and pagination.",
        "properties": {
          "active": {
            "type": "integer",
            "minimum": 0,
            "format": "int64"
          },
          "archived": {
            "type": "integer",
            "minimum": 0,
            "format": "int64"
          },
          "total": {
            "type": "integer",
            "minimum": 0,
            "format": "int64"
          }
        },
        "required": [
          "active",
          "archived",
          "total"
        ]
      },
      "MailboxList": {
        "type": "object",
        "required": [
          "mailboxes",
          "counts",
          "pagination"
        ],
        "properties": {
          "mailboxes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Mailbox"
            }
          },
          "counts": {
            "$ref": "#/components/schemas/MailboxCounts"
          },
          "pagination": {
            "$ref": "#/components/schemas/Pagination"
          }
        }
      },
      "MailboxEmailOptions": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "username": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64,
            "description": "Free: a prefix normalized to dots, shortened to 59 characters, with a permanent 4-character random lowercase letter/digit suffix added. Paid: the exact name before @, normalized to lowercase, at least 6 characters on built-in domains. Omit to generate; blank/null is invalid. Unavailable names return EMAIL_ALREADY_EXISTS."
          },
          "domain": {
            "type": "string",
            "description": "Built-in domain such as revdokumail.com on any plan, or a ready custom email domain owned by the selected account on an eligible plan. Omit for the default platform domain."
          }
        }
      },
      "MailboxCreate": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "title": {
            "type": "string",
            "maxLength": 255,
            "description": "Optional title. Defaults to email.username as given, or to the generated name without its random suffix. A title that another active mailbox uses returns 409 MAILBOX_TITLE_TAKEN."
          },
          "description": {
            "type": "string",
            "maxLength": 2000
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true
          },
          "email": {
            "$ref": "#/components/schemas/MailboxEmailOptions"
          }
        }
      },
      "MailboxUpdate": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "title": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 255,
            "description": "New title. An empty string or null clears it. A title that another active mailbox uses returns 409 MAILBOX_TITLE_TAKEN."
          },
          "description": {
            "type": "string",
            "maxLength": 2000
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "EmailAlias": {
        "type": "object",
        "required": [
          "id",
          "address",
          "active"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "address": {
            "type": "string"
          },
          "active": {
            "type": "boolean",
            "description": "Within the current alias allowance. Mailbox receiving holds still apply."
          }
        }
      },
      "EmailSenderAllowlist": {
        "type": "object",
        "required": [
          "enabled",
          "entries",
          "version",
          "max_entries",
          "editable"
        ],
        "properties": {
          "enabled": {
            "type": "boolean"
          },
          "entries": {
            "type": "array",
            "maxItems": 500,
            "items": {
              "type": "string"
            }
          },
          "version": {
            "type": "string"
          },
          "max_entries": {
            "type": "integer"
          },
          "editable": {
            "type": "boolean"
          }
        }
      },
      "MailboxEmailSettings": {
        "type": "object",
        "description": "Address settings of one mailbox.",
        "required": [
          "message_count",
          "unread_count",
          "last_received_at",
          "receiving_enabled",
          "sending_enabled",
          "aliases"
        ],
        "properties": {
          "address": {
            "type": "string",
            "description": "Primary address. Present when the credential has write access to the mailbox. Show it after the title."
          },
          "message_count": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "minimum": 0,
            "description": "Emails currently stored. Null while the email index is being prepared."
          },
          "unread_count": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "minimum": 0,
            "description": "Stored emails with shared unread status. Null while the email index is being prepared."
          },
          "last_received_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Receipt time of the latest saved email; null before the first email."
          },
          "receiving_enabled": {
            "type": "boolean",
            "description": "Whether the mailbox can receive email now."
          },
          "blocked_reason": {
            "type": "string",
            "description": "Why receiving is unavailable. Omitted when receiving_enabled is true."
          },
          "sending_enabled": {
            "type": "boolean",
            "description": "Whether the mailbox can send replies now."
          },
          "sending_blocked_reason": {
            "type": "string",
            "description": "Why sending is unavailable. Omitted when sending_enabled is true."
          },
          "username": {
            "type": [
              "string",
              "null"
            ],
            "description": "The part of address before @."
          },
          "aliases": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailAlias"
            }
          },
          "available_domains": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "hostname": {
                  "type": "string"
                },
                "kind": {
                  "type": "string",
                  "enum": [
                    "platform",
                    "custom"
                  ]
                }
              }
            }
          },
          "assignment": {
            "type": "object",
            "description": "No candidate address is disclosed. Keep using address until status is active; on pending poll the email endpoint.",
            "properties": {
              "id": {
                "type": "string"
              },
              "status": {
                "type": "string",
                "enum": [
                  "pending",
                  "active",
                  "failed"
                ]
              },
              "hostname": {
                "type": "string"
              },
              "error": {
                "type": "object",
                "properties": {
                  "code": {
                    "type": "string"
                  },
                  "message": {
                    "type": "string"
                  },
                  "retryable": {
                    "type": "boolean"
                  }
                }
              }
            }
          },
          "customization": {
            "type": "object",
            "description": "Caller-specific customization capability on the dedicated email GET/rotate endpoints.",
            "properties": {
              "allowed": {
                "type": "boolean"
              },
              "blocked_reason": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "settings_url": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Account-domain settings link for administrators; null otherwise."
              }
            }
          },
          "sender_allowlist": {
            "$ref": "#/components/schemas/EmailSenderAllowlist",
            "description": "Returned to account administrators with mailbox-admin permission."
          }
        }
      },
      "Webhook": {
        "type": "object",
        "required": [
          "url",
          "event"
        ],
        "properties": {
          "url": {
            "type": "string",
            "format": "uri"
          },
          "event": {
            "type": "string",
            "const": "email.received"
          }
        }
      },
      "WebhookWithSecret": {
        "type": "object",
        "required": [
          "url",
          "event"
        ],
        "properties": {
          "url": {
            "type": "string",
            "format": "uri"
          },
          "event": {
            "type": "string",
            "const": "email.received"
          },
          "signing_secret": {
            "type": "string",
            "description": "Returned once, when this request issues a secret: a new URL or rotate_secret=true. Store it to verify signatures."
          }
        }
      },
      "EmailSubscription": {
        "type": "object",
        "required": [
          "token",
          "expires_in",
          "channel",
          "account_id",
          "mailbox_id",
          "websocket_url"
        ],
        "properties": {
          "token": {
            "type": "string"
          },
          "expires_in": {
            "type": "integer",
            "const": 60
          },
          "channel": {
            "type": "string",
            "const": "EmailReceivedChannel"
          },
          "account_id": {
            "type": "string"
          },
          "mailbox_id": {
            "type": "string"
          },
          "websocket_url": {
            "type": "string",
            "format": "uri",
            "description": "Base WebSocket endpoint. Append email_subscription_token as a query parameter."
          }
        }
      },
      "EmailReceivedEvent": {
        "type": "object",
        "required": [
          "id",
          "type",
          "created_at",
          "data"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Stable event ID; deduplicate across retries."
          },
          "type": {
            "type": "string",
            "const": "email.received"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "type": "object",
            "required": [
              "account_id",
              "mailbox_id",
              "email_id",
              "received_at",
              "attachment_count"
            ],
            "properties": {
              "account_id": {
                "type": "string"
              },
              "mailbox_id": {
                "type": "string"
              },
              "email_id": {
                "type": "string"
              },
              "received_at": {
                "type": "string",
                "format": "date-time"
              },
              "attachment_count": {
                "type": "integer",
                "minimum": 0
              }
            }
          }
        }
      },
      "DecodedEmailAddress": {
        "type": "object",
        "required": [
          "address",
          "name"
        ],
        "properties": {
          "address": {
            "type": "string"
          },
          "name": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "EmailForwarding": {
        "type": "object",
        "description": "Server-recorded member forwarding provenance. The original author is reported by the member, not independently authenticated. Absent for ordinary or unrecognized mail.",
        "required": [
          "attribution",
          "method",
          "parser_version",
          "member_id",
          "member_email",
          "intake_account_id"
        ],
        "properties": {
          "method": {
            "type": "string"
          },
          "member_id": {
            "type": "string"
          },
          "member_email": {
            "type": "string"
          },
          "intake_account_id": {
            "type": "string"
          },
          "outer_from": {
            "type": "string"
          },
          "outer_subject": {
            "type": "string"
          },
          "outer_message_id": {
            "type": "string"
          },
          "original_date_raw": {
            "type": "string"
          },
          "original_sent_at": {
            "type": "string"
          },
          "attribution": {
            "type": "string",
            "const": "member_forwarded"
          },
          "parser_version": {
            "type": "integer",
            "minimum": 1,
            "description": "Parser implementation used at intake; does not change the forwarding response shape."
          }
        }
      },
      "EmailForwardingContent": {
        "allOf": [
          {
            "$ref": "#/components/schemas/EmailForwarding"
          },
          {
            "type": "object",
            "properties": {
              "note_text": {
                "type": "string",
                "description": "Separate member note, bounded to 64 KiB. Never part of the original body."
              },
              "note_status": {
                "type": "string",
                "enum": [
                  "complete",
                  "empty",
                  "truncated",
                  "unavailable"
                ]
              }
            }
          }
        ]
      },
      "EmailDelivery": {
        "type": "object",
        "description": "Present on sent emails only.",
        "required": [
          "status",
          "recipients"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "sending",
              "sent",
              "failed",
              "uncertain"
            ],
            "description": "uncertain: the provider result is unknown. Do not send again before you check the sent list."
          },
          "recipients": {
            "type": "object",
            "description": "Status for each recipient address: queued, sent, delivered, bounced, bounced_temporarily, complained or rejected.",
            "additionalProperties": {
              "type": "string"
            }
          }
        }
      },
      "EmailLabel": {
        "type": "object",
        "required": [
          "id",
          "name",
          "color"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^tag_"
          },
          "name": {
            "type": "string"
          },
          "color": {
            "type": "string",
            "enum": [
              "red",
              "orange",
              "yellow",
              "green",
              "blue",
              "purple",
              "gray"
            ]
          }
        }
      },
      "SendEmailRequest": {
        "type": "object",
        "required": [
          "text"
        ],
        "properties": {
          "to": {
            "type": "array",
            "maxItems": 10,
            "items": {
              "type": "string",
              "format": "email"
            },
            "description": "Recipient addresses, one per item. Optional with in_reply_to; defaults to the authenticated sender of that email. To and cc together allow at most 10 addresses."
          },
          "cc": {
            "type": "array",
            "maxItems": 10,
            "items": {
              "type": "string",
              "format": "email"
            },
            "description": "Carbon-copy addresses. Bcc is not supported."
          },
          "subject": {
            "type": "string",
            "maxLength": 255,
            "description": "Required without in_reply_to. Defaults to \"Re: \" plus the original subject."
          },
          "text": {
            "type": "string",
            "minLength": 1,
            "description": "Plain-text body, up to 1 MiB."
          },
          "html": {
            "type": "string",
            "description": "Optional HTML body, up to 1 MiB."
          },
          "in_reply_to": {
            "type": "string",
            "pattern": "^eml_",
            "description": "Received email ID to reply to. Sets reply headers and the conversation."
          },
          "attachment_ids": {
            "type": "array",
            "maxItems": 10,
            "items": {
              "type": "string",
              "pattern": "^df_"
            },
            "description": "Existing file IDs in this mailbox to attach."
          },
          "account_id": {
            "type": "string"
          },
          "reason": {
            "$ref": "#/components/schemas/ActionReason"
          }
        }
      },
      "EmailAttachment": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^df_"
          },
          "filename": {
            "type": "string"
          },
          "content_type": {
            "type": [
              "string",
              "null"
            ]
          },
          "size_bytes": {
            "type": "integer",
            "minimum": 0,
            "format": "int64"
          },
          "version_id": {
            "type": "string",
            "description": "Present only with include_storage=true."
          },
          "origin": {
            "type": "string",
            "enum": [
              "original",
              "forwarder",
              "forwarded_message",
              "unspecified"
            ],
            "description": "For normalized forwards: inner attachment, member addition, attached source EML, or unknown inline-forward origin."
          }
        },
        "required": [
          "id",
          "filename",
          "content_type",
          "size_bytes"
        ]
      },
      "DecodedIncomingMessage": {
        "type": "object",
        "description": "Stored message.json, not a dedicated endpoint. UTF-8, at most 512 KiB. Header identities, reply relationships and body are untrusted message data. Original message.eml is authoritative. Structured address, delivery and thread fields are additive in schema v1 and may be absent in older files.",
        "required": [
          "schema_version",
          "subject",
          "from",
          "to",
          "delivered_to",
          "received_at",
          "body_text",
          "body_status",
          "attachments"
        ],
        "properties": {
          "schema_version": {
            "type": "integer",
            "const": 1
          },
          "subject": {
            "type": [
              "string",
              "null"
            ]
          },
          "from": {
            "type": [
              "string",
              "null"
            ]
          },
          "to": {
            "type": [
              "string",
              "null"
            ]
          },
          "from_addresses": {
            "type": "array",
            "description": "Parsed From authors in header order, retaining multiple authors. Empty when absent/unparseable. Display names are not identity keys.",
            "items": {
              "$ref": "#/components/schemas/DecodedEmailAddress"
            }
          },
          "to_addresses": {
            "type": "array",
            "description": "Parsed To recipients in header order, with named groups flattened. Empty when absent/unparseable; not trusted delivery routing.",
            "items": {
              "$ref": "#/components/schemas/DecodedEmailAddress"
            }
          },
          "cc_addresses": {
            "type": "array",
            "description": "Parsed Cc recipients in header order, with named groups flattened. Empty when absent/unparseable.",
            "items": {
              "$ref": "#/components/schemas/DecodedEmailAddress"
            }
          },
          "reply_to_addresses": {
            "type": "array",
            "description": "Parsed Reply-To addresses in header order. Empty when absent/unparseable. Does not authorize sending a reply.",
            "items": {
              "$ref": "#/components/schemas/DecodedEmailAddress"
            }
          },
          "message_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Sender Message-ID without angle brackets, preserving case. Null when absent/unparseable/ambiguous; never the Revdoku delivery ID."
          },
          "in_reply_to": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Ordered parent Message-IDs without angle brackets, preserving case. Empty when absent/unparseable; multiple parents are retained."
          },
          "references": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Ordered References IDs without angle brackets, preserving case. Empty when absent/unparseable."
          },
          "delivery_id": {
            "type": "string",
            "pattern": "^[0-9a-f]{32}$",
            "description": "Revdoku delivery identity, matching email_delivery_id metadata and the original folder suffix. Stable on retries, independent of Message-ID. Copies retain the source identity; not a unique file/copy ID."
          },
          "thread_id": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^thr_[0-9a-f]{64}$",
            "description": "thr_ plus SHA-256 of thread_anchor_message_id. Best-effort header-derived grouping hint, not authoritative conversation membership or an access grant. Missing ancestry or reused IDs can split/merge hints. Scope lookups to accessible mailboxes."
          },
          "thread_id_source": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "references",
              "in_reply_to",
              "message_id",
              null
            ]
          },
          "thread_anchor_message_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "First References ID, otherwise the sole In-Reply-To ID, otherwise this message's ID if no parent is available. Null without an anchor or when multiple parents lack References."
          },
          "delivered_to": {
            "type": "string"
          },
          "received_at": {
            "type": "string",
            "format": "date-time"
          },
          "body_text": {
            "type": [
              "string",
              "null"
            ]
          },
          "body_status": {
            "type": "string",
            "enum": [
              "complete",
              "empty",
              "truncated",
              "unavailable"
            ]
          },
          "omitted_attachment_count": {
            "type": "integer",
            "minimum": 1
          },
          "attachments": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "path",
                "original_filename",
                "content_type",
                "size_bytes"
              ],
              "properties": {
                "path": {
                  "type": "string",
                  "description": "Relative to message folder."
                },
                "original_filename": {
                  "type": "string"
                },
                "content_type": {
                  "type": "string"
                },
                "size_bytes": {
                  "type": "integer",
                  "minimum": 0,
                  "format": "int64"
                },
                "origin": {
                  "type": "string",
                  "enum": [
                    "original",
                    "forwarder",
                    "forwarded_message",
                    "unspecified"
                  ],
                  "description": "For normalized forwards: inner attachment, member addition, attached source EML, or unknown inline-forward origin."
                }
              }
            }
          },
          "forwarding": {
            "$ref": "#/components/schemas/EmailForwardingContent"
          },
          "cc": {
            "type": [
              "string",
              "null"
            ],
            "description": "Decoded Cc header; use the corresponding parsed address array for individual addresses."
          },
          "reply_to": {
            "type": [
              "string",
              "null"
            ],
            "description": "Decoded Reply-To header; use the corresponding parsed address array for individual addresses."
          }
        }
      },
      "EmailSummary": {
        "type": "object",
        "properties": {
          "subject": {
            "type": [
              "string",
              "null"
            ]
          },
          "from_addresses": {
            "type": "array",
            "description": "Parsed From authors in header order, retaining multiple authors. Empty when absent/unparseable. Display names are not identity keys.",
            "items": {
              "$ref": "#/components/schemas/DecodedEmailAddress"
            }
          },
          "to_addresses": {
            "type": "array",
            "description": "Parsed To recipients in header order, with named groups flattened. Empty when absent/unparseable; not trusted delivery routing.",
            "items": {
              "$ref": "#/components/schemas/DecodedEmailAddress"
            }
          },
          "cc_addresses": {
            "type": "array",
            "description": "Parsed Cc recipients in header order, with named groups flattened. Empty when absent/unparseable.",
            "items": {
              "$ref": "#/components/schemas/DecodedEmailAddress"
            }
          },
          "reply_to_addresses": {
            "type": "array",
            "description": "Parsed Reply-To addresses in header order. Empty when absent/unparseable. Does not authorize sending a reply.",
            "items": {
              "$ref": "#/components/schemas/DecodedEmailAddress"
            }
          },
          "message_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Sender Message-ID without angle brackets, preserving case. Null when absent/unparseable/ambiguous; never the Revdoku delivery ID."
          },
          "in_reply_to": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Ordered parent Message-IDs without angle brackets, preserving case. Empty when absent/unparseable; multiple parents are retained."
          },
          "references": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Ordered References IDs without angle brackets, preserving case. Empty when absent/unparseable."
          },
          "delivered_to": {
            "type": "string"
          },
          "received_at": {
            "type": "string",
            "format": "date-time",
            "description": "Receipt time. For sent emails, the time Revdoku accepted the send."
          },
          "body_status": {
            "type": "string",
            "enum": [
              "complete",
              "empty",
              "truncated",
              "unavailable",
              "withheld"
            ]
          },
          "omitted_attachment_count": {
            "type": "integer",
            "minimum": 1
          },
          "id": {
            "type": "string",
            "pattern": "^eml_"
          },
          "conversation_id": {
            "type": "string",
            "pattern": "^eml_",
            "description": "Email ID that identifies the conversation. Replies are linked by email headers. Filter a list with conversation_id."
          },
          "direction": {
            "type": "string",
            "enum": [
              "received",
              "sent"
            ],
            "description": "received for incoming email; sent for email sent from this mailbox."
          },
          "delivery": {
            "$ref": "#/components/schemas/EmailDelivery"
          },
          "labels": {
            "type": "array",
            "description": "Labels on the email files. AI labels add one built-in category label, such as Junk or Receipts, a few seconds after the email arrives, usually after the email.received event.",
            "items": {
              "$ref": "#/components/schemas/EmailLabel"
            }
          },
          "withheld": {
            "type": "boolean",
            "description": "True when the email has the built-in Junk label. The subject, display names, sender address (except its domain), body and attachments are hidden, and downloads of the email and its files return EMAIL_WITHHELD. A person can review the email in the dashboard and remove the label."
          },
          "file_id": {
            "type": "string",
            "pattern": "^df_",
            "description": "Included only with include_storage=true for file-browser integration."
          },
          "version_id": {
            "type": "string",
            "description": "Included only with include_storage=true for file-browser integration."
          },
          "attachment_count": {
            "type": "integer",
            "minimum": 0
          },
          "read": {
            "type": "boolean"
          },
          "read_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "read_by": {
            "type": [
              "object",
              "null"
            ]
          },
          "read_by_api_key": {
            "type": [
              "object",
              "null"
            ]
          },
          "files": {
            "type": "object",
            "properties": {
              "body_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "original_id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "attachment_ids": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "directory": {
                "type": "string",
                "description": "Storage folder containing this email, without a trailing slash."
              }
            },
            "required": [
              "body_id",
              "original_id",
              "attachment_ids"
            ],
            "description": "Included only with include_storage=true for file-browser integration."
          },
          "forwarding": {
            "$ref": "#/components/schemas/EmailForwarding"
          }
        },
        "required": [
          "id",
          "conversation_id",
          "direction",
          "received_at",
          "attachment_count",
          "labels",
          "withheld",
          "read",
          "read_at",
          "read_by",
          "read_by_api_key"
        ]
      },
      "EmailDetail": {
        "allOf": [
          {
            "$ref": "#/components/schemas/EmailSummary"
          },
          {
            "type": "object",
            "properties": {
              "body_text": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "body_status": {
                "type": "string",
                "enum": [
                  "complete",
                  "empty",
                  "truncated",
                  "unavailable",
                  "withheld"
                ]
              },
              "attachments": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/EmailAttachment"
                }
              },
              "forwarding": {
                "$ref": "#/components/schemas/EmailForwardingContent"
              }
            },
            "required": [
              "body_text",
              "body_status",
              "attachments"
            ]
          }
        ]
      },
      "EmailList": {
        "type": "object",
        "required": [
          "emails",
          "pagination"
        ],
        "properties": {
          "emails": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailSummary"
            }
          },
          "pagination": {
            "$ref": "#/components/schemas/Pagination"
          }
        }
      },
      "FileActor": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "email": {
            "type": "string"
          }
        }
      },
      "FileKey": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "token_type": {
            "type": "string"
          }
        }
      },
      "FileVersionReason": {
        "type": "object",
        "properties": {
          "version_id": {
            "type": "string"
          },
          "reason": {
            "type": "string"
          },
          "created_by_id": {
            "type": "string"
          },
          "version_number": {
            "type": "integer",
            "format": "int64"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "UploadBlob": {
        "type": "object",
        "properties": {
          "filename": {
            "type": "string"
          },
          "byte_size": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "checksum": {
            "type": "string"
          },
          "content_type": {
            "type": "string"
          },
          "sha256": {
            "type": "string"
          },
          "purpose": {
            "type": "string",
            "enum": [
              "mailbox_file"
            ]
          }
        },
        "required": [
          "filename",
          "byte_size",
          "checksum",
          "content_type",
          "sha256",
          "purpose"
        ]
      },
      "StorageUpload": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "format": "uri"
          },
          "headers": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          }
        },
        "required": [
          "url",
          "headers"
        ]
      },
      "FileUploadSkip": {
        "type": "object",
        "properties": {
          "path": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "reason": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "input_index": {
            "type": "integer"
          },
          "details": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "FileVersion": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "file_id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "mime_type": {
            "type": "string"
          },
          "sha256": {
            "type": "string"
          },
          "reason": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_by_system": {
            "type": "string"
          },
          "deleted": {
            "type": "boolean",
            "description": "True for the version that records a deletion."
          },
          "ready": {
            "type": "boolean"
          },
          "has_text": {
            "type": "boolean"
          },
          "version_number": {
            "type": "integer",
            "format": "int64"
          },
          "byte_size": {
            "type": "integer",
            "format": "int64"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "created_by": {
            "$ref": "#/components/schemas/FileActor"
          },
          "updated_by": {
            "$ref": "#/components/schemas/FileActor"
          },
          "created_by_agent": {
            "type": "object",
            "additionalProperties": true
          },
          "updated_by_agent": {
            "type": "object",
            "additionalProperties": true
          },
          "created_by_api_key": {
            "type": "object",
            "additionalProperties": true
          },
          "updated_by_api_key": {
            "type": "object",
            "additionalProperties": true
          },
          "read": {
            "type": "boolean"
          },
          "read_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "read_by": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/FileActor"
              },
              {
                "type": "null"
              }
            ]
          },
          "read_by_api_key": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/FileKey"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "id",
          "file_id",
          "version_number"
        ]
      },
      "MailboxFile": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "mailbox_id": {
            "type": "string",
            "pattern": "^bkt_"
          },
          "basename": {
            "type": "string"
          },
          "path": {
            "type": "string"
          },
          "role": {
            "type": "string"
          },
          "created_by_system": {
            "type": "string"
          },
          "deleted": {
            "type": "boolean"
          },
          "version_reasons": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FileVersionReason"
            }
          },
          "lock": {
            "type": "object",
            "additionalProperties": true
          },
          "current_file_version": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/FileVersion"
              },
              {
                "type": "null"
              }
            ]
          },
          "created_by": {
            "$ref": "#/components/schemas/FileActor"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "deleted_at": {
            "type": "string",
            "format": "date-time"
          },
          "created_by_agent": {
            "type": "object",
            "additionalProperties": true
          },
          "updated_by_agent": {
            "type": "object",
            "additionalProperties": true
          },
          "created_by_api_key": {
            "type": "object",
            "additionalProperties": true
          },
          "updated_by_api_key": {
            "type": "object",
            "additionalProperties": true
          },
          "read": {
            "type": "boolean"
          },
          "read_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "read_by": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/FileActor"
              },
              {
                "type": "null"
              }
            ]
          },
          "read_by_api_key": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/FileKey"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "id",
          "path"
        ]
      },
      "FileList": {
        "type": "object",
        "required": [
          "files",
          "pagination"
        ],
        "properties": {
          "files": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MailboxFile"
            }
          },
          "pagination": {
            "$ref": "#/components/schemas/Pagination"
          }
        }
      },
      "FileVersionList": {
        "type": "object",
        "required": [
          "versions",
          "pagination"
        ],
        "properties": {
          "versions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FileVersion"
            }
          },
          "pagination": {
            "$ref": "#/components/schemas/Pagination"
          }
        }
      },
      "FileDownload": {
        "type": "object",
        "required": [
          "download",
          "version"
        ],
        "properties": {
          "download": {
            "$ref": "#/components/schemas/Download"
          },
          "version": {
            "$ref": "#/components/schemas/FileVersion"
          },
          "previously_read": {
            "type": "boolean",
            "description": "Read state before this request, when tracking succeeded."
          }
        }
      },
      "PrepareFileUploadRequest": {
        "type": "object",
        "required": [
          "mailbox_id",
          "path",
          "blob"
        ],
        "properties": {
          "mailbox_id": {
            "type": "string"
          },
          "path": {
            "type": "string",
            "description": "Destination path in the mailbox. Paths under _email/ return EMAIL_PATH_READ_ONLY."
          },
          "existing_file_policy": {
            "type": "string",
            "enum": [
              "replace",
              "skip"
            ],
            "default": "replace",
            "description": "skip returns the existing file without an upload when the path exists."
          },
          "blob": {
            "$ref": "#/components/schemas/UploadBlob"
          },
          "account_id": {
            "type": "string"
          },
          "reason": {
            "$ref": "#/components/schemas/ActionReason"
          }
        }
      },
      "PreparedFileUpload": {
        "type": "object",
        "properties": {
          "signed_id": {
            "type": "string"
          },
          "filename": {
            "type": "string"
          },
          "byte_size": {
            "type": "integer",
            "format": "int64"
          },
          "checksum": {
            "type": "string"
          },
          "content_type": {
            "type": "string"
          },
          "direct_upload": {
            "$ref": "#/components/schemas/StorageUpload"
          },
          "file": {
            "$ref": "#/components/schemas/MailboxFile"
          },
          "version": {
            "$ref": "#/components/schemas/FileVersion"
          },
          "skipped": {
            "type": "boolean"
          },
          "duplicate": {
            "type": "boolean"
          },
          "reason": {
            "type": "string"
          },
          "details": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "description": "A new upload returns signed_id and direct_upload. Identical content returns skipped=true, duplicate=true, file and version without a storage upload."
      },
      "SaveUploadedFileRequest": {
        "type": "object",
        "required": [
          "path",
          "signed_blob_id"
        ],
        "properties": {
          "path": {
            "type": "string",
            "description": "Destination path. An existing path receives a new version. Paths under _email/ return EMAIL_PATH_READ_ONLY."
          },
          "signed_blob_id": {
            "type": "string",
            "description": "data.signed_id from POST /v1/direct_uploads."
          },
          "name": {
            "type": "string",
            "description": "Display name; defaults to the last path segment."
          },
          "role": {
            "type": "string",
            "enum": [
              "source",
              "reference",
              "generated",
              "agent_output",
              "export",
              "artifact"
            ],
            "default": "source"
          },
          "existing_file_policy": {
            "type": "string",
            "enum": [
              "replace",
              "skip"
            ],
            "default": "replace"
          },
          "expected_mailbox_version": {
            "type": "string",
            "description": "Mailbox version_id from your last read. A different current version returns MAILBOX_VERSION_CONFLICT and saves nothing."
          },
          "account_id": {
            "type": "string"
          },
          "reason": {
            "$ref": "#/components/schemas/ActionReason"
          }
        }
      },
      "SavedFile": {
        "type": "object",
        "properties": {
          "file": {
            "$ref": "#/components/schemas/MailboxFile"
          },
          "version": {
            "$ref": "#/components/schemas/FileVersion"
          },
          "created": {
            "type": "boolean"
          },
          "skipped": {
            "$ref": "#/components/schemas/FileUploadSkip"
          },
          "duplicate": {
            "type": "boolean"
          }
        },
        "required": [
          "file",
          "version",
          "created"
        ]
      },
      "AppendTextResult": {
        "type": "object",
        "required": [
          "file",
          "version",
          "path",
          "appended",
          "appended_bytes",
          "newline_inserted"
        ],
        "properties": {
          "file": {
            "$ref": "#/components/schemas/MailboxFile"
          },
          "version": {
            "$ref": "#/components/schemas/FileVersion"
          },
          "path": {
            "type": "string"
          },
          "appended": {
            "type": "boolean",
            "const": true
          },
          "appended_bytes": {
            "type": "integer",
            "minimum": 0
          },
          "newline_inserted": {
            "type": "boolean"
          }
        }
      },
      "PathOperationResult": {
        "type": "object",
        "required": [
          "operation",
          "skipped",
          "path"
        ],
        "properties": {
          "operation": {
            "type": "string",
            "enum": [
              "rename",
              "move",
              "copy"
            ]
          },
          "skipped": {
            "type": "boolean",
            "description": "True when the file already had the requested path."
          },
          "old_path": {
            "type": "string"
          },
          "path": {
            "type": "string"
          },
          "source_mailbox_id": {
            "type": "string"
          },
          "target_mailbox_id": {
            "type": "string"
          },
          "source_file": {
            "$ref": "#/components/schemas/MailboxFile"
          },
          "file": {
            "$ref": "#/components/schemas/MailboxFile"
          },
          "version": {
            "$ref": "#/components/schemas/FileVersion"
          }
        }
      },
      "RestoredFileVersion": {
        "type": "object",
        "required": [
          "file",
          "version",
          "restored_from"
        ],
        "properties": {
          "file": {
            "$ref": "#/components/schemas/MailboxFile"
          },
          "version": {
            "$ref": "#/components/schemas/FileVersion"
          },
          "restored_from": {
            "$ref": "#/components/schemas/FileVersion"
          }
        }
      },
      "DnsRecord": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "value": {
            "type": "string"
          },
          "purpose": {
            "type": "string"
          },
          "zone": {
            "type": "string"
          },
          "relative_name": {
            "type": "string"
          }
        },
        "required": [
          "type",
          "name",
          "value",
          "purpose",
          "zone",
          "relative_name"
        ]
      },
      "EmailDomainCheck": {
        "type": "object",
        "properties": {
          "hostname": {
            "type": "string"
          },
          "root_domain": {
            "type": "boolean"
          },
          "suggested_subdomain": {
            "type": [
              "string",
              "null"
            ]
          },
          "root_guidance": {
            "type": "string"
          }
        },
        "required": [
          "hostname",
          "root_domain"
        ]
      },
      "EmailDomain": {
        "type": "object",
        "properties": {
          "suggested_subdomain": {
            "type": [
              "string",
              "null"
            ]
          },
          "root_guidance": {
            "type": [
              "string",
              "null"
            ]
          },
          "pause_reason": {
            "type": [
              "string",
              "null"
            ]
          },
          "id": {
            "type": "string"
          },
          "hostname": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "guidance": {
            "type": "string"
          },
          "receiving": {
            "type": "boolean"
          },
          "root_domain": {
            "type": "boolean"
          },
          "paused_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "last_checked_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "ownership_verified_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "setup_expires_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "ready_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "required_dns_records": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DnsRecord"
            }
          },
          "error": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "code": {
                    "type": "string"
                  },
                  "message": {
                    "type": "string"
                  },
                  "retryable": {
                    "type": "boolean"
                  }
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "assigned_mailboxes": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "email": {
                  "type": "object",
                  "properties": {
                    "address": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "required": [
          "id",
          "hostname",
          "status"
        ]
      },
      "EmailDomainList": {
        "type": "object",
        "required": [
          "domains",
          "enabled",
          "pagination"
        ],
        "properties": {
          "domains": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EmailDomain"
            }
          },
          "enabled": {
            "type": "boolean",
            "description": "Whether this account can use custom email domains."
          },
          "guidance": {
            "type": "string"
          },
          "pagination": {
            "$ref": "#/components/schemas/Pagination"
          }
        }
      },
      "CodeRequested": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "expires_in_seconds": {
            "type": "integer"
          },
          "fallback_url": {
            "type": "string",
            "format": "uri"
          },
          "hint": {
            "type": "string"
          }
        }
      },
      "AgentConnection": {
        "type": "object",
        "description": "A new API key for an AI agent or the CLI. Store api_key securely; it is shown only once.",
        "required": [
          "api_key",
          "account_id",
          "scope"
        ],
        "properties": {
          "api_key": {
            "type": "string"
          },
          "account_id": {
            "type": "string"
          },
          "account_name": {
            "type": "string"
          },
          "scope": {
            "type": "string",
            "enum": [
              "mailbox_read",
              "mailbox_write",
              "mailbox_admin"
            ]
          },
          "mailbox_access": {
            "type": "string",
            "enum": [
              "all",
              "selected"
            ]
          },
          "mailbox_ids": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "mailbox_permissions": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "account_connection_limits": {
            "type": "object",
            "additionalProperties": true
          },
          "expires_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "manage_access": {
            "type": "object",
            "additionalProperties": true
          },
          "mailboxes": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "guidance": {
            "type": "string"
          }
        }
      },
      "BrowserLink": {
        "type": "object",
        "required": [
          "url",
          "path"
        ],
        "properties": {
          "url": {
            "type": "string",
            "format": "uri",
            "description": "Dashboard link. The user signs in normally; the link grants nothing."
          },
          "path": {
            "type": "string"
          },
          "single_use": {
            "type": "boolean"
          },
          "requires_login": {
            "type": "boolean"
          },
          "redirect_path": {
            "type": "string"
          }
        }
      },
      "UploadSessionFile": {
        "type": "object",
        "required": [
          "path",
          "byte_size",
          "content_type",
          "checksum",
          "sha256"
        ],
        "properties": {
          "path": {
            "type": "string",
            "description": "Destination path in the mailbox. Paths under _email/ return EMAIL_PATH_READ_ONLY."
          },
          "byte_size": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "content_type": {
            "type": "string"
          },
          "checksum": {
            "type": "string",
            "description": "Base64-encoded MD5 of the bytes."
          },
          "sha256": {
            "type": "string",
            "description": "Hex SHA-256 of the bytes."
          }
        }
      },
      "UploadSessionUpload": {
        "type": "object",
        "required": [
          "path",
          "upload"
        ],
        "properties": {
          "input_index": {
            "type": "integer"
          },
          "path": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "signed_blob_id": {
            "type": "string"
          },
          "upload": {
            "$ref": "#/components/schemas/StorageUpload"
          }
        },
        "description": "PUT the bytes of path to upload.url with exactly upload.headers and no API key."
      },
      "UploadSession": {
        "type": "object",
        "required": [
          "id",
          "mailbox_id",
          "status"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^bus_"
          },
          "mailbox_id": {
            "type": "string",
            "pattern": "^bkt_"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "finalized",
              "expired",
              "failed"
            ],
            "description": "pending accepts uploads. failed means canceled; its unsaved files were discarded."
          },
          "base_mailbox_version_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Mailbox version when the session started."
          },
          "target_mailbox_version_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Mailbox version created by the final save."
          },
          "uploads_expire_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Unsaved uploads are discarded after this time."
          },
          "session_closed_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "files_count": {
            "type": "integer",
            "minimum": 0
          },
          "pending_files_count": {
            "type": "integer",
            "minimum": 0
          },
          "uploaded_files_count": {
            "type": "integer",
            "minimum": 0
          },
          "finalized_files_count": {
            "type": "integer",
            "minimum": 0
          },
          "skipped_files_count": {
            "type": "integer",
            "minimum": 0
          },
          "skipped_code_counts": {
            "type": "object",
            "additionalProperties": {
              "type": "integer"
            },
            "description": "Skipped files per skip code."
          },
          "failed_files_count": {
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "UploadedFile": {
        "type": "object",
        "required": [
          "path",
          "file",
          "version",
          "created"
        ],
        "properties": {
          "input_index": {
            "type": "integer"
          },
          "path": {
            "type": "string"
          },
          "file": {
            "$ref": "#/components/schemas/MailboxFile"
          },
          "version": {
            "$ref": "#/components/schemas/FileVersion"
          },
          "created": {
            "type": "boolean",
            "description": "False when the path received a new version."
          }
        }
      },
      "UploadSessionResult": {
        "type": "object",
        "required": [
          "mailbox_upload_session",
          "uploaded",
          "uploaded_count",
          "skipped",
          "skipped_count"
        ],
        "properties": {
          "mailbox_upload_session": {
            "$ref": "#/components/schemas/UploadSession"
          },
          "uploads": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UploadSessionUpload"
            },
            "description": "Create and uploads only: storage targets for the files that need bytes."
          },
          "uploaded": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UploadedFile"
            },
            "description": "Files saved by this request (at most 250)."
          },
          "uploaded_count": {
            "type": "integer",
            "minimum": 0
          },
          "uploaded_truncated": {
            "type": "boolean"
          },
          "created_count": {
            "type": "integer",
            "minimum": 0
          },
          "updated_count": {
            "type": "integer",
            "minimum": 0
          },
          "skipped": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FileUploadSkip"
            },
            "description": "Files left unchanged, for example identical content (DUPLICATE_FILE_VERSION)."
          },
          "skipped_count": {
            "type": "integer",
            "minimum": 0
          },
          "skipped_truncated": {
            "type": "boolean"
          },
          "finalize_pending": {
            "type": "boolean",
            "description": "Finalize only: true when more files remain. Call finalize again after Retry-After."
          },
          "remaining_files_count": {
            "type": "integer",
            "minimum": 0
          },
          "message": {
            "type": "string"
          }
        }
      },
      "ActionRequest": {
        "type": "object",
        "description": "Optional account selection and reason for an action without other input.",
        "properties": {
          "account_id": {
            "type": "string",
            "description": "Select another granted account for this request."
          },
          "reason": {
            "$ref": "#/components/schemas/ActionReason"
          }
        }
      }
    },
    "parameters": {
      "AccountId": {
        "name": "account_id",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string"
        },
        "description": "Select another granted account for this request. Omit to use the credential default. In JSON bodies, send account_id as a body field instead."
      },
      "Reason": {
        "name": "reason",
        "in": "query",
        "required": false,
        "schema": {
          "$ref": "#/components/schemas/ActionReason"
        }
      },
      "Limit": {
        "name": "limit",
        "in": "query",
        "required": false,
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 200,
          "default": 50
        }
      },
      "Cursor": {
        "name": "cursor",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string"
        },
        "description": "pagination.next_cursor from the previous page."
      },
      "MailboxId": {
        "name": "mailbox_id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "pattern": "^bkt_"
        }
      },
      "EmailId": {
        "name": "email_id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "pattern": "^eml_"
        }
      },
      "FileId": {
        "name": "file_id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "pattern": "^df_"
        }
      },
      "VersionId": {
        "name": "version_id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        }
      },
      "AttachmentId": {
        "name": "attachment_id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "pattern": "^df_"
        }
      },
      "AliasId": {
        "name": "alias_id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        }
      },
      "DomainId": {
        "name": "domain_id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        }
      },
      "AccountPathId": {
        "name": "account_id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "pattern": "^acct_"
        },
        "description": "Granted account to read."
      },
      "IncludeStorage": {
        "name": "include_storage",
        "in": "query",
        "required": false,
        "schema": {
          "type": "boolean",
          "default": false
        },
        "description": "Include backing file IDs for file-browser integrations."
      }
    },
    "responses": {
      "Error": {
        "description": "Request failed. See error.code. 429 and some 503 responses include Retry-After.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        }
      }
    }
  }
}
