{
  "openapi": "3.1.0",
  "info": {
    "title": "GhostParse API",
    "version": "1.2.0",
    "summary": "Free inbound email API: receive email as signed JSON webhooks, with extraction, an instant address and a CLI.",
    "description": "Transactional email only. Full guide: https://ghostparse.com/docs. Operated by WILDYE LIMITED.",
    "termsOfService": "https://ghostparse.com/terms",
    "contact": {
      "email": "hello@wildye.com"
    }
  },
  "servers": [
    {
      "url": "https://ghostparse.com"
    }
  ],
  "security": [
    {
      "apiKey": []
    }
  ],
  "tags": [
    {
      "name": "Emails",
      "description": "Send transactional email"
    },
    {
      "name": "Webhooks",
      "description": "Inbound email delivery to your endpoint"
    },
    {
      "name": "Domains",
      "description": "Provision domains and email addresses (API keys with the domains scope)"
    },
    {
      "name": "Inbound",
      "description": "Delivery log and signed reply addresses"
    },
    {
      "name": "Resellers",
      "description": "Sub-accounts for your own customers (reseller accounts; keys with the accounts scope)"
    },
    {
      "name": "Integrations",
      "description": "Make and n8n (REST hooks), Slack, Teams and Google Sheets destinations, routing rules (keys with the integrations scope)"
    },
    {
      "name": "BigCommerce",
      "description": "Order emails for BigCommerce stores, sent from your domain, connected with an API token. Needs the integrations permission."
    },
    {
      "name": "Platform",
      "description": "Public facts about this platform"
    },
    {
      "name": "Autopilot",
      "description": "The Autopilot for the WooCommerce plugin: what to do with a customer email, from facts the shop sends."
    },
    {
      "name": "Parsers",
      "description": "Turn emails into data: rules, AI, or your own JSON Schema"
    }
  ],
  "paths": {
    "/v1/emails": {
      "post": {
        "tags": [
          "Emails"
        ],
        "operationId": "sendEmail",
        "summary": "Send a transactional email",
        "description": "The `from` address must be on a verified domain and listed under that domain's Email addresses with Send on. At most 50 recipients across to, cc and bcc.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Repeat a request with the same key within 24 hours to get the original result instead of sending again.",
            "schema": {
              "type": "string",
              "maxLength": 255
            },
            "example": "order-1042-receipt"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendEmailRequest"
              },
              "example": {
                "from": {
                  "address": "orders@yourapp.com",
                  "name": "Your App"
                },
                "to": "customer@example.com",
                "subject": "Your receipt for order #1042",
                "html": "<p>Thanks for your order.</p>",
                "text": "Thanks for your order.",
                "headers": {
                  "X-Order-Id": "1042"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SentEmail"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "quota_exceeded or spend_cap: the plan's email allowance (shared by sent and received email) or the spending cap is used up",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Policy: domain_not_verified, sender_not_allowed, policy_violation, sending_paused (too many bounces, complaints or refused emails; receiving carries on), or insufficient_scope (key lacks the send scope)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "validation_error, recipients_suppressed (every recipient is on your suppression list), or content_refused (scanned before sending and refused as spam, phishing or malware; kind says which)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationError"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited (Too Many Requests, see Retry-After), daily_limit_reached, or ramp_limit (new accounts' daily limit for their first month)",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds to wait (per-minute limit only)"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "send_failed: the outbound mail server couldn't take the message. Safe to retry with the same Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/suppressions": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AccountHeader"
        }
      ],
      "get": {
        "tags": [
          "Emails"
        ],
        "operationId": "listSuppressions",
        "summary": "Addresses your email is no longer sent to",
        "description": "Hard bounces and spam complaints add addresses automatically; sending to them is skipped (see suppressed in the send response).",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000,
              "default": 500
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Suppressed addresses, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "suppressions": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Suppression"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Emails"
        ],
        "operationId": "addSuppression",
        "summary": "Stop sending to an address",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SuppressionCreate"
              },
              "example": {
                "address": "former-customer@example.com"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Suppressed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuppressionCreated"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "invalid_address",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/suppressions/{address}": {
      "parameters": [
        {
          "name": "address",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          },
          "description": "URL-encoded email address"
        },
        {
          "$ref": "#/components/parameters/AccountHeader"
        }
      ],
      "delete": {
        "tags": [
          "Emails"
        ],
        "operationId": "removeSuppression",
        "summary": "Send to an address again (only if you're sure it works)",
        "responses": {
          "204": {
            "description": "Removed"
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhooks/test": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "sendTestWebhook",
        "summary": "Send a test event to your webhook URL",
        "responses": {
          "200": {
            "description": "Delivered",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookTestResult"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Your endpoint didn't accept it",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookTestResult"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "target": {
                    "type": "string",
                    "enum": [
                      "main",
                      "backup"
                    ],
                    "default": "main"
                  }
                }
              }
            }
          }
        }
      },
      "parameters": [
        {
          "$ref": "#/components/parameters/AccountHeader"
        }
      ]
    },
    "/v1/webhook": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AccountHeader"
        }
      ],
      "get": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "getWebhookSettings",
        "summary": "Webhook settings",
        "description": "Needs the domains scope.",
        "responses": {
          "200": {
            "description": "Settings",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookSettings"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "updateWebhookSettings",
        "summary": "Change webhook settings",
        "description": "Needs the domains scope.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookSettingsUpdate"
              },
              "example": {
                "webhook_url": "https://yourapp.com/webhooks/email",
                "backup_webhook_url": "https://backup.yourapp.com/webhooks/email"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Settings",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookSettings"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "secret_incompatible: rotate the secret before switching to standard",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Invalid URL or setting",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhook/secret/rotate": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AccountHeader"
        }
      ],
      "post": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "rotateWebhookSecret",
        "summary": "New signing secret",
        "description": "The old secret keeps working for 24 hours (webhooks carry both signatures) unless immediate is true.",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "immediate": {
                    "type": "boolean",
                    "default": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The new secret (shown once)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SecretRotation"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhook/storage": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AccountHeader"
        }
      ],
      "get": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "getAttachmentStorage",
        "summary": "Attachment storage",
        "description": "Your bucket for attachments, or null. Needs the domains scope.",
        "responses": {
          "200": {
            "description": "The bucket",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "storage": {
                      "oneOf": [
                        {
                          "$ref": "#/components/schemas/AttachmentStorageSettings"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "setAttachmentStorage",
        "summary": "Set up attachment storage",
        "description": "Saves your S3-compatible bucket after a test: a small file (ghostparse-test.txt) is uploaded and its link opened. 422 storage_test_failed says what went wrong. Then set attachments_mode to storage. Needs the domains scope.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AttachmentStorage"
              },
              "example": {
                "provider": "r2",
                "endpoint": "https://0123456789abcdef.r2.cloudflarestorage.com",
                "region": "auto",
                "bucket": "yourcompany-email",
                "prefix": "email/",
                "access_key_id": "…",
                "secret_access_key": "…"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Saved and tested",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AttachmentStorageSettings"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "removeAttachmentStorage",
        "summary": "Remove attachment storage",
        "description": "If attachments_mode was storage, it becomes omit. Needs the domains scope.",
        "responses": {
          "200": {
            "description": "Removed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhook/storage/test": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AccountHeader"
        }
      ],
      "post": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "testAttachmentStorage",
        "summary": "Test attachment storage",
        "description": "Uploads ghostparse-test.txt and opens its link. Needs the domains scope.",
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "error": {
                      "type": "string"
                    },
                    "key": {
                      "type": "string"
                    },
                    "url": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/parsers": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AccountHeader"
        }
      ],
      "get": {
        "tags": [
          "Parsers"
        ],
        "operationId": "listParsers",
        "summary": "Parsers",
        "description": "Needs the domains scope.",
        "responses": {
          "200": {
            "description": "Parsers",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "parsers": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Parser"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Parsers"
        ],
        "operationId": "createParser",
        "summary": "Create a parser",
        "description": "Rules, AI, or your own JSON Schema (mode schema). AI and schema parsers need AI extraction turned on for the account (Parsers page). Needs the domains scope.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ParserInput"
              },
              "example": {
                "name": "Invoices",
                "mode": "schema",
                "schema": {
                  "type": "object",
                  "properties": {
                    "invoice_number": {
                      "type": "string"
                    },
                    "total": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "invoice_number",
                    "total"
                  ]
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Parser"
                }
              }
            }
          }
        }
      }
    },
    "/v1/parsers/{id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AccountHeader"
        },
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "tags": [
          "Parsers"
        ],
        "operationId": "getParser",
        "summary": "A parser",
        "description": "Needs the domains scope.",
        "responses": {
          "200": {
            "description": "The parser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Parser"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "Parsers"
        ],
        "operationId": "updateParser",
        "summary": "Change a parser",
        "description": "A changed schema becomes a new schema_version. Needs the domains scope.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ParserInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The parser",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Parser"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Parsers"
        ],
        "operationId": "deleteParser",
        "summary": "Delete a parser",
        "description": "Addresses and domains using it go back to no parser. Needs the domains scope.",
        "responses": {
          "204": {
            "description": "Deleted"
          }
        }
      }
    },
    "/v1/parsers/{id}/versions": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AccountHeader"
        },
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "tags": [
          "Parsers"
        ],
        "operationId": "listParserVersions",
        "summary": "Schema versions",
        "description": "Schema parsers: every version of the schema, newest first. Needs the domains scope.",
        "responses": {
          "200": {
            "description": "Versions",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "versions": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "version": {
                            "type": "integer"
                          },
                          "sha256": {
                            "type": "string"
                          },
                          "created_at": {
                            "type": "string"
                          },
                          "current": {
                            "type": "boolean"
                          },
                          "schema": {
                            "type": "object"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/parsers/{id}/test": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AccountHeader"
        },
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "post": {
        "tags": [
          "Parsers"
        ],
        "operationId": "testParser",
        "summary": "Try a parser",
        "description": "Runs the parser on an email's text and returns what data.extracted would be. AI and schema parsers use the AI allowance. Needs the domains scope.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "text"
                ],
                "properties": {
                  "subject": {
                    "type": "string"
                  },
                  "from": {
                    "type": "string"
                  },
                  "text": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "What would be delivered",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Extracted"
                }
              }
            }
          }
        }
      }
    },
    "/v1/inbox": {
      "get": {
        "tags": [
          "Inbound"
        ],
        "operationId": "getInbox",
        "summary": "Your instant inbox address",
        "description": "Every account gets an address on the platform's own domain that receives mail before any DNS setup. Any API key may call this.",
        "responses": {
          "200": {
            "description": "The address",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Inbox"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "parameters": [
        {
          "$ref": "#/components/parameters/AccountHeader"
        }
      ]
    },
    "/v1/parse": {
      "post": {
        "tags": [
          "Inbound"
        ],
        "operationId": "parseEmail",
        "summary": "Parse an old email (for imports)",
        "description": "Turns a raw message into the same JSON as an email.received event's data, with attachments inline (base64). For importing email from an old mailbox: nothing is stored or delivered, and it doesn't count towards your plan. Up to 600 requests a minute per key, and 100,000 messages a day per account.",
        "requestBody": {
          "required": true,
          "content": {
            "message/rfc822": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The parsed email",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "description": "As email.received's data"
                    },
                    "size_bytes": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Larger than the message size limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "Not a raw message",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "unparseable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "parse_limit: today's cap is reached",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/mail-oauth/providers": {
      "get": {
        "tags": [
          "Inbound"
        ],
        "operationId": "mailOAuthProviders",
        "summary": "Providers you can sign in with to import email",
        "description": "Google and Microsoft, when this platform has an OAuth client for them. For apps that import email over IMAP (like the webmail).",
        "responses": {
          "200": {
            "description": "The providers",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "providers": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "enum": [
                              "google",
                              "microsoft"
                            ]
                          },
                          "name": {
                            "type": "string"
                          },
                          "imap": {
                            "type": "object",
                            "properties": {
                              "host": {
                                "type": "string"
                              },
                              "port": {
                                "type": "integer"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/mail-oauth/start": {
      "post": {
        "tags": [
          "Inbound"
        ],
        "operationId": "mailOAuthStart",
        "summary": "Start a sign-in with Google or Microsoft",
        "description": "Returns the provider's sign-in address. Send the person there. Afterwards they come back to return_url with ?mail_oauth=<handle> (or ?mail_oauth_error=denied|failed|no_refresh). The handle works once, for 10 minutes.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "provider",
                  "return_url"
                ],
                "properties": {
                  "provider": {
                    "type": "string",
                    "enum": [
                      "google",
                      "microsoft"
                    ]
                  },
                  "return_url": {
                    "type": "string",
                    "format": "uri",
                    "description": "https (or http://localhost)"
                  }
                }
              },
              "example": {
                "provider": "google",
                "return_url": "https://example.com/mail/"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Where to send the person",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "mail_oauth_off: no client for that provider here",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "validation_error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/mail-oauth/claim": {
      "post": {
        "tags": [
          "Inbound"
        ],
        "operationId": "mailOAuthClaim",
        "summary": "Swap a sign-in's handle for its tokens",
        "description": "From your server, with the same account's key, once. We don't keep the tokens: store the refresh token yourself, encrypted.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "handle"
                ],
                "properties": {
                  "handle": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The tokens, for IMAP with XOAUTH2",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "provider": {
                      "type": "string"
                    },
                    "email": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "access_token": {
                      "type": "string"
                    },
                    "refresh_token": {
                      "type": "string"
                    },
                    "expires_in": {
                      "type": "integer"
                    },
                    "imap": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "not_found: expired, used, or another account's",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/mail-oauth/refresh": {
      "post": {
        "tags": [
          "Inbound"
        ],
        "operationId": "mailOAuthRefresh",
        "summary": "Refresh a sign-in's access token",
        "description": "Access tokens last about an hour. Microsoft may return a new refresh token: keep it in place of the old one.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "provider",
                  "refresh_token"
                ],
                "properties": {
                  "provider": {
                    "type": "string",
                    "enum": [
                      "google",
                      "microsoft"
                    ]
                  },
                  "refresh_token": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A fresh access token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "access_token": {
                      "type": "string"
                    },
                    "expires_in": {
                      "type": "integer"
                    },
                    "refresh_token": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "mail_oauth_revoked: sign in again",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "mail_oauth_unreachable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/samples": {
      "post": {
        "tags": [
          "Inbound"
        ],
        "operationId": "sendSample",
        "summary": "Send a sample email through the real pipeline",
        "description": "A realistic customer reply (quoted history, an attachment, header X-Email-Parser-Sample: true) is parsed, checked, run through the address's parser and delivered to your webhook or CLI listener, and logged. 10 per minute. Any API key may call this.",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "to": {
                    "type": "string",
                    "description": "One of your receiving addresses (default: your instant inbox address)"
                  }
                }
              },
              "example": {}
            }
          }
        },
        "responses": {
          "200": {
            "description": "What happened",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SampleResult"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "no_receiving_address or not_receiving",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "parameters": [
        {
          "$ref": "#/components/parameters/AccountHeader"
        }
      ]
    },
    "/v1/listen": {
      "get": {
        "tags": [
          "Inbound"
        ],
        "operationId": "listen",
        "summary": "Stream deliveries to the CLI (Server-Sent Events)",
        "description": "Used by `email-parser listen`. Events: `ready`, then `delivery` with `{delivery_id, mirror, headers, body}` (body base64): replay it as a POST to your local endpoint, then report the status to /v1/listen/ack unless `mirror` is true. Without a webhook URL on the account, the listener is where mail goes; with one, it gets copies.",
        "responses": {
          "200": {
            "description": "An open event stream",
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "parameters": [
        {
          "$ref": "#/components/parameters/AccountHeader"
        }
      ]
    },
    "/v1/listen/ack": {
      "post": {
        "tags": [
          "Inbound"
        ],
        "operationId": "listenAck",
        "summary": "Report a local endpoint's response for a streamed delivery",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "delivery_id",
                  "status"
                ],
                "properties": {
                  "delivery_id": {
                    "type": "string"
                  },
                  "status": {
                    "type": "integer",
                    "description": "The local endpoint's HTTP status; 0 if it couldn't be reached"
                  },
                  "error": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "delivery_id": "6f1c…",
                "status": 200
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "acknowledged is false for unknown or already-timed-out deliveries",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "acknowledged": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "parameters": [
        {
          "$ref": "#/components/parameters/AccountHeader"
        }
      ]
    },
    "/v1/deliveries": {
      "get": {
        "tags": [
          "Inbound"
        ],
        "operationId": "listDeliveries",
        "summary": "Recent inbound deliveries (newest first)",
        "description": "Kept for 90 days. Any API key may call this.",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "delivered",
                "deferred",
                "failed",
                "rejected",
                "dropped"
              ]
            }
          },
          {
            "name": "domain_id",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "message_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Exact Message-ID, with the angle brackets"
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "before",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "description": "next_before from the previous page"
          }
        ],
        "responses": {
          "200": {
            "description": "A page of deliveries",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "deliveries": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Delivery"
                      }
                    },
                    "next_before": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "invalid_status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "parameters": [
        {
          "$ref": "#/components/parameters/AccountHeader"
        }
      ]
    },
    "/v1/usage": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AccountHeader"
        }
      ],
      "get": {
        "tags": [
          "Inbound"
        ],
        "operationId": "getUsage",
        "summary": "This billing period's usage and plan",
        "description": "Any API key may call this. Inbound emails over a Free plan's allowance (plus 10%) are deferred; paid plans bill them.",
        "responses": {
          "200": {
            "description": "Usage",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Usage"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/reply-addresses": {
      "post": {
        "tags": [
          "Inbound"
        ],
        "operationId": "createReplyAddress",
        "summary": "Make a signed reply address",
        "description": "Use it as the Reply-To of a notification. Replies arrive with recipients[].tag set and tag_verified true; nobody else can make valid ones. Any API key may call this.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReplyAddressRequest"
              },
              "example": {
                "address": "support@acme.com",
                "tag": "t42"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The address",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReplyAddress"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "not_found: the domain isn't on your account",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "invalid_address, invalid_tag, address_not_receiving or validation_error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "parameters": [
        {
          "$ref": "#/components/parameters/AccountHeader"
        }
      ]
    },
    "/v1/domains": {
      "get": {
        "tags": [
          "Domains"
        ],
        "operationId": "listDomains",
        "summary": "List domains",
        "parameters": [
          {
            "name": "reference",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "name",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Domains",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "domains": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Domain"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the domains scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Domains"
        ],
        "operationId": "createDomain",
        "summary": "Add a domain (optionally with addresses and settings)",
        "description": "Created atomically: if any part is invalid, nothing is created. Returns the DNS records to publish.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DomainCreate"
              },
              "example": {
                "name": "customer-shop.com",
                "reference": "hosting-customer-1001",
                "inbound_enabled": true,
                "webhook_url": "https://customer-shop.com/webhooks/email",
                "addresses": [
                  {
                    "local_part": "info",
                    "can_send": true,
                    "can_receive": true
                  },
                  {
                    "local_part": "noreply",
                    "can_send": true,
                    "can_receive": false
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Domain"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the domains scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "domain_exists",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "validation_error, invalid_domain, invalid_address, wrong_domain, duplicate_address, no_permissions, invalid_reference, invalid_webhook_url, too_many_domains, too_many_addresses",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "parameters": [
        {
          "$ref": "#/components/parameters/AccountHeader"
        }
      ]
    },
    "/v1/domains/{id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AccountHeader"
        }
      ],
      "get": {
        "tags": [
          "Domains"
        ],
        "operationId": "getDomain",
        "summary": "Get a domain",
        "responses": {
          "200": {
            "description": "Domain",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Domain"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the domains scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Domains"
        ],
        "operationId": "updateDomain",
        "summary": "Update inbound, webhook URL or reference",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DomainUpdate"
              },
              "example": {
                "inbound_enabled": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Domain"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the domains scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "validation_error, invalid_reference, invalid_webhook_url",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Domains"
        ],
        "operationId": "deleteDomain",
        "summary": "Remove a domain and its addresses",
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the domains scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/domains/{id}/verify": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AccountHeader"
        }
      ],
      "post": {
        "tags": [
          "Domains"
        ],
        "operationId": "verifyDomain",
        "summary": "Check the domain's DNS records now",
        "description": "Limited to 30 requests per minute per key. DNS can take minutes to propagate: retry with backoff.",
        "responses": {
          "200": {
            "description": "Check results",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VerifyResult"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the domains scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/domains/{id}/dns-plan": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AccountHeader"
        }
      ],
      "post": {
        "tags": [
          "Domains"
        ],
        "operationId": "planDomainDns",
        "summary": "Plan the changes to a DNS zone",
        "description": "For control panels that edit the zone themselves. Send the TXT and MX records the zone has now, and get back what to create, update or delete so it has this domain's records. An existing SPF record gets our include added (a domain may only have one). An existing DMARC record keeps its policy and gets our report address. Existing MX records are left alone unless replace_mx is true. Changes nothing.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "existing"
                ],
                "properties": {
                  "existing": {
                    "type": "array",
                    "maxItems": 500,
                    "items": {
                      "type": "object",
                      "required": [
                        "id",
                        "type",
                        "name",
                        "content"
                      ],
                      "properties": {
                        "id": {
                          "type": [
                            "string",
                            "integer"
                          ],
                          "description": "Your id for the record (a cPanel zone line index), returned as record_id"
                        },
                        "type": {
                          "type": "string",
                          "enum": [
                            "TXT",
                            "MX"
                          ]
                        },
                        "name": {
                          "type": "string",
                          "description": "Full name, with or without the final dot"
                        },
                        "content": {
                          "type": "string",
                          "description": "TXT: the value, its strings joined. MX: the mail server."
                        },
                        "priority": {
                          "type": "integer"
                        }
                      }
                    }
                  },
                  "replace_mx": {
                    "type": "boolean",
                    "description": "Replace the domain's MX records with ours (moves its mail here)"
                  },
                  "provider": {
                    "type": "string",
                    "description": "Your panel's name, used in the reasons",
                    "example": "cPanel"
                  }
                }
              },
              "example": {
                "existing": [
                  {
                    "id": 5,
                    "type": "TXT",
                    "name": "bobsbakery.example",
                    "content": "v=spf1 +a +mx ~all"
                  },
                  {
                    "id": 4,
                    "type": "MX",
                    "name": "bobsbakery.example",
                    "content": "bobsbakery.example",
                    "priority": 0
                  }
                ],
                "provider": "cPanel"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The changes, in order",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "domain": {
                      "type": "string"
                    },
                    "changes": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "enum": [
                              "spf",
                              "dkim",
                              "dmarc",
                              "mx"
                            ]
                          },
                          "action": {
                            "type": "string",
                            "enum": [
                              "create",
                              "update",
                              "delete",
                              "skip"
                            ]
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "TXT",
                              "MX"
                            ]
                          },
                          "name": {
                            "type": "string"
                          },
                          "content": {
                            "type": "string"
                          },
                          "priority": {
                            "type": "integer"
                          },
                          "current": {
                            "type": "string"
                          },
                          "record_id": {
                            "type": "string"
                          },
                          "reason": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the domains scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "validation_error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/domains/{id}/addresses": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AccountHeader"
        }
      ],
      "post": {
        "tags": [
          "Domains"
        ],
        "operationId": "addAddress",
        "summary": "Add an email address",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AddressCreate"
              },
              "example": {
                "local_part": "billing",
                "can_send": true,
                "can_receive": false
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainAddress"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the domains scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "address_exists",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "validation_error, invalid_address, wrong_domain, no_permissions, too_many_addresses",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/domains/{id}/addresses/{addressId}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AccountHeader"
        }
      ],
      "patch": {
        "tags": [
          "Domains"
        ],
        "operationId": "updateAddress",
        "summary": "Change an address's permissions, webhook or signed-tag requirement",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AddressUpdate"
              },
              "example": {
                "can_receive": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainAddress"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the domains scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "no_permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Domains"
        ],
        "operationId": "removeAddress",
        "summary": "Remove an email address",
        "responses": {
          "204": {
            "description": "Removed"
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the domains scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/domains/{id}/sender-rules": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AccountHeader"
        }
      ],
      "get": {
        "tags": [
          "Domains"
        ],
        "operationId": "listSenderRules",
        "summary": "List a domain's sender rules",
        "responses": {
          "200": {
            "description": "Rules",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "sender_rules": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/SenderRule"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the domains scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Domains"
        ],
        "operationId": "addSenderRule",
        "summary": "Block a sender, or allow only listed senders",
        "description": "Allow-listed senders must pass authentication (DMARC, or DKIM/SPF for their domain when it has no DMARC record).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SenderRuleCreate"
              },
              "example": {
                "action": "block",
                "pattern": "spammer.example"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Added",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SenderRule"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the domains scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "rule_exists",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "invalid_pattern, too_many_rules or validation_error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/domains/{id}/sender-rules/{ruleId}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AccountHeader"
        }
      ],
      "delete": {
        "tags": [
          "Domains"
        ],
        "operationId": "removeSenderRule",
        "summary": "Remove a sender rule",
        "responses": {
          "204": {
            "description": "Removed"
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the domains scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/accounts": {
      "get": {
        "tags": [
          "Resellers"
        ],
        "operationId": "listSubaccounts",
        "summary": "List your sub-accounts",
        "parameters": [
          {
            "name": "reference",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sub-accounts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "accounts": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Subaccount"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "not_reseller or insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Resellers"
        ],
        "operationId": "createSubaccount",
        "summary": "Create a sub-account",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubaccountCreate"
              },
              "example": {
                "name": "Bob's Bakery",
                "reference": "cust-77",
                "webhook_url": "https://bobsbakery.example/webhooks/email"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubaccountCreated"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "not_reseller or insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input, or too_many_accounts",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/accounts/{id}": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "tags": [
          "Resellers"
        ],
        "operationId": "getSubaccount",
        "summary": "A sub-account",
        "responses": {
          "200": {
            "description": "The sub-account",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Subaccount"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "account_not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Resellers"
        ],
        "operationId": "updateSubaccount",
        "summary": "Rename, re-reference, suspend, change package or pause sending",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubaccountUpdate"
              },
              "example": {
                "suspended": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Subaccount"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "account_not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Resellers"
        ],
        "operationId": "deleteSubaccount",
        "summary": "Delete a sub-account and everything in it",
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "account_not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/accounts/{id}/invitations": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "post": {
        "tags": [
          "Resellers"
        ],
        "operationId": "inviteToSubaccount",
        "summary": "Invite someone to a sub-account's dashboard",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvitationCreate"
              },
              "example": {
                "email": "owner@bobsbakery.example",
                "role": "owner"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Invitation sent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Invitation"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "account_not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "email_taken",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/accounts/{id}/api-keys": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "post": {
        "tags": [
          "Resellers"
        ],
        "operationId": "createSubaccountApiKey",
        "summary": "Create an API key for a sub-account",
        "description": "For an app you install for your customer, like the webmail on their hosting: the key belongs to the sub-account, so it can't reach your account or your other customers. It's shown once. Up to 10 active keys per account.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name",
                  "scopes"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 100
                  },
                  "scopes": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "type": "string",
                      "enum": [
                        "send",
                        "domains",
                        "integrations"
                      ]
                    }
                  }
                }
              },
              "example": {
                "name": "Webmail at bobsbakery.example/mail",
                "scopes": [
                  "send",
                  "domains"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The key, shown once",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "prefix": {
                      "type": "string"
                    },
                    "scopes": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "key": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "account_not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "invalid_scopes, too_many_keys",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/accounts/{id}/api-keys/{keyId}": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        },
        {
          "name": "keyId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "delete": {
        "tags": [
          "Resellers"
        ],
        "operationId": "revokeSubaccountApiKey",
        "summary": "Revoke a sub-account's API key",
        "responses": {
          "204": {
            "description": "Revoked"
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "account_not_found or not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/accounts/{id}/webhook-secret": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "tags": [
          "Resellers"
        ],
        "operationId": "getSubaccountWebhookSecret",
        "summary": "Read a sub-account's webhook signing secret",
        "description": "The secret its webhooks are signed with (also returned once when the sub-account is created), for an app you set up for your customer that checks the signatures.",
        "responses": {
          "200": {
            "description": "The secret",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "webhook_secret": {
                      "type": "string",
                      "example": "whsec_..."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "account_not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/accounts/usage": {
      "get": {
        "tags": [
          "Resellers"
        ],
        "operationId": "listCustomerUsage",
        "summary": "Usage per customer, for billing",
        "description": "Each customer's month: mailboxes and domains now, emails received and sent, over and held back by their package, bounces and complaints, with totals and your own plan's figures. Add `format=csv` for a CSV file (one row per customer).",
        "parameters": [
          {
            "name": "month",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^\\d{4}-(0[1-9]|1[0-2])$"
            },
            "description": "A calendar month, like 2026-11. Default: this month."
          },
          {
            "name": "format",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "json",
                "csv"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The report",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UsageReport"
                }
              },
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "invalid_month",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/accounts/{id}/usage": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "tags": [
          "Resellers"
        ],
        "operationId": "getCustomerUsage",
        "summary": "One customer's usage",
        "parameters": [
          {
            "name": "month",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^\\d{4}-(0[1-9]|1[0-2])$"
            },
            "description": "A calendar month, like 2026-11. Default: this month."
          }
        ],
        "responses": {
          "200": {
            "description": "The customer's month",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerUsage"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "account_not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/packages": {
      "get": {
        "tags": [
          "Resellers"
        ],
        "operationId": "listPackages",
        "summary": "Customer packages",
        "responses": {
          "200": {
            "description": "Your packages",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "packages": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Package"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Resellers"
        ],
        "operationId": "createPackage",
        "summary": "Create a customer package",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PackageCreate"
              },
              "example": {
                "name": "Email Basic",
                "max_mailboxes": 3,
                "max_domains": 1,
                "monthly_emails": 2000,
                "over_limit": "block"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The package",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Package"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "package_exists",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "validation_error, too_many_packages",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/packages/{id}": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "patch": {
        "tags": [
          "Resellers"
        ],
        "operationId": "updatePackage",
        "summary": "Change a package (its customers get the new limits)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PackageUpdate"
              },
              "example": {
                "monthly_emails": 5000
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The package",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Package"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "package_not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "package_exists",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Resellers"
        ],
        "operationId": "deletePackage",
        "summary": "Delete a package (its customers keep what they have)",
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "package_not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/me": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AccountHeader"
        }
      ],
      "get": {
        "tags": [
          "Integrations"
        ],
        "operationId": "getMe",
        "summary": "The account and API key making the request",
        "description": "Any API key may call this. Automation platforms use it to test a connection.",
        "responses": {
          "200": {
            "description": "Account",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Me"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/api-keys/current": {
      "delete": {
        "tags": [
          "Integrations"
        ],
        "operationId": "revokeCurrentKey",
        "summary": "Revoke the API key making the request",
        "description": "For an app giving back a key it no longer needs, such as the webmail's installer after a failed install.",
        "responses": {
          "204": {
            "description": "Revoked"
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webmail/setup-code/check": {
      "post": {
        "tags": [
          "Integrations"
        ],
        "operationId": "checkWebmailSetupCode",
        "security": [],
        "summary": "Check a webmail setup code without using it",
        "description": "For the webmail's SSH installer (/install/webmail.sh). The dashboard makes a setup code for a domain (good once, for an hour). No API key: the code is the credential.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "code"
                ],
                "properties": {
                  "code": {
                    "type": "string",
                    "description": "The setup code from the dashboard (wms_…)"
                  },
                  "url": {
                    "type": "string",
                    "description": "Where the webmail will be (names its key)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "What the code is for",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "domain": {
                      "type": "string"
                    },
                    "admin_email": {
                      "type": "string"
                    },
                    "app_name": {
                      "type": "string"
                    },
                    "expires_at": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "invalid_setup_code: expired, used or unknown",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "validation_error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webmail/setup-code/redeem": {
      "post": {
        "tags": [
          "Integrations"
        ],
        "operationId": "redeemWebmailSetupCode",
        "security": [],
        "summary": "Swap a webmail setup code for the webmail's API key",
        "description": "Once. Makes an API key with the send and domains permissions, and returns it with the signing secret and the domain's addresses (not patterns), for the webmail's settings.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "code"
                ],
                "properties": {
                  "code": {
                    "type": "string",
                    "description": "The setup code from the dashboard (wms_…)"
                  },
                  "url": {
                    "type": "string",
                    "description": "Where the webmail will be (names its key)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The webmail's settings",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "api_key": {
                      "type": "string"
                    },
                    "api_key_prefix": {
                      "type": "string"
                    },
                    "webhook_secret": {
                      "type": "string"
                    },
                    "domain": {
                      "type": "string"
                    },
                    "admin_email": {
                      "type": "string"
                    },
                    "app_name": {
                      "type": "string"
                    },
                    "mailboxes": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "invalid_setup_code: expired, used or unknown",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "validation_error, or too_many_keys",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/hooks": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AccountHeader"
        }
      ],
      "get": {
        "tags": [
          "Integrations"
        ],
        "operationId": "listHooks",
        "summary": "List REST hook subscriptions",
        "responses": {
          "200": {
            "description": "Hooks",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "hooks": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Hook"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the integrations permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Integrations"
        ],
        "operationId": "subscribeHook",
        "summary": "Subscribe a URL to email.received",
        "description": "Each email is POSTed to target_url as a signed JSON event. Answer 410 to unsubscribe.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HookCreate"
              },
              "example": {
                "target_url": "https://hook.eu1.make.com/abc123def456",
                "source": "make",
                "filter": {
                  "address": "invoices@*"
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Subscribed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HookCreated"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the integrations permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "invalid_destination or validation_error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/hooks/sample": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AccountHeader"
        }
      ],
      "get": {
        "tags": [
          "Integrations"
        ],
        "operationId": "sampleHookEvent",
        "summary": "A sample email.received event, in an array",
        "responses": {
          "200": {
            "description": "Sample events",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/WebhookEvent"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the integrations permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/hooks/{id}": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        },
        {
          "$ref": "#/components/parameters/AccountHeader"
        }
      ],
      "delete": {
        "tags": [
          "Integrations"
        ],
        "operationId": "unsubscribeHook",
        "summary": "Unsubscribe",
        "responses": {
          "204": {
            "description": "Unsubscribed"
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the integrations permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "hook_not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/destinations": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AccountHeader"
        }
      ],
      "get": {
        "tags": [
          "Integrations"
        ],
        "operationId": "listDestinations",
        "summary": "List destinations",
        "responses": {
          "200": {
            "description": "Destinations",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "destinations": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Destination"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the integrations permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Integrations"
        ],
        "operationId": "createDestination",
        "summary": "Add a destination (Slack, Teams, Google Sheets or a webhook)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DestinationCreate"
              },
              "example": {
                "type": "slack",
                "name": "#support",
                "url": "https://hooks.slack.com/services/T000/B000/XXXX",
                "all_mail": true,
                "filter": {
                  "address": "support@*"
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Destination"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the integrations permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "invalid_destination, too_many_destinations or validation_error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/destinations/{id}": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        },
        {
          "$ref": "#/components/parameters/AccountHeader"
        }
      ],
      "get": {
        "tags": [
          "Integrations"
        ],
        "operationId": "getDestination",
        "summary": "A destination",
        "responses": {
          "200": {
            "description": "Destination",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Destination"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the integrations permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "destination_not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Integrations"
        ],
        "operationId": "updateDestination",
        "summary": "Change a destination",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DestinationUpdate"
              },
              "example": {
                "enabled": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Destination"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the integrations permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "destination_not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "invalid_destination",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Integrations"
        ],
        "operationId": "deleteDestination",
        "summary": "Delete a destination (routing rules stop sending to it)",
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the integrations permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "destination_not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/destinations/{id}/test": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        },
        {
          "$ref": "#/components/parameters/AccountHeader"
        }
      ],
      "post": {
        "tags": [
          "Integrations"
        ],
        "operationId": "testDestination",
        "summary": "Send the sample email to a destination",
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "delivered": {
                      "type": "boolean"
                    },
                    "status": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "delivered"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the integrations permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "destination_not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/rules": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AccountHeader"
        }
      ],
      "get": {
        "tags": [
          "Integrations"
        ],
        "operationId": "listRules",
        "summary": "List routing rules, in order",
        "responses": {
          "200": {
            "description": "Rules",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "rules": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/RoutingRule"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the integrations permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Integrations"
        ],
        "operationId": "createRule",
        "summary": "Add a routing rule",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RoutingRuleCreate"
              },
              "example": {
                "name": "Invoices to the finance sheet",
                "conditions": [
                  {
                    "field": "from_domain",
                    "op": "ends_with",
                    "value": "stripe.com"
                  },
                  {
                    "field": "subject",
                    "op": "contains",
                    "value": "invoice"
                  }
                ],
                "action": "route",
                "targets": [
                  "webhook"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RoutingRule"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the integrations permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "invalid_rule, too_many_routing_rules or validation_error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/rules/test": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AccountHeader"
        }
      ],
      "post": {
        "tags": [
          "Integrations"
        ],
        "operationId": "testRules",
        "summary": "Where would this email go? Nothing is sent.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RuleTest"
              },
              "example": {
                "subject": "Your invoice",
                "from": "billing@stripe.com",
                "to": "accounts@yourapp.com"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Decision",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RoutingDecision"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the integrations permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/rules/{id}": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        },
        {
          "$ref": "#/components/parameters/AccountHeader"
        }
      ],
      "get": {
        "tags": [
          "Integrations"
        ],
        "operationId": "getRule",
        "summary": "A routing rule",
        "responses": {
          "200": {
            "description": "Rule",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RoutingRule"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the integrations permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "rule_not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Integrations"
        ],
        "operationId": "updateRule",
        "summary": "Change a rule, or move it (position)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RoutingRuleUpdate"
              },
              "example": {
                "position": 1
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RoutingRule"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the integrations permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "rule_not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "invalid_rule",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Integrations"
        ],
        "operationId": "deleteRule",
        "summary": "Delete a rule",
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the integrations permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "rule_not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/bigcommerce/stores": {
      "parameters": [
        {
          "$ref": "#/components/parameters/AccountHeader"
        }
      ],
      "get": {
        "tags": [
          "BigCommerce"
        ],
        "operationId": "listBigCommerceStores",
        "summary": "Connected BigCommerce stores",
        "responses": {
          "200": {
            "description": "Stores",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "stores": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/BigCommerceStore"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the integrations permission; outbound_disabled: this platform doesn't send email",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "BigCommerce"
        ],
        "operationId": "connectBigCommerceStore",
        "summary": "Connect a BigCommerce store",
        "description": "Checks the token, registers the store's webhooks (pointing at webhook_url, with a secret header of ours) and saves the store. Nothing to set up in BigCommerce by hand.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BigCommerceStoreCreate"
              },
              "example": {
                "store": "https://api.bigcommerce.com/stores/abc123/v3/",
                "api_token": "abcd1234…",
                "from_address": "orders@yourshop.com",
                "reply_to": "support@yourshop.com"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Connected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BigCommerceStoreDetail"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the integrations permission; outbound_disabled: this platform doesn't send email",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "store_exists",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "invalid_store, invalid_api_token, or bigcommerce_error: BigCommerce refused the token (message says why)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/bigcommerce/stores/{id}": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        },
        {
          "$ref": "#/components/parameters/AccountHeader"
        }
      ],
      "get": {
        "tags": [
          "BigCommerce"
        ],
        "operationId": "getBigCommerceStore",
        "summary": "A store and its templates",
        "responses": {
          "200": {
            "description": "Store",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BigCommerceStoreDetail"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the integrations permission; outbound_disabled: this platform doesn't send email",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "store_not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "BigCommerce"
        ],
        "operationId": "updateBigCommerceStore",
        "summary": "Change a store's settings",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BigCommerceStoreUpdate"
              },
              "example": {
                "inbox_address": "support@yourshop.com",
                "forward_to": "you@yourcompany.com"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BigCommerceStoreDetail"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the integrations permission; outbound_disabled: this platform doesn't send email",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "store_not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "store_exists",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "invalid_shop_domain, invalid_logo_url, invalid_color, validation_error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "BigCommerce"
        ],
        "operationId": "disconnectBigCommerceStore",
        "summary": "Disconnect a store",
        "responses": {
          "204": {
            "description": "Disconnected: its emails stop and its templates are deleted"
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the integrations permission; outbound_disabled: this platform doesn't send email",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "store_not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "description": "Removes our webhooks from the store and deletes its templates here. Delete the API account in BigCommerce too."
      }
    },
    "/v1/bigcommerce/stores/{id}/rotate-url": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        },
        {
          "$ref": "#/components/parameters/AccountHeader"
        }
      ],
      "post": {
        "tags": [
          "BigCommerce"
        ],
        "operationId": "rotateBigCommerceWebhookUrl",
        "summary": "Make a new webhook URL",
        "description": "A new webhook URL: the store's webhooks are moved to it (with a new secret) at once.",
        "responses": {
          "200": {
            "description": "Store with its new webhook_url",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BigCommerceStoreDetail"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the integrations permission; outbound_disabled: this platform doesn't send email",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "store_not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/bigcommerce/stores/{id}/events": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        },
        {
          "$ref": "#/components/parameters/AccountHeader"
        }
      ],
      "get": {
        "tags": [
          "BigCommerce"
        ],
        "operationId": "listBigCommerceEvents",
        "summary": "Recent order events",
        "description": "The last 50 events, newest first, kept 30 days. Only the order number and result are stored.",
        "responses": {
          "200": {
            "description": "Events",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "events": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/BigCommerceEvent"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the integrations permission; outbound_disabled: this platform doesn't send email",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "store_not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/bigcommerce/stores/{id}/templates": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        },
        {
          "$ref": "#/components/parameters/AccountHeader"
        }
      ],
      "get": {
        "tags": [
          "BigCommerce"
        ],
        "operationId": "listBigCommerceTemplates",
        "summary": "The store's three email templates",
        "responses": {
          "200": {
            "description": "Templates",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "templates": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/BigCommerceTemplate"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the integrations permission; outbound_disabled: this platform doesn't send email",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "store_not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/bigcommerce/stores/{id}/templates/{template}": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        },
        {
          "$ref": "#/components/parameters/AccountHeader"
        },
        {
          "name": "template",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "enum": [
              "order_confirmation",
              "shipping_confirmation",
              "order_cancelled",
              "refund_confirmation"
            ]
          }
        }
      ],
      "put": {
        "tags": [
          "BigCommerce"
        ],
        "operationId": "updateBigCommerceTemplate",
        "summary": "Change a template",
        "description": "null for subject or html goes back to the default.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StoreTemplateUpdate"
              },
              "example": {
                "enabled": true,
                "subject": "Thanks for your order {{order.name}}"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Template",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BigCommerceTemplate"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the integrations permission; outbound_disabled: this platform doesn't send email",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "store_not_found, template_not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "invalid_template, validation_error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/bigcommerce/stores/{id}/templates/{template}/preview": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        },
        {
          "$ref": "#/components/parameters/AccountHeader"
        },
        {
          "name": "template",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "enum": [
              "order_confirmation",
              "shipping_confirmation",
              "order_cancelled",
              "refund_confirmation"
            ]
          }
        }
      ],
      "post": {
        "tags": [
          "BigCommerce"
        ],
        "operationId": "previewBigCommerceTemplate",
        "summary": "Render a template with a sample order",
        "description": "Renders subject and html if given, else the saved template.",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StorePreviewRequest"
              },
              "example": {
                "subject": "Order {{order.name}} confirmed"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Preview",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StorePreview"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the integrations permission; outbound_disabled: this platform doesn't send email",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "store_not_found, template_not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/bigcommerce/stores/{id}/templates/{template}/test": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        },
        {
          "$ref": "#/components/parameters/AccountHeader"
        },
        {
          "name": "template",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "enum": [
              "order_confirmation",
              "shipping_confirmation",
              "order_cancelled",
              "refund_confirmation"
            ]
          }
        }
      ],
      "post": {
        "tags": [
          "BigCommerce"
        ],
        "operationId": "testBigCommerceTemplate",
        "summary": "Send the saved template with a sample order",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "to"
                ],
                "properties": {
                  "to": {
                    "type": "string",
                    "format": "email"
                  }
                }
              },
              "example": {
                "to": "you@yourshop.com"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SentEmail"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "quota_exceeded, spend_cap",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the integrations permission; outbound_disabled: this platform doesn't send email",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "store_not_found, template_not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "recipients_suppressed, validation_error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "send_failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/meta": {
      "get": {
        "tags": [
          "Platform"
        ],
        "operationId": "getMeta",
        "summary": "Webhook source IPs and data region",
        "description": "Public: no API key needed.",
        "security": [],
        "responses": {
          "200": {
            "description": "Platform facts",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Meta"
                }
              }
            }
          }
        }
      }
    },
    "/v1/dmarc": {
      "get": {
        "tags": [
          "Domains"
        ],
        "operationId": "listDmarc",
        "summary": "DMARC reports: every domain at a glance",
        "responses": {
          "200": {
            "description": "Domains with their report address and last 30 days",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DmarcOverview"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the domains scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/domains/{id}/dmarc": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "tags": [
          "Domains"
        ],
        "operationId": "getDomainDmarc",
        "summary": "DMARC reports for one domain",
        "parameters": [
          {
            "name": "days",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 90,
              "default": 30
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Totals, sending sources and reports",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DmarcSummary"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the domains scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/dmarc/reports/{id}": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "tags": [
          "Domains"
        ],
        "operationId": "getDmarcReport",
        "summary": "One DMARC report with every row",
        "responses": {
          "200": {
            "description": "The report",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DmarcReportDetail"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key needs the domains scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/autopilot/decide": {
      "post": {
        "tags": [
          "Autopilot"
        ],
        "operationId": "decideAutopilot",
        "summary": "Decide how to answer a customer email",
        "description": "Used by the WordPress plugin's Autopilot for WooCommerce. Send one customer email and, when the sender is shown to be the order's customer, the order's facts as plain text. The AI sorts the email and writes the reply from those facts only. Nothing is kept. Needs AI turned on for the account and an API key with the send permission; each call uses one AI extraction.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AutopilotDecideRequest"
              },
              "example": {
                "shop": {
                  "name": "Fernhill Roasters",
                  "url": "https://fernhill.example/"
                },
                "email": {
                  "from": "maria@example.com",
                  "name": "Maria",
                  "subject": "Re: Your order #1047",
                  "text": "Has it shipped yet?"
                },
                "order": {
                  "facts": "Order #1047, placed 8 October 2026\nShipment sent 10 October 2026, with Royal Mail, tracking number TT482910374GB"
                },
                "settings": {
                  "sign_off": "Happy brewing,\nFernhill",
                  "shop_info": "Delivery: UK 1-2 working days."
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The decision",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AutopilotDecision"
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope: the key lacks the send permission",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "ai_unavailable, ai_disabled, autopilot_failed (the AI couldn't be used, e.g. the plan's AI allowance is used up) or validation_error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/sandbox/events": {
      "post": {
        "tags": [
          "Inbound"
        ],
        "summary": "Build a sandbox webhook event",
        "description": "Returns a webhook event exactly as your endpoint would get it, without receiving, delivering, storing or counting anything. Its data has `sandbox: true`. Send a raw email (Content-Type: message/rfc822) to build email.received from it; otherwise the sample email is used. `email-parser simulate` signs the result and POSTs it to a local URL. Any API key.",
        "parameters": [
          {
            "name": "type",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "email.received",
                "email.bounced",
                "email.complained"
              ],
              "default": "email.received"
            }
          },
          {
            "name": "to",
            "in": "query",
            "description": "The recipient address in the event",
            "schema": {
              "type": "string",
              "format": "email"
            }
          },
          {
            "name": "parser",
            "in": "query",
            "description": "A rules parser's id: email.received then carries what it extracts in `extracted`. AI parsers aren't run here (422 ai_parser).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "message/rfc822": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            },
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string"
                  },
                  "to": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The event",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "422": {
            "description": "Unknown event type, or a raw email for a type other than email.received"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    }
  },
  "webhooks": {
    "emailReceived": {
      "post": {
        "summary": "An inbound email was received (sent to your webhook URL)",
        "description": "Verify the signature before trusting the body (our SDKs, or any Standard Webhooks library, do this). Standard Webhooks (the default): HMAC-SHA256 over \"<webhook-id>.<webhook-timestamp>.<raw body>\" keyed with the base64-decoded part of your whsec_ secret, sent as `webhook-signature: v1,<base64>` (space-separated when two secrets are valid during a rotation). Accounts on the original format get `webhook-signature: t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\" keyed with the whole secret>`. Respond 2xx within 10 s. De-duplicate on data.message_id. If you set a backup webhook URL, it receives the same signed request when this endpoint is unreachable or returns 5xx.",
        "security": [],
        "parameters": [
          {
            "name": "webhook-id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Equals the event id; the same on every retry."
          },
          {
            "name": "webhook-timestamp",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "1790932497",
            "description": "Unix seconds when this attempt was signed"
          },
          {
            "name": "webhook-signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "v1,unqzZ64edPDGcZVcnf3zGnmbc6EQ6DznDhh3jhZXPIE="
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx acknowledges the event"
          },
          "400": {
            "description": "Signature verification failed. Other 4xx (except 408/429) bounce the email; 5xx/timeouts are retried."
          }
        },
        "operationId": "emailReceived"
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "API key from the dashboard (ek_live_…). Sending needs the send scope; /v1/domains and /v1/webhook need the domains scope; /v1/accounts (resellers) needs the accounts scope."
      }
    },
    "schemas": {
      "Address": {
        "oneOf": [
          {
            "type": "string",
            "format": "email"
          },
          {
            "type": "object",
            "required": [
              "address"
            ],
            "additionalProperties": false,
            "properties": {
              "address": {
                "type": "string",
                "format": "email"
              },
              "name": {
                "type": "string",
                "maxLength": 200
              }
            }
          }
        ]
      },
      "AddressList": {
        "oneOf": [
          {
            "$ref": "#/components/schemas/Address"
          },
          {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Address"
            }
          }
        ]
      },
      "Attachment": {
        "type": "object",
        "required": [
          "filename",
          "content"
        ],
        "additionalProperties": false,
        "properties": {
          "filename": {
            "type": "string",
            "minLength": 1
          },
          "content": {
            "type": "string",
            "contentEncoding": "base64",
            "description": "File bytes, base64-encoded"
          },
          "content_type": {
            "type": "string",
            "example": "application/pdf"
          },
          "content_id": {
            "type": "string",
            "description": "Makes it an inline image, referenced as cid:<content_id> in HTML"
          }
        }
      },
      "SendEmailRequest": {
        "type": "object",
        "required": [
          "from",
          "subject"
        ],
        "additionalProperties": false,
        "description": "At least one of text/html, and at least one recipient across to/cc/bcc.",
        "properties": {
          "from": {
            "$ref": "#/components/schemas/Address"
          },
          "to": {
            "$ref": "#/components/schemas/AddressList"
          },
          "cc": {
            "$ref": "#/components/schemas/AddressList"
          },
          "bcc": {
            "$ref": "#/components/schemas/AddressList"
          },
          "reply_to": {
            "$ref": "#/components/schemas/AddressList"
          },
          "subject": {
            "type": "string",
            "minLength": 1,
            "maxLength": 998
          },
          "text": {
            "type": "string"
          },
          "html": {
            "type": "string"
          },
          "headers": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Custom headers (names without spaces or colons; values up to 2,000 characters). Not allowed: From, To, Cc, Bcc, Reply-To, Subject, Message-ID, Date, MIME-Version, Content-* and Resent-* headers, Precedence, List-Id, List-Unsubscribe, List-Unsubscribe-Post, and headers mail servers add or that claim another sender: Sender, Return-Path, Received, Received-SPF, DKIM-Signature, DomainKey-Signature, Authentication-Results, ARC-*, Delivered-To, X-Original-To, X-Account-Id, Feedback-ID."
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Attachment"
            }
          },
          "in_reply_to": {
            "type": "string",
            "description": "Message-ID being replied to"
          },
          "references": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "signature": {
            "type": "boolean",
            "default": true,
            "description": "false leaves out the From address's signature. The domain's disclaimer is always added."
          },
          "from_name": {
            "type": "string",
            "maxLength": 200,
            "description": "The From name (\"Jane Smith\" in \"Jane Smith <jane@…>\"). No line breaks. Overrides a name in `from`; without either, the address's saved From name is used.",
            "example": "Jane Smith"
          }
        }
      },
      "SentEmail": {
        "type": "object",
        "required": [
          "id",
          "message_id",
          "accepted",
          "rejected",
          "sent_at",
          "thread_id",
          "suppressed"
        ],
        "properties": {
          "id": {
            "type": "string",
            "example": "out_2f154a2f-34b4-475f-b349-202cf97a2adc"
          },
          "message_id": {
            "type": "string",
            "example": "<out_2f154a2f-34b4-475f-b349-202cf97a2adc@yourapp.com>"
          },
          "accepted": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "rejected": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sent_at": {
            "type": "string",
            "format": "date-time"
          },
          "thread_id": {
            "type": "string",
            "description": "Replies to this email arrive with this thread_id",
            "example": "thr_2c9e0d1f5a7b3e4c6d8f0a1b"
          },
          "suppressed": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Recipients left out because they're on your suppression list (an earlier hard bounce or complaint)"
          },
          "from": {
            "type": "object",
            "description": "The From the email was sent with, including the name used",
            "properties": {
              "address": {
                "type": "string"
              },
              "name": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "Machine-readable code, e.g. sender_not_allowed"
          },
          "message": {
            "type": "string"
          },
          "statusCode": {
            "type": "integer"
          }
        }
      },
      "ValidationError": {
        "type": "object",
        "required": [
          "error",
          "issues"
        ],
        "properties": {
          "error": {
            "const": "validation_error"
          },
          "issues": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "code": {
                  "type": "string"
                },
                "path": {
                  "type": "array",
                  "items": {
                    "type": [
                      "string",
                      "integer"
                    ]
                  }
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "WebhookTestResult": {
        "type": "object",
        "required": [
          "delivered"
        ],
        "properties": {
          "delivered": {
            "type": "boolean"
          },
          "event_id": {
            "type": "string"
          },
          "error": {
            "type": "string"
          }
        }
      },
      "WebhookEvent": {
        "type": "object",
        "required": [
          "id",
          "type",
          "timestamp",
          "created_at",
          "tenant_id",
          "data"
        ],
        "properties": {
          "id": {
            "type": "string",
            "example": "evt_6c1d…"
          },
          "type": {
            "type": "string",
            "enum": [
              "email.received",
              "webhook.test"
            ]
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "description": "Standard Webhooks payload field (same as created_at)"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "tenant_id": {
            "type": "string",
            "description": "Your account ID"
          },
          "data": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/InboundEmail"
              },
              {
                "type": "object",
                "properties": {
                  "message": {
                    "type": "string"
                  }
                },
                "description": "webhook.test"
              }
            ]
          }
        }
      },
      "ParsedAddress": {
        "type": "object",
        "properties": {
          "address": {
            "type": "string"
          },
          "name": {
            "type": "string"
          }
        }
      },
      "InboundAttachment": {
        "type": "object",
        "properties": {
          "filename": {
            "type": [
              "string",
              "null"
            ],
            "description": "From the sender: sanitise before saving"
          },
          "content_type": {
            "type": "string"
          },
          "size": {
            "type": "integer"
          },
          "content_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "disposition": {
            "type": [
              "string",
              "null"
            ]
          },
          "content": {
            "type": [
              "string",
              "null"
            ],
            "contentEncoding": "base64",
            "description": "null when attachments are delivered as separate parts (multipart), uploaded to your bucket (storage) or left out"
          },
          "sha256": {
            "type": "string",
            "description": "Hex SHA-256 of the file. In multipart deliveries, check the file part against this: the event JSON is what's signed."
          },
          "part": {
            "type": "string",
            "example": "attachment_0",
            "description": "Multipart deliveries only: the form part holding this file"
          },
          "storage": {
            "$ref": "#/components/schemas/StoredFile"
          }
        }
      },
      "Authentication": {
        "type": "object",
        "properties": {
          "verdict": {
            "type": "string",
            "enum": [
              "pass",
              "fail",
              "none",
              "temperror",
              "permerror"
            ],
            "description": "DMARC result for the From domain"
          },
          "spf": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "result": {
                "type": "string"
              },
              "domain": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "client_ip": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "dkim": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "result": {
                  "type": "string"
                },
                "domain": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "selector": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "aligned": {
                  "type": "boolean"
                }
              }
            }
          },
          "dmarc": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "result": {
                "type": "string"
              },
              "policy": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "domain": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "arc": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "result": {
                "type": "string"
              }
            }
          },
          "header": {
            "type": "string"
          }
        }
      },
      "InboundEmail": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "inb_…"
          },
          "message_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "De-duplicate on this"
          },
          "envelope": {
            "type": "object",
            "properties": {
              "mail_from": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "rcpt_to": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "client_ip": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "helo": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "from": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/ParsedAddress"
              },
              {
                "type": "null"
              }
            ]
          },
          "to": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ParsedAddress"
            }
          },
          "cc": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ParsedAddress"
            }
          },
          "reply_to": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ParsedAddress"
            }
          },
          "subject": {
            "type": [
              "string",
              "null"
            ]
          },
          "date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "in_reply_to": {
            "type": [
              "string",
              "null"
            ]
          },
          "references": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "thread_id": {
            "type": "string",
            "example": "thr_836de45f552c568b8e3b9810",
            "description": "Same for every message in a conversation: see thread"
          },
          "thread": {
            "$ref": "#/components/schemas/Thread"
          },
          "text": {
            "type": [
              "string",
              "null"
            ]
          },
          "reply_text": {
            "type": [
              "string",
              "null"
            ],
            "description": "Just the new part of a reply: quoted history (\"On … wrote:\", \"> \" lines, Outlook header blocks) and signature removed. Best effort: text has everything."
          },
          "html": {
            "type": [
              "string",
              "null"
            ]
          },
          "headers": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Lower-cased names"
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InboundAttachment"
            }
          },
          "authentication": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Authentication"
              },
              {
                "type": "null"
              }
            ]
          },
          "auto_submitted": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "auto_reply",
              "bounce",
              "auto_generated",
              null
            ],
            "description": "Set for out-of-office replies, bounces and other machine-generated mail. Never auto-reply to these."
          },
          "bounce": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Bounce"
              },
              {
                "type": "null"
              }
            ]
          },
          "calendar": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CalendarEvent"
            },
            "description": "Events from attached iCalendar invites (.ics)"
          },
          "recipients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InboundRecipient"
            },
            "description": "Your envelope recipients, split into base address and tag"
          },
          "spam": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/SpamResult"
              },
              {
                "type": "null"
              }
            ]
          },
          "virus": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/VirusResult"
              },
              {
                "type": "null"
              }
            ]
          },
          "extracted": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Extracted"
              },
              {
                "type": "null"
              }
            ],
            "description": "Fields pulled out by the address's parser (rules or AI); null when the address has no parser."
          },
          "size": {
            "type": "integer",
            "description": "Size of the original message in bytes"
          },
          "raw": {
            "type": "string",
            "contentEncoding": "base64",
            "description": "The original message (.eml). Only when \"Include the original message\" is on and attachments are inline or omitted."
          },
          "raw_part": {
            "type": "string",
            "const": "raw",
            "description": "Multipart deliveries with \"Include the original message\" on: the form part holding the .eml."
          },
          "received_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "description": "data of an email.received event. raw and raw_part only appear when the account asks for the original message."
      },
      "AddressCreate": {
        "type": "object",
        "required": [
          "local_part"
        ],
        "additionalProperties": false,
        "properties": {
          "local_part": {
            "type": "string",
            "description": "The part before the @ (no +). \"name@domain\" is accepted if the domain matches. Use * for patterns: \"ticket-*\" or \"*\" (catch-all). Patterns can only receive.",
            "example": "info"
          },
          "can_send": {
            "type": "boolean",
            "default": true,
            "description": "Default: true when the platform sends email, else false"
          },
          "can_receive": {
            "type": "boolean",
            "default": true
          },
          "webhook_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Send this address's mail to its own webhook; null/empty = the domain's or account's"
          },
          "require_signed_tag": {
            "type": "boolean",
            "description": "Only accept signed reply addresses (support+tag.signature@); plain and forged sub-addresses are refused"
          },
          "parser_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Parser (from the dashboard's Parsers page) for this address's mail; null for none"
          }
        }
      },
      "AddressUpdate": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "can_send": {
            "type": "boolean"
          },
          "can_receive": {
            "type": "boolean"
          },
          "webhook_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Send this address's mail to its own webhook; null/empty = the domain's or account's"
          },
          "require_signed_tag": {
            "type": "boolean",
            "description": "Only accept signed reply addresses (support+tag.signature@); plain and forged sub-addresses are refused"
          },
          "parser_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Parser (from the dashboard's Parsers page) for this address's mail; null for none"
          },
          "display_name": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 100,
            "description": "From name for email sent from this address, used when a send gives none"
          },
          "position": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 100,
            "description": "Shown under the name in the signature"
          },
          "signature": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 2000,
            "description": "Plain-text signature, added after a \"-- \" line to email sent from this address. Web and email addresses become links in the HTML version."
          }
        }
      },
      "DomainCreate": {
        "type": "object",
        "required": [
          "name"
        ],
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 253,
            "example": "customer-shop.com"
          },
          "reference": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 255,
            "description": "Your own ID for this domain"
          },
          "inbound_enabled": {
            "type": "boolean",
            "default": false
          },
          "webhook_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "description": "Overrides the account's webhook URL for this domain"
          },
          "max_message_bytes": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Largest email accepted for this domain (1024 up to the platform limit, 25 MB); null = platform limit"
          },
          "addresses": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/AddressCreate"
            }
          }
        }
      },
      "DomainUpdate": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "inbound_enabled": {
            "type": "boolean"
          },
          "webhook_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "description": "null = use the account's webhook URL"
          },
          "reference": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 255
          },
          "max_message_bytes": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Largest email accepted for this domain (1024 up to the platform limit, 25 MB); null = platform limit"
          },
          "disclaimer": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 4000,
            "description": "Plain text added to the end of every email sent from this domain"
          },
          "parser_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The parser for the domain's addresses that don't have their own"
          }
        }
      },
      "DnsRecord": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "spf",
              "dkim",
              "dmarc",
              "mx"
            ]
          },
          "type": {
            "type": "string",
            "enum": [
              "TXT",
              "MX"
            ]
          },
          "host": {
            "type": "string"
          },
          "value": {
            "type": "string"
          },
          "priority": {
            "type": "integer"
          },
          "purpose": {
            "type": "string"
          },
          "note": {
            "type": "string"
          },
          "verified": {
            "type": "boolean"
          },
          "optional": {
            "type": "boolean",
            "description": "Recommended but not required (the DMARC record on an inbound-only platform)."
          }
        }
      },
      "DomainAddress": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "address": {
            "type": "string",
            "format": "email"
          },
          "local_part": {
            "type": "string"
          },
          "is_pattern": {
            "type": "boolean"
          },
          "can_send": {
            "type": "boolean"
          },
          "can_receive": {
            "type": "boolean"
          },
          "webhook_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "require_signed_tag": {
            "type": "boolean"
          },
          "parser_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "display_name": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 100,
            "description": "From name for email sent from this address, used when a send gives none"
          },
          "position": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 100,
            "description": "Shown under the name in the signature"
          },
          "signature": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 2000,
            "description": "Plain-text signature, added after a \"-- \" line to email sent from this address. Web and email addresses become links in the HTML version."
          }
        }
      },
      "Domain": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "reference": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "last_checked_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "inbound_enabled": {
            "type": "boolean"
          },
          "webhook_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "max_message_bytes": {
            "type": [
              "integer",
              "null"
            ]
          },
          "sending_ready": {
            "type": "boolean"
          },
          "inbound_ready": {
            "type": "boolean"
          },
          "records": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DnsRecord"
            }
          },
          "addresses": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DomainAddress"
            }
          },
          "sender_rules": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SenderRule"
            }
          },
          "dmarc_report_address": {
            "type": [
              "string",
              "null"
            ],
            "description": "Where this domain's DMARC aggregate reports go: the rua= in its DMARC record."
          },
          "disclaimer": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 4000,
            "description": "Plain text added to the end of every email sent from this domain"
          },
          "parser_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The parser for the domain's addresses that don't have their own"
          }
        }
      },
      "VerifyResult": {
        "type": "object",
        "properties": {
          "domain": {
            "$ref": "#/components/schemas/Domain"
          },
          "checks": {
            "type": "object",
            "properties": {
              "spf": {
                "type": "object",
                "properties": {
                  "ok": {
                    "type": "boolean"
                  },
                  "found": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "error": {
                    "type": "string"
                  }
                }
              },
              "dkim": {
                "type": "object",
                "properties": {
                  "ok": {
                    "type": "boolean"
                  },
                  "found": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "error": {
                    "type": "string"
                  }
                }
              },
              "dmarc": {
                "type": "object",
                "properties": {
                  "ok": {
                    "type": "boolean"
                  },
                  "found": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "error": {
                    "type": "string"
                  }
                }
              },
              "mx": {
                "type": "object",
                "properties": {
                  "ok": {
                    "type": "boolean"
                  },
                  "found": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "error": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      },
      "InboundRecipient": {
        "type": "object",
        "properties": {
          "address": {
            "type": "string",
            "example": "support+t42.k3j9x2m4q8a7b@acme.com"
          },
          "base_address": {
            "type": "string",
            "example": "support@acme.com",
            "description": "The allow-listed address it was delivered to (sub-address removed)"
          },
          "tag": {
            "type": [
              "string",
              "null"
            ],
            "example": "t42",
            "description": "The part after +; for a signed reply address, just the tag"
          },
          "tag_verified": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "true: a signed reply address made by your account. false: signed form but wrong signature (forged). null: not a signed tag."
          }
        }
      },
      "Bounce": {
        "type": "object",
        "properties": {
          "recipient": {
            "type": [
              "string",
              "null"
            ],
            "description": "The address that couldn't be delivered to"
          },
          "action": {
            "type": [
              "string",
              "null"
            ],
            "example": "failed"
          },
          "status": {
            "type": [
              "string",
              "null"
            ],
            "example": "5.1.1",
            "description": "5.x.x permanent, 4.x.x temporary"
          },
          "diagnostic": {
            "type": [
              "string",
              "null"
            ],
            "example": "550 5.1.1 User unknown"
          },
          "original_message_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Message-ID of the email that bounced, when the report includes it"
          }
        }
      },
      "CalendarEvent": {
        "type": "object",
        "properties": {
          "method": {
            "type": [
              "string",
              "null"
            ],
            "example": "REQUEST",
            "description": "REQUEST (invite/update), CANCEL, REPLY (an RSVP), PUBLISH"
          },
          "uid": {
            "type": [
              "string",
              "null"
            ]
          },
          "sequence": {
            "type": [
              "integer",
              "null"
            ]
          },
          "status": {
            "type": [
              "string",
              "null"
            ]
          },
          "summary": {
            "type": [
              "string",
              "null"
            ]
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "location": {
            "type": [
              "string",
              "null"
            ]
          },
          "start": {
            "type": [
              "string",
              "null"
            ],
            "example": "2026-10-05T09:00:00",
            "description": "ISO 8601. Ends in Z for UTC; otherwise local to timezone. Date only for all-day events."
          },
          "end": {
            "type": [
              "string",
              "null"
            ]
          },
          "timezone": {
            "type": [
              "string",
              "null"
            ],
            "example": "Europe/London"
          },
          "all_day": {
            "type": "boolean"
          },
          "recurrence": {
            "type": [
              "string",
              "null"
            ],
            "description": "RRULE, e.g. FREQ=WEEKLY;BYDAY=MO"
          },
          "organizer": {
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string"
                  },
                  "name": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "attendees": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "email": {
                  "type": "string"
                },
                "name": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "status": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "example": "NEEDS-ACTION"
                },
                "role": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              }
            }
          }
        }
      },
      "SpamResult": {
        "type": "object",
        "description": "From rspamd, when the platform has spam scanning on",
        "properties": {
          "score": {
            "type": "number",
            "example": 2.4,
            "description": "Higher is spammier: around 6 is probably spam, 15 definitely"
          },
          "action": {
            "type": "string",
            "example": "no action"
          },
          "symbols": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Rules that matched"
          }
        }
      },
      "VirusResult": {
        "type": "object",
        "description": "From ClamAV, when the platform has virus scanning on",
        "properties": {
          "infected": {
            "type": "boolean"
          },
          "names": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "SenderRule": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "rul_…"
          },
          "action": {
            "type": "string",
            "enum": [
              "allow",
              "block"
            ]
          },
          "pattern": {
            "type": "string",
            "example": "*.example.com",
            "description": "An address, a domain, or *. plus a domain for its subdomains"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "SenderRuleCreate": {
        "type": "object",
        "required": [
          "action",
          "pattern"
        ],
        "properties": {
          "action": {
            "type": "string",
            "enum": [
              "allow",
              "block"
            ],
            "description": "block refuses matching senders. Any allow rule means only matching, authenticated senders are accepted."
          },
          "pattern": {
            "type": "string",
            "example": "partner.example"
          }
        }
      },
      "ReplyAddressRequest": {
        "type": "object",
        "required": [
          "address",
          "tag"
        ],
        "properties": {
          "address": {
            "type": "string",
            "example": "support@acme.com",
            "description": "A receiving address on one of your domains"
          },
          "tag": {
            "type": "string",
            "example": "t42",
            "description": "1-40 characters: letters, digits, - and _. Lower-cased."
          }
        }
      },
      "ReplyAddress": {
        "type": "object",
        "properties": {
          "address": {
            "type": "string",
            "example": "support+t42.k3j9x2m4q8a7b@acme.com"
          },
          "base_address": {
            "type": "string"
          },
          "tag": {
            "type": "string"
          }
        }
      },
      "Delivery": {
        "type": "object",
        "description": "What happened to one inbound email for your account. Metadata only, never content.",
        "properties": {
          "id": {
            "type": "integer"
          },
          "domain_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "delivered",
              "deferred",
              "failed",
              "rejected",
              "dropped"
            ],
            "description": "deferred: your webhook failed temporarily, the sender will retry. failed: your webhook refused it (4xx). rejected: refused by a rule or unknown address. dropped: accepted but not delivered (auto-reply setting)."
          },
          "reason": {
            "type": [
              "string",
              "null"
            ]
          },
          "email_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "event_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "message_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "sender_domain": {
            "type": [
              "string",
              "null"
            ]
          },
          "recipients": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "webhook_host": {
            "type": [
              "string",
              "null"
            ]
          },
          "http_status": {
            "type": [
              "integer",
              "null"
            ]
          },
          "attempts": {
            "type": [
              "integer",
              "null"
            ]
          },
          "duration_ms": {
            "type": [
              "integer",
              "null"
            ]
          },
          "size_bytes": {
            "type": [
              "integer",
              "null"
            ]
          },
          "spam_score": {
            "type": [
              "number",
              "null"
            ]
          },
          "flags": {
            "type": [
              "object",
              "null"
            ],
            "description": "e.g. dmarc, auto_submitted, virus, signed_tag, and code for refusals"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Extracted": {
        "type": "object",
        "properties": {
          "parser_id": {
            "type": "string",
            "example": "prs_…"
          },
          "parser": {
            "type": "string",
            "example": "Orders"
          },
          "method": {
            "type": "string",
            "enum": [
              "rules",
              "ai",
              "schema"
            ]
          },
          "fields": {
            "type": "object",
            "additionalProperties": true,
            "example": {
              "order_number": "1042",
              "total": 42.5,
              "tracking": "TRK-88213"
            },
            "description": "One key per field you defined; null when the email didn't contain it. Empty when extraction failed. Schema parsers: the answer's top-level plain values (for Slack, Sheets and routing rules)."
          },
          "error": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why extraction failed (the email is still delivered), e.g. the daily AI limit"
          },
          "truncated": {
            "type": "boolean",
            "description": "AI parsers: the email was very long and only its start was read"
          },
          "data": {
            "description": "Schema parsers: the answer in your schema's shape (null when there's no answer)."
          },
          "valid": {
            "type": "boolean",
            "description": "Schema parsers: data passed every check in your schema"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "example": [
              "/lines/0/qty must be >= 1"
            ],
            "description": "Schema parsers: why data didn't pass"
          },
          "schema_version": {
            "type": "integer",
            "description": "Schema parsers: the version of the schema used"
          },
          "schema_sha256": {
            "type": "string",
            "description": "Schema parsers: SHA-256 of the exact schema used"
          }
        }
      },
      "Inbox": {
        "type": "object",
        "properties": {
          "address": {
            "type": [
              "string",
              "null"
            ],
            "example": "k3j9x2m4q8a7@in.mailparser.example",
            "description": "null when turned off"
          },
          "enabled": {
            "type": "boolean"
          },
          "available": {
            "type": "boolean",
            "description": "false when this platform has no instant addresses"
          }
        }
      },
      "SampleResult": {
        "type": "object",
        "properties": {
          "to": {
            "type": "string"
          },
          "delivered": {
            "type": "boolean"
          },
          "error": {
            "type": "string",
            "description": "Only when not delivered"
          }
        }
      },
      "Thread": {
        "type": "object",
        "description": "The conversation this email belongs to. thread_id is the same for the first message and every reply (derived from References / In-Reply-To, then Outlook's Thread-Index), so it can be computed for an email you sent: thr_ + the first 24 hex characters of SHA-256 of its Message-ID without angle brackets (domain part lower-cased). The SDKs have a helper.",
        "required": [
          "id",
          "root_message_id",
          "position",
          "is_reply",
          "method",
          "tag"
        ],
        "properties": {
          "id": {
            "type": "string",
            "example": "thr_836de45f552c568b8e3b9810"
          },
          "root_message_id": {
            "type": [
              "string",
              "null"
            ],
            "example": "<out_1@yourapp.com>",
            "description": "The conversation's first message; null when only Outlook's Thread-Index identified it"
          },
          "position": {
            "type": "integer",
            "description": "0 for the first message; otherwise how many messages precede it (approximate)"
          },
          "is_reply": {
            "type": "boolean"
          },
          "method": {
            "type": "string",
            "enum": [
              "references",
              "in_reply_to",
              "thread_index",
              "message_id",
              "none"
            ]
          },
          "tag": {
            "type": [
              "string",
              "null"
            ],
            "description": "Your tag from a verified signed reply address (e.g. a ticket ID), when there is one"
          }
        }
      },
      "WebhookSettings": {
        "type": "object",
        "properties": {
          "webhook_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "backup_webhook_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "description": "Tried when webhook_url is unreachable or returns 5xx (after its retries), before the sender is asked to retry. A 4xx answer is final."
          },
          "webhook_signature": {
            "type": "string",
            "enum": [
              "standard",
              "legacy"
            ],
            "description": "standard = Standard Webhooks; legacy = the original t=…,v1=… format. Switching to standard needs a secret made after Standard Webhooks support (rotate first if you get secret_incompatible)."
          },
          "reject_bulk_inbound": {
            "type": "boolean"
          },
          "enforce_dmarc": {
            "type": "boolean"
          },
          "drop_auto_replies": {
            "type": "boolean"
          },
          "spam_threshold": {
            "type": [
              "number",
              "null"
            ]
          },
          "reject_viruses": {
            "type": "boolean"
          },
          "reject_risky_attachments": {
            "type": "boolean",
            "description": "Refuse email with dangerous attachments: programs, scripts, Office files with macros, disk images and shortcuts (.exe, .js, .docm, .iso, .lnk…), and zip files holding them. On by default."
          },
          "attachments_mode": {
            "type": "string",
            "enum": [
              "inline",
              "multipart",
              "omit",
              "storage"
            ],
            "description": "storage: uploaded to your bucket (set up with /v1/webhook/storage first), with links in attachments[].storage"
          },
          "include_raw": {
            "type": "boolean"
          },
          "alerts_enabled": {
            "type": "boolean"
          },
          "webhook_secret_rotating_until": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "WebhookSettingsUpdate": {
        "type": "object",
        "description": "Only the settings to change.",
        "properties": {
          "webhook_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "backup_webhook_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "description": "Tried when webhook_url is unreachable or returns 5xx (after its retries), before the sender is asked to retry. A 4xx answer is final."
          },
          "webhook_signature": {
            "type": "string",
            "enum": [
              "standard",
              "legacy"
            ],
            "description": "standard = Standard Webhooks; legacy = the original t=…,v1=… format. Switching to standard needs a secret made after Standard Webhooks support (rotate first if you get secret_incompatible)."
          },
          "reject_bulk_inbound": {
            "type": "boolean"
          },
          "enforce_dmarc": {
            "type": "boolean"
          },
          "drop_auto_replies": {
            "type": "boolean"
          },
          "spam_threshold": {
            "type": [
              "number",
              "null"
            ]
          },
          "reject_viruses": {
            "type": "boolean"
          },
          "reject_risky_attachments": {
            "type": "boolean",
            "description": "Refuse email with dangerous attachments: programs, scripts, Office files with macros, disk images and shortcuts (.exe, .js, .docm, .iso, .lnk…), and zip files holding them. On by default."
          },
          "attachments_mode": {
            "type": "string",
            "enum": [
              "inline",
              "multipart",
              "omit",
              "storage"
            ],
            "description": "storage: uploaded to your bucket (set up with /v1/webhook/storage first), with links in attachments[].storage"
          },
          "include_raw": {
            "type": "boolean"
          },
          "alerts_enabled": {
            "type": "boolean"
          }
        }
      },
      "SecretRotation": {
        "type": "object",
        "properties": {
          "webhook_secret": {
            "type": "string",
            "example": "whsec_Rml4dHVyZVNlY3JldEZvclNES1Rlc3RzMDE="
          },
          "previous_secret_valid_until": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "Subaccount": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "acct_mb_kwrlaq_jhk2AQ"
          },
          "name": {
            "type": "string"
          },
          "reference": {
            "type": [
              "string",
              "null"
            ],
            "description": "Your own ID for this customer"
          },
          "suspended": {
            "type": "boolean"
          },
          "suspended_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "webhook_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "package": {
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  }
                }
              },
              {
                "type": "null"
              }
            ],
            "description": "The customer package limiting it (Packages), or null"
          },
          "mailboxes": {
            "type": "integer",
            "description": "Email addresses on its domains"
          },
          "sending_paused": {
            "type": "boolean",
            "description": "Sending stopped (by you, or automatically for too many bounces or complaints); receiving carries on"
          },
          "sending_paused_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "sending_paused_reason": {
            "type": [
              "string",
              "null"
            ]
          },
          "domains": {
            "type": "integer"
          },
          "users": {
            "type": "integer"
          },
          "delivered_30d": {
            "type": "integer"
          },
          "last_delivery_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Invitation": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "role": {
            "type": "string",
            "enum": [
              "owner",
              "admin",
              "developer",
              "viewer"
            ]
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "SubaccountCreated": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "acct_mb_kwrlaq_jhk2AQ"
          },
          "name": {
            "type": "string"
          },
          "reference": {
            "type": [
              "string",
              "null"
            ],
            "description": "Your own ID for this customer"
          },
          "suspended": {
            "type": "boolean"
          },
          "suspended_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "webhook_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "package": {
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  }
                }
              },
              {
                "type": "null"
              }
            ],
            "description": "The customer package limiting it (Packages), or null"
          },
          "mailboxes": {
            "type": "integer",
            "description": "Email addresses on its domains"
          },
          "sending_paused": {
            "type": "boolean",
            "description": "Sending stopped (by you, or automatically for too many bounces or complaints); receiving carries on"
          },
          "sending_paused_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "sending_paused_reason": {
            "type": [
              "string",
              "null"
            ]
          },
          "domains": {
            "type": "integer"
          },
          "users": {
            "type": "integer"
          },
          "delivered_30d": {
            "type": "integer"
          },
          "last_delivery_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "webhook_secret": {
            "type": "string",
            "description": "Its webhook signing secret: shown only this once"
          },
          "invitation": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Invitation"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "SubaccountCreate": {
        "type": "object",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 100
          },
          "reference": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 255
          },
          "webhook_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "owner_email": {
            "type": [
              "string",
              "null"
            ],
            "format": "email",
            "description": "Invite this person (by email, with your branding) to use the dashboard as the owner"
          },
          "package": {
            "type": [
              "string",
              "null"
            ],
            "description": "The customer package: its id or exact name"
          }
        }
      },
      "SubaccountUpdate": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "reference": {
            "type": [
              "string",
              "null"
            ]
          },
          "suspended": {
            "type": "boolean",
            "description": "Suspended: its mail is refused, users are signed out and its own API keys stop working. You can still manage it."
          },
          "package": {
            "type": [
              "string",
              "null"
            ],
            "description": "Move to another package (its id or exact name), or null for none. Only limits what's added from then on."
          },
          "sending_paused": {
            "type": "boolean",
            "description": "Pause or resume its sending. Resume one paused for bounces or complaints once the cause is fixed: only what happens after counts."
          }
        }
      },
      "InvitationCreate": {
        "type": "object",
        "required": [
          "email"
        ],
        "properties": {
          "email": {
            "type": "string",
            "format": "email"
          },
          "role": {
            "type": "string",
            "enum": [
              "owner",
              "admin",
              "developer",
              "viewer"
            ],
            "default": "owner"
          }
        }
      },
      "Meta": {
        "type": "object",
        "properties": {
          "webhook_source_ips": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Webhooks come from these addresses (empty if not published)"
          },
          "mx_hostname": {
            "type": "string"
          },
          "inbox_domain": {
            "type": [
              "string",
              "null"
            ]
          },
          "data_region": {
            "type": [
              "string",
              "null"
            ],
            "example": "United Kingdom"
          },
          "webhook_signature": {
            "type": "object",
            "properties": {
              "default": {
                "type": "string"
              },
              "spec": {
                "type": "string"
              }
            }
          }
        }
      },
      "Usage": {
        "type": "object",
        "properties": {
          "access": {
            "type": "object",
            "description": "Whether the account can receive and send right now. state is ok; card_required (verify a card on the Billing page; deadline is when mail starts being held, null if it already is); or free_used (the 1,000 free emails are used: choose pay as you go with a spending limit, or a plan). While not ok, inbound mail is held, not lost.",
            "required": [
              "state"
            ],
            "properties": {
              "state": {
                "type": "string",
                "enum": [
                  "ok",
                  "card_required",
                  "free_used"
                ]
              },
              "reason": {
                "type": "string",
                "description": "What to do, in words to show the customer (when not ok)"
              },
              "deadline": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              },
              "card_deadline": {
                "type": "string",
                "format": "date-time",
                "description": "ok, but a card must be verified by then"
              },
              "trial": {
                "type": [
                  "object",
                  "null"
                ],
                "description": "The free emails, while on the free trial",
                "properties": {
                  "used": {
                    "type": "integer"
                  },
                  "included": {
                    "type": "integer"
                  },
                  "remaining": {
                    "type": "integer"
                  }
                }
              }
            }
          },
          "enabled": {
            "type": "boolean",
            "description": "false when this platform has no paid plans (nothing is limited by plan)"
          },
          "plan": {
            "type": "string",
            "enum": [
              "free",
              "payg",
              "starter",
              "pro",
              "business",
              "reseller_starter",
              "reseller_growth",
              "reseller_scale"
            ]
          },
          "plan_name": {
            "type": "string"
          },
          "interval": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "month",
              "year",
              null
            ]
          },
          "override": {
            "type": "boolean",
            "description": "A free upgrade from the platform operator: no charge for the plan"
          },
          "sip_trunks": {
            "type": [
              "object",
              "null"
            ],
            "description": "Calls on the account's own SIP trunks this period: null when there are no trunks and no minutes. Trunks are included on every plan; calls in and out are charged by the minute, each rounded up",
            "properties": {
              "count": {
                "type": "integer",
                "description": "Trunks connected"
              },
              "minutes": {
                "type": "integer",
                "description": "Phone minutes this period, in and out"
              },
              "interval": {
                "type": "string",
                "enum": [
                  "month",
                  "year"
                ]
              },
              "minute_pence": {
                "type": "integer"
              },
              "cost_pence": {
                "type": "integer"
              },
              "charged": {
                "type": "boolean"
              },
              "not_charged_because": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "override_until": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the free upgrade ends (null: until the operator removes it, or no free upgrade)"
          },
          "billing_account_id": {
            "type": "string",
            "description": "The account billed (a reseller, for its sub-accounts)"
          },
          "period_start": {
            "type": "string",
            "format": "date-time"
          },
          "period_end": {
            "type": "string",
            "format": "date-time"
          },
          "emails": {
            "type": "object",
            "properties": {
              "used": {
                "type": "integer",
                "description": "Received plus sent: one allowance covers both"
              },
              "included": {
                "type": "integer"
              },
              "overage": {
                "type": "integer"
              },
              "received": {
                "type": "integer",
                "description": "Emails delivered to the account"
              },
              "sent": {
                "type": "integer",
                "description": "Recipients of email the account sent (each recipient counts as one email)"
              }
            }
          },
          "ai": {
            "type": "object",
            "properties": {
              "used": {
                "type": "integer"
              },
              "included": {
                "type": "integer"
              }
            }
          },
          "meetings": {
            "type": "object",
            "description": "Webmail meetings of 7 to 25 people (on the media server): person-minutes this period, the plan's allowance, and the charge beyond it, up to the account's cap. At the cap, or on a plan without them, meetings hold up to 6.",
            "properties": {
              "available": {
                "type": "boolean"
              },
              "code": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "plan",
                  "store_billing",
                  "cap",
                  null
                ]
              },
              "reason": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "charged": {
                "type": "boolean"
              },
              "used_minutes": {
                "type": "integer"
              },
              "included_minutes": {
                "type": "integer"
              },
              "billable_minutes": {
                "type": "integer"
              },
              "pence_per_person_hour": {
                "type": "integer"
              },
              "cost_pence": {
                "type": "integer"
              },
              "cap_pence": {
                "type": "integer"
              }
            }
          },
          "overage_pence_per_1000": {
            "type": [
              "integer",
              "null"
            ]
          },
          "overage_cost_pence": {
            "type": "integer"
          },
          "mailboxes": {
            "type": [
              "object",
              "null"
            ],
            "description": "Reseller plans (priced per mailbox): your and your customers' mailboxes, those included, and the ones beyond, billed monthly",
            "properties": {
              "used": {
                "type": "integer"
              },
              "included": {
                "type": "integer"
              },
              "extra": {
                "type": "integer"
              },
              "extra_pence_per_month": {
                "type": "integer"
              },
              "extra_cost_pence": {
                "type": "integer",
                "description": "For the extra mailboxes this period (a year is ten months' price)"
              }
            }
          }
        }
      },
      "Me": {
        "type": "object",
        "required": [
          "account",
          "api_key",
          "platform"
        ],
        "properties": {
          "account": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "plan": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "api_key": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "prefix": {
                "type": "string"
              },
              "scopes": {
                "type": "array",
                "items": {
                  "type": "string",
                  "enum": [
                    "send",
                    "domains",
                    "accounts",
                    "integrations"
                  ]
                }
              }
            }
          },
          "features": {
            "type": "object",
            "description": "What the webmail may offer this account. files: Files (document storage), currently on every plan.",
            "properties": {
              "files": {
                "type": "boolean"
              }
            }
          },
          "reseller_id": {
            "type": "string",
            "description": "Set when a reseller's key acts on a sub-account"
          },
          "platform": {
            "type": "string"
          }
        }
      },
      "HookCreate": {
        "type": "object",
        "required": [
          "target_url"
        ],
        "properties": {
          "target_url": {
            "type": "string",
            "format": "uri"
          },
          "event": {
            "type": "string",
            "enum": [
              "email.received"
            ]
          },
          "source": {
            "type": "string",
            "enum": [
              "make",
              "n8n",
              "webhook"
            ],
            "default": "webhook"
          },
          "name": {
            "type": "string",
            "maxLength": 100
          },
          "filter": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "address": {
                "type": "string",
                "description": "Only email to addresses matching this; * and ? wildcards"
              }
            }
          }
        }
      },
      "HookCreated": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "event": {
            "type": "string"
          },
          "target_url": {
            "type": "string"
          },
          "source": {
            "type": "string"
          },
          "filter": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "address": {
                "type": "string",
                "description": "Only email to addresses matching this; * and ? wildcards"
              }
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Hook": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "event": {
            "type": "string"
          },
          "source": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "target": {
            "type": "string",
            "description": "The URL's host only"
          },
          "filter": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "address": {
                "type": "string",
                "description": "Only email to addresses matching this; * and ? wildcards"
              }
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "DestinationCreate": {
        "type": "object",
        "required": [
          "type"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "webhook",
              "slack",
              "teams",
              "google_sheets",
              "make",
              "n8n"
            ]
          },
          "name": {
            "type": "string",
            "maxLength": 100
          },
          "enabled": {
            "type": "boolean",
            "default": true
          },
          "all_mail": {
            "type": "boolean",
            "default": false,
            "description": "Get every email (else only what routing rules send)"
          },
          "filter": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "address": {
                "type": "string",
                "description": "Only email to addresses matching this; * and ? wildcards"
              }
            }
          },
          "url": {
            "type": "string",
            "description": "Slack/Teams/webhook URL, or the Apps Script web app URL"
          },
          "include_body": {
            "type": "boolean",
            "default": true,
            "description": "Slack and Teams: include the message text"
          },
          "mode": {
            "type": "string",
            "enum": [
              "service_account",
              "apps_script"
            ],
            "description": "Google Sheets"
          },
          "spreadsheet": {
            "type": "string",
            "description": "Google Sheets (service_account): the spreadsheet URL or id"
          },
          "sheet": {
            "type": "string",
            "description": "Google Sheets: the tab"
          },
          "columns": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "maxItems": 30,
            "description": "Google Sheets columns, e.g. received_at, from, subject, extracted.order_number"
          }
        }
      },
      "DestinationUpdate": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 100
          },
          "enabled": {
            "type": "boolean",
            "default": true
          },
          "all_mail": {
            "type": "boolean",
            "default": false,
            "description": "Get every email (else only what routing rules send)"
          },
          "filter": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "address": {
                "type": "string",
                "description": "Only email to addresses matching this; * and ? wildcards"
              }
            }
          },
          "url": {
            "type": "string",
            "description": "Slack/Teams/webhook URL, or the Apps Script web app URL"
          },
          "include_body": {
            "type": "boolean",
            "default": true,
            "description": "Slack and Teams: include the message text"
          },
          "mode": {
            "type": "string",
            "enum": [
              "service_account",
              "apps_script"
            ],
            "description": "Google Sheets"
          },
          "spreadsheet": {
            "type": "string",
            "description": "Google Sheets (service_account): the spreadsheet URL or id"
          },
          "sheet": {
            "type": "string",
            "description": "Google Sheets: the tab"
          },
          "columns": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "maxItems": 30,
            "description": "Google Sheets columns, e.g. received_at, from, subject, extracted.order_number"
          }
        }
      },
      "Destination": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "webhook",
              "slack",
              "teams",
              "google_sheets",
              "make",
              "n8n"
            ]
          },
          "name": {
            "type": "string"
          },
          "summary": {
            "type": [
              "string",
              "null"
            ],
            "description": "Host or spreadsheet name; never the full URL"
          },
          "enabled": {
            "type": "boolean"
          },
          "all_mail": {
            "type": "boolean"
          },
          "filter": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "address": {
                "type": "string",
                "description": "Only email to addresses matching this; * and ? wildcards"
              }
            }
          },
          "source": {
            "type": "string",
            "enum": [
              "dashboard",
              "api",
              "hook"
            ]
          },
          "settings": {
            "type": "object",
            "description": "Non-secret settings: include_body; for Sheets mode, spreadsheet_id, sheet, columns"
          },
          "health": {
            "type": "object",
            "properties": {
              "status": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "ok",
                  "failing",
                  null
                ]
              },
              "error": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "last_delivery_at": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "failing_since": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "RoutingCondition": {
        "type": "object",
        "required": [
          "field",
          "op"
        ],
        "properties": {
          "field": {
            "type": "string",
            "enum": [
              "subject",
              "from",
              "from_domain",
              "from_name",
              "to",
              "cc",
              "body",
              "attachment_name",
              "has_attachments",
              "spam_score",
              "header"
            ]
          },
          "op": {
            "type": "string",
            "enum": [
              "contains",
              "not_contains",
              "equals",
              "not_equals",
              "starts_with",
              "ends_with",
              "matches",
              "not_matches",
              "gte",
              "lt",
              "is_true",
              "is_false"
            ]
          },
          "value": {
            "type": [
              "string",
              "number"
            ]
          },
          "header": {
            "type": "string",
            "description": "For field header: the header name"
          }
        }
      },
      "RoutingRuleCreate": {
        "type": "object",
        "required": [
          "name",
          "conditions",
          "action"
        ],
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 100
          },
          "enabled": {
            "type": "boolean",
            "default": true
          },
          "domain_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Only mail to this domain; null for all"
          },
          "match": {
            "type": "string",
            "enum": [
              "all",
              "any"
            ],
            "default": "all"
          },
          "conditions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RoutingCondition"
            },
            "minItems": 1,
            "maxItems": 10
          },
          "action": {
            "type": "string",
            "enum": [
              "route",
              "copy",
              "drop"
            ]
          },
          "targets": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "maxItems": 10,
            "description": "Destination ids, or \"webhook\" for the usual webhook (route only)"
          },
          "position": {
            "type": "integer",
            "minimum": 1,
            "description": "Where in the list (1 = first); default last"
          }
        }
      },
      "RoutingRuleUpdate": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 100
          },
          "enabled": {
            "type": "boolean",
            "default": true
          },
          "domain_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Only mail to this domain; null for all"
          },
          "match": {
            "type": "string",
            "enum": [
              "all",
              "any"
            ],
            "default": "all"
          },
          "conditions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RoutingCondition"
            },
            "minItems": 1,
            "maxItems": 10
          },
          "action": {
            "type": "string",
            "enum": [
              "route",
              "copy",
              "drop"
            ]
          },
          "targets": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "maxItems": 10,
            "description": "Destination ids, or \"webhook\" for the usual webhook (route only)"
          },
          "position": {
            "type": "integer",
            "minimum": 1,
            "description": "Where in the list (1 = first); default last"
          }
        }
      },
      "RoutingRule": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "enabled": {
            "type": "boolean"
          },
          "position": {
            "type": "integer"
          },
          "domain_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "match": {
            "type": "string",
            "enum": [
              "all",
              "any"
            ]
          },
          "conditions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RoutingCondition"
            }
          },
          "action": {
            "type": "string",
            "enum": [
              "route",
              "copy",
              "drop"
            ]
          },
          "targets": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "RuleTest": {
        "type": "object",
        "properties": {
          "subject": {
            "type": "string"
          },
          "from": {
            "type": "string"
          },
          "from_name": {
            "type": "string"
          },
          "to": {
            "type": "string"
          },
          "body": {
            "type": "string"
          },
          "attachment_names": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "spam_score": {
            "type": "number"
          }
        }
      },
      "RoutingDecision": {
        "type": "object",
        "properties": {
          "action": {
            "type": "string",
            "enum": [
              "default",
              "route",
              "drop"
            ]
          },
          "targets": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "copies": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "matched": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "action": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "Suppression": {
        "type": "object",
        "properties": {
          "address": {
            "type": "string"
          },
          "reason": {
            "type": "string",
            "enum": [
              "bounce",
              "complaint",
              "manual"
            ]
          },
          "detail": {
            "type": [
              "string",
              "null"
            ],
            "description": "The bounce status and diagnostic, or the complaint type"
          },
          "message_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Our id (out_…) of the message that bounced or was complained about"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "SuppressionCreate": {
        "type": "object",
        "required": [
          "address"
        ],
        "properties": {
          "address": {
            "type": "string",
            "format": "email"
          }
        }
      },
      "SuppressionCreated": {
        "type": "object",
        "properties": {
          "address": {
            "type": "string"
          },
          "reason": {
            "type": "string"
          },
          "detail": {
            "type": [
              "string",
              "null"
            ]
          },
          "message_id": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "DmarcTotals": {
        "type": "object",
        "properties": {
          "reports": {
            "type": "integer"
          },
          "messages": {
            "type": "integer"
          },
          "passed": {
            "type": "integer"
          },
          "failed": {
            "type": "integer"
          },
          "pass_rate": {
            "type": [
              "number",
              "null"
            ],
            "description": "Percentage of emails that passed DMARC"
          }
        }
      },
      "DmarcReport": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "dmr_…"
          },
          "org_name": {
            "type": "string",
            "example": "google.com"
          },
          "org_email": {
            "type": [
              "string",
              "null"
            ]
          },
          "report_id": {
            "type": "string"
          },
          "date_begin": {
            "type": "string",
            "format": "date-time"
          },
          "date_end": {
            "type": "string",
            "format": "date-time"
          },
          "policy": {
            "type": "object",
            "properties": {
              "domain": {
                "type": "string"
              },
              "p": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "pct": {
                "type": [
                  "integer",
                  "null"
                ]
              }
            }
          },
          "messages": {
            "type": "integer"
          },
          "passed": {
            "type": "integer"
          },
          "pass_rate": {
            "type": [
              "number",
              "null"
            ]
          },
          "received_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "DmarcReportDetail": {
        "allOf": [
          {
            "$ref": "#/components/schemas/DmarcReport"
          },
          {
            "type": "object",
            "properties": {
              "domain_id": {
                "type": "string"
              },
              "records": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "source_ip": {
                      "type": "string"
                    },
                    "count": {
                      "type": "integer"
                    },
                    "disposition": {
                      "type": "string",
                      "enum": [
                        "none",
                        "quarantine",
                        "reject"
                      ]
                    },
                    "dkim": {
                      "type": "string",
                      "description": "DMARC's DKIM verdict (aligned)"
                    },
                    "spf": {
                      "type": "string",
                      "description": "DMARC's SPF verdict (aligned)"
                    },
                    "header_from": {
                      "type": "string"
                    },
                    "envelope_from": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "dkim_auth": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "domain": {
                            "type": "string"
                          },
                          "result": {
                            "type": "string"
                          },
                          "selector": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "spf_auth": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "domain": {
                            "type": "string"
                          },
                          "result": {
                            "type": "string"
                          },
                          "selector": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        ]
      },
      "DmarcSummary": {
        "type": "object",
        "properties": {
          "domain_id": {
            "type": "string"
          },
          "domain": {
            "type": "string"
          },
          "report_address": {
            "type": [
              "string",
              "null"
            ]
          },
          "days": {
            "type": "integer"
          },
          "totals": {
            "$ref": "#/components/schemas/DmarcTotals"
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "source_ip": {
                  "type": "string"
                },
                "hostname": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "description": "Reverse DNS of the source, when it has one"
                },
                "messages": {
                  "type": "integer"
                },
                "passed": {
                  "type": "integer"
                },
                "dkim_pass": {
                  "type": "integer"
                },
                "spf_pass": {
                  "type": "integer"
                },
                "quarantined": {
                  "type": "integer"
                },
                "rejected": {
                  "type": "integer"
                },
                "header_from": {
                  "type": "string"
                },
                "reporters": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "reports": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DmarcReport"
            }
          }
        }
      },
      "DmarcOverview": {
        "type": "object",
        "properties": {
          "domains": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "domain_id": {
                  "type": "string"
                },
                "domain": {
                  "type": "string"
                },
                "report_address": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "last_30_days": {
                  "$ref": "#/components/schemas/DmarcTotals"
                },
                "last_report_at": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "format": "date-time"
                }
              }
            }
          }
        }
      },
      "AutopilotDecideRequest": {
        "type": "object",
        "required": [
          "shop",
          "email"
        ],
        "properties": {
          "shop": {
            "type": "object",
            "required": [
              "name"
            ],
            "properties": {
              "name": {
                "type": "string",
                "maxLength": 200
              },
              "url": {
                "type": "string",
                "maxLength": 500
              }
            }
          },
          "email": {
            "type": "object",
            "required": [
              "from",
              "subject",
              "text"
            ],
            "properties": {
              "from": {
                "type": "string",
                "format": "email"
              },
              "name": {
                "type": [
                  "string",
                  "null"
                ],
                "maxLength": 200
              },
              "subject": {
                "type": "string",
                "maxLength": 998
              },
              "text": {
                "type": "string",
                "maxLength": 20000,
                "description": "The customer's words (without the quoted thread)"
              }
            }
          },
          "order": {
            "type": [
              "object",
              "null"
            ],
            "required": [
              "facts"
            ],
            "properties": {
              "facts": {
                "type": "string",
                "maxLength": 8000,
                "description": "The order as plain lines: status, items, shipments and tracking. Only for a sender shown to be the order's customer."
              }
            }
          },
          "order_unverified": {
            "type": "boolean",
            "description": "An order was found, but the sender isn't shown to be its customer: the reply won't share it"
          },
          "settings": {
            "type": "object",
            "properties": {
              "sign_off": {
                "type": "string",
                "maxLength": 300
              },
              "shop_info": {
                "type": "string",
                "maxLength": 4000
              }
            }
          }
        }
      },
      "AutopilotDecision": {
        "type": "object",
        "required": [
          "intent",
          "confidence",
          "summary",
          "answered",
          "action_needed",
          "reply"
        ],
        "properties": {
          "intent": {
            "type": "string",
            "enum": [
              "order_status",
              "return",
              "change",
              "cancel",
              "product",
              "other"
            ]
          },
          "confidence": {
            "type": "string",
            "enum": [
              "high",
              "medium",
              "low"
            ]
          },
          "summary": {
            "type": "string",
            "description": "One line for the shop's staff"
          },
          "answered": {
            "type": "boolean",
            "description": "The reply fully deals with the email from the facts given"
          },
          "action_needed": {
            "type": [
              "string",
              "null"
            ],
            "description": "What staff must do, e.g. a change to the order"
          },
          "reply": {
            "type": "string",
            "description": "Plain-text reply, ending with the sign-off"
          }
        }
      },
      "StoredFile": {
        "type": "object",
        "description": "Attachment storage only: where the file is in your bucket, and a link to download it",
        "properties": {
          "provider": {
            "type": "string",
            "enum": [
              "aws",
              "r2",
              "b2",
              "gcs",
              "spaces",
              "wasabi",
              "other"
            ]
          },
          "bucket": {
            "type": "string"
          },
          "key": {
            "type": "string",
            "example": "email/2026/10/16/em_3kq9x/1-invoice.pdf"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "A presigned link (expires at url_expires_at), or a permanent link under your public address"
          },
          "url_expires_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "AttachmentStorage": {
        "type": "object",
        "required": [
          "provider",
          "bucket",
          "access_key_id"
        ],
        "properties": {
          "provider": {
            "type": "string",
            "enum": [
              "aws",
              "r2",
              "b2",
              "gcs",
              "spaces",
              "wasabi",
              "other"
            ]
          },
          "endpoint": {
            "type": [
              "string",
              "null"
            ],
            "description": "The S3 endpoint, e.g. https://<account id>.r2.cloudflarestorage.com. Not needed for AWS."
          },
          "region": {
            "type": [
              "string",
              "null"
            ],
            "example": "eu-west-2",
            "description": "auto for Cloudflare R2 and Google Cloud Storage"
          },
          "bucket": {
            "type": "string"
          },
          "prefix": {
            "type": [
              "string",
              "null"
            ],
            "example": "email/"
          },
          "access_key_id": {
            "type": "string"
          },
          "secret_access_key": {
            "type": "string",
            "writeOnly": true,
            "description": "Leave out on an update to keep the saved one. Never returned."
          },
          "link": {
            "type": "string",
            "enum": [
              "presigned",
              "public"
            ],
            "default": "presigned"
          },
          "public_base_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "link=public: the address the bucket is served from"
          },
          "link_hours": {
            "type": "integer",
            "minimum": 1,
            "maximum": 168,
            "default": 168
          }
        }
      },
      "AttachmentStorageSettings": {
        "type": "object",
        "properties": {
          "provider": {
            "type": "string",
            "enum": [
              "aws",
              "r2",
              "b2",
              "gcs",
              "spaces",
              "wasabi",
              "other"
            ]
          },
          "endpoint": {
            "type": [
              "string",
              "null"
            ],
            "description": "The S3 endpoint, e.g. https://<account id>.r2.cloudflarestorage.com. Not needed for AWS."
          },
          "region": {
            "type": [
              "string",
              "null"
            ],
            "example": "eu-west-2",
            "description": "auto for Cloudflare R2 and Google Cloud Storage"
          },
          "bucket": {
            "type": "string"
          },
          "prefix": {
            "type": [
              "string",
              "null"
            ],
            "example": "email/"
          },
          "access_key_id": {
            "type": "string"
          },
          "link": {
            "type": "string",
            "enum": [
              "presigned",
              "public"
            ],
            "default": "presigned"
          },
          "public_base_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "link=public: the address the bucket is served from"
          },
          "link_hours": {
            "type": "integer",
            "minimum": 1,
            "maximum": 168,
            "default": 168
          },
          "last_test_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "last_error": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "ParserInput": {
        "type": "object",
        "required": [
          "name",
          "mode"
        ],
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 100
          },
          "mode": {
            "type": "string",
            "enum": [
              "rules",
              "ai",
              "schema"
            ]
          },
          "fields": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "name",
                "type"
              ],
              "properties": {
                "name": {
                  "type": "string",
                  "example": "order_number"
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "string",
                    "number",
                    "integer",
                    "boolean",
                    "date",
                    "list"
                  ]
                },
                "description": {
                  "type": "string",
                  "description": "AI parsers: what the field is"
                },
                "rule": {
                  "type": "object",
                  "description": "Rules parsers: where to find it",
                  "properties": {
                    "source": {
                      "type": "string",
                      "enum": [
                        "subject",
                        "text",
                        "from",
                        "any"
                      ]
                    },
                    "kind": {
                      "type": "string",
                      "enum": [
                        "after",
                        "between",
                        "regex"
                      ]
                    },
                    "pattern": {
                      "type": "string"
                    },
                    "end": {
                      "type": "string"
                    }
                  }
                }
              }
            },
            "maxItems": 30,
            "description": "Rules and AI parsers"
          },
          "instructions": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 2000,
            "description": "AI and schema parsers: guidance for the whole parser"
          },
          "schema": {
            "type": "object",
            "description": "mode schema: a JSON Schema whose top level is an object, e.g. Pydantic's model_json_schema() or Zod's z.toJSONSchema()"
          }
        }
      },
      "Parser": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "prs_…"
          },
          "name": {
            "type": "string"
          },
          "mode": {
            "type": "string",
            "enum": [
              "rules",
              "ai",
              "schema"
            ]
          },
          "fields": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "name",
                "type"
              ],
              "properties": {
                "name": {
                  "type": "string",
                  "example": "order_number"
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "string",
                    "number",
                    "integer",
                    "boolean",
                    "date",
                    "list"
                  ]
                },
                "description": {
                  "type": "string",
                  "description": "AI parsers: what the field is"
                },
                "rule": {
                  "type": "object",
                  "description": "Rules parsers: where to find it",
                  "properties": {
                    "source": {
                      "type": "string",
                      "enum": [
                        "subject",
                        "text",
                        "from",
                        "any"
                      ]
                    },
                    "kind": {
                      "type": "string",
                      "enum": [
                        "after",
                        "between",
                        "regex"
                      ]
                    },
                    "pattern": {
                      "type": "string"
                    },
                    "end": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "instructions": {
            "type": [
              "string",
              "null"
            ]
          },
          "schema_version": {
            "type": "integer"
          },
          "schema": {
            "type": "object",
            "description": "Schema parsers (single parser responses): the current schema, normalised"
          },
          "schema_sha256": {
            "type": "string"
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Schema parsers: things worth fixing, e.g. required fields that can't be null"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "StorePreviewRequest": {
        "type": "object",
        "properties": {
          "subject": {
            "type": "string"
          },
          "html": {
            "type": "string"
          }
        }
      },
      "StorePreview": {
        "type": "object",
        "properties": {
          "subject": {
            "type": "string"
          },
          "html": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "unknown": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Value names the template uses that don't exist (usually a typo)"
          }
        }
      },
      "StoreTemplateUpdate": {
        "type": "object",
        "properties": {
          "enabled": {
            "type": "boolean"
          },
          "subject": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 300
          },
          "html": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 204800
          }
        }
      },
      "BigCommerceTemplate": {
        "type": "object",
        "properties": {
          "template": {
            "type": "string",
            "enum": [
              "order_confirmation",
              "shipping_confirmation",
              "order_cancelled",
              "refund_confirmation"
            ]
          },
          "name": {
            "type": "string"
          },
          "topics": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The BigCommerce webhooks that send it"
          },
          "when": {
            "type": "string"
          },
          "app_only": {
            "type": "boolean",
            "description": "Always false for BigCommerce stores"
          },
          "enabled": {
            "type": "boolean"
          },
          "subject": {
            "type": "string"
          },
          "html": {
            "type": "string"
          },
          "customised": {
            "type": "object",
            "properties": {
              "subject": {
                "type": "boolean"
              },
              "html": {
                "type": "boolean"
              }
            },
            "description": "false: the default is used"
          },
          "updated_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "BigCommerceEvent": {
        "type": "object",
        "properties": {
          "event_id": {
            "type": "string",
            "description": "What makes the event unique, like order:1001:confirmed or order:1001:shipped:77"
          },
          "topic": {
            "type": "string",
            "description": "The BigCommerce webhook (store/order/created, store/order/statusUpdated, store/shipment/created, store/order/refund/created), or inbox (mail to the store's inbox), message (emailed to an order's customer) or autopilot"
          },
          "order_name": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "sent",
              "failed",
              "skipped",
              "sending",
              "received"
            ]
          },
          "email_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The sent email's id (out_…)"
          },
          "error": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "BigCommerceStore": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "platform": {
            "type": "string",
            "enum": [
              "bigcommerce"
            ]
          },
          "shop_domain": {
            "type": "string",
            "description": "The store's control panel host, store-<hash>.mybigcommerce.com",
            "example": "store-abc123.mybigcommerce.com"
          },
          "store_hash": {
            "type": "string",
            "example": "abc123"
          },
          "name": {
            "type": "string"
          },
          "connection": {
            "type": "string",
            "enum": [
              "api"
            ],
            "description": "Connected with a store-level API account's token; we registered the store's webhooks"
          },
          "app_installed": {
            "type": "null"
          },
          "webhook_url": {
            "type": "string",
            "format": "uri",
            "description": "Where the webhooks we registered in the store point. Nothing to set up by hand."
          },
          "webhook_topics": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "example": [
              "store/order/created",
              "store/order/statusUpdated",
              "store/shipment/created",
              "store/order/refund/created"
            ]
          },
          "has_signing_secret": {
            "type": "null"
          },
          "from_address": {
            "type": "string",
            "format": "email"
          },
          "reply_to": {
            "type": [
              "string",
              "null"
            ]
          },
          "copy_to": {
            "type": [
              "string",
              "null"
            ]
          },
          "logo_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "accent_color": {
            "type": [
              "string",
              "null"
            ]
          },
          "inbox_address": {
            "type": [
              "string",
              "null"
            ],
            "format": "email",
            "description": "One of your addresses with Receive on. Order emails' Reply-To is this address signed for the order; replies and any other mail to it are forwarded to forward_to and (with the app) noted on the order."
          },
          "forward_to": {
            "type": [
              "string",
              "null"
            ],
            "format": "email",
            "description": "Where mail to the inbox is forwarded."
          },
          "enabled": {
            "type": "boolean"
          },
          "ready": {
            "type": "boolean",
            "description": "Everything is in place for emails to go out"
          },
          "problems": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "What's still missing, in plain words"
          },
          "last_event_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "last_status": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "ok",
              "error",
              null
            ]
          },
          "last_error": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "BigCommerceStoreDetail": {
        "allOf": [
          {
            "$ref": "#/components/schemas/BigCommerceStore"
          },
          {
            "type": "object",
            "properties": {
              "templates": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/BigCommerceTemplate"
                }
              }
            }
          }
        ]
      },
      "BigCommerceStoreCreate": {
        "type": "object",
        "required": [
          "store",
          "api_token",
          "from_address"
        ],
        "properties": {
          "store": {
            "type": "string",
            "description": "The API path BigCommerce shows with the token (https://api.bigcommerce.com/stores/abc123/v3/), the store's control panel address, or its hash"
          },
          "api_token": {
            "type": "string",
            "description": "A store-level API account's access token, with Orders: modify and Information & settings: read-only. Checked before the store is saved; never returned."
          },
          "name": {
            "type": "string",
            "maxLength": 100,
            "description": "Shown in the emails. Defaults to the store's name in BigCommerce."
          },
          "from_address": {
            "type": "string",
            "format": "email",
            "description": "A sending address on one of your verified domains."
          },
          "reply_to": {
            "type": [
              "string",
              "null"
            ],
            "format": "email",
            "description": "Where replies go"
          },
          "copy_to": {
            "type": [
              "string",
              "null"
            ],
            "format": "email",
            "description": "Also send every order email here (counts as an extra email)"
          },
          "logo_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "An https:// image shown at the top of the emails"
          },
          "accent_color": {
            "type": [
              "string",
              "null"
            ],
            "description": "Button colour, like #1a73e8"
          },
          "inbox_address": {
            "type": [
              "string",
              "null"
            ],
            "format": "email",
            "description": "One of your addresses with Receive on. Order emails' Reply-To is this address signed for the order; replies and any other mail to it are forwarded to forward_to and (with the app) noted on the order."
          },
          "forward_to": {
            "type": [
              "string",
              "null"
            ],
            "format": "email",
            "description": "Where mail to the inbox is forwarded."
          },
          "enabled": {
            "type": "boolean",
            "description": "false pauses this store's emails"
          }
        }
      },
      "BigCommerceStoreUpdate": {
        "type": "object",
        "properties": {
          "api_token": {
            "type": "string",
            "description": "A new access token: checked, and the store's webhooks registered with it, before it's saved"
          },
          "name": {
            "type": "string",
            "maxLength": 100,
            "description": "Shown in the emails. Defaults to the store's name in BigCommerce."
          },
          "from_address": {
            "type": "string",
            "format": "email",
            "description": "A sending address on one of your verified domains."
          },
          "reply_to": {
            "type": [
              "string",
              "null"
            ],
            "format": "email",
            "description": "Where replies go"
          },
          "copy_to": {
            "type": [
              "string",
              "null"
            ],
            "format": "email",
            "description": "Also send every order email here (counts as an extra email)"
          },
          "logo_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "An https:// image shown at the top of the emails"
          },
          "accent_color": {
            "type": [
              "string",
              "null"
            ],
            "description": "Button colour, like #1a73e8"
          },
          "inbox_address": {
            "type": [
              "string",
              "null"
            ],
            "format": "email",
            "description": "One of your addresses with Receive on. Order emails' Reply-To is this address signed for the order; replies and any other mail to it are forwarded to forward_to and (with the app) noted on the order."
          },
          "forward_to": {
            "type": [
              "string",
              "null"
            ],
            "format": "email",
            "description": "Where mail to the inbox is forwarded."
          },
          "enabled": {
            "type": "boolean",
            "description": "false pauses this store's emails"
          }
        }
      },
      "Package": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "pkg_Yx2k0aQwM1pZ"
          },
          "name": {
            "type": "string"
          },
          "max_mailboxes": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "description": "Mailboxes a customer on it can have; null for no limit"
          },
          "max_domains": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "description": "Domains; null for no limit"
          },
          "monthly_emails": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "description": "Emails a calendar month (received + sent); null for no limit"
          },
          "over_limit": {
            "type": "string",
            "enum": [
              "block",
              "allow"
            ],
            "description": "At the email limit: hold new email back (senders retry; sending is refused), or let it through and count it as over the limit, to charge for"
          },
          "customers": {
            "type": "integer",
            "description": "Customers on it"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "PackageCreate": {
        "type": "object",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 100
          },
          "max_mailboxes": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "description": "null or left out: no limit"
          },
          "max_domains": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "description": "null or left out: no limit"
          },
          "monthly_emails": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "description": "null or left out: no limit"
          },
          "over_limit": {
            "type": "string",
            "enum": [
              "block",
              "allow"
            ],
            "default": "block"
          }
        }
      },
      "PackageUpdate": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 100
          },
          "max_mailboxes": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "description": "null or left out: no limit"
          },
          "max_domains": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "description": "null or left out: no limit"
          },
          "monthly_emails": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "description": "null or left out: no limit"
          },
          "over_limit": {
            "type": "string",
            "enum": [
              "block",
              "allow"
            ],
            "default": "block"
          }
        }
      },
      "CustomerUsage": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "reference": {
            "type": [
              "string",
              "null"
            ]
          },
          "package": {
            "type": [
              "string",
              "null"
            ]
          },
          "mailboxes": {
            "type": "integer"
          },
          "max_mailboxes": {
            "type": [
              "integer",
              "null"
            ]
          },
          "domains": {
            "type": "integer"
          },
          "max_domains": {
            "type": [
              "integer",
              "null"
            ]
          },
          "emails": {
            "type": "integer",
            "description": "Received + sent this month"
          },
          "received": {
            "type": "integer"
          },
          "sent": {
            "type": "integer"
          },
          "monthly_emails": {
            "type": [
              "integer",
              "null"
            ]
          },
          "over_limit_emails": {
            "type": "integer",
            "description": "Let through over the package's limit (over_limit: allow): to charge for"
          },
          "refused_emails": {
            "type": "integer",
            "description": "Held back by the package's limit (over_limit: block)"
          },
          "bounces": {
            "type": "integer",
            "description": "Permanent bounces of email it sent"
          },
          "complaints": {
            "type": "integer",
            "description": "Spam complaints about email it sent"
          },
          "suspended": {
            "type": "boolean"
          },
          "sending_paused": {
            "type": "boolean"
          }
        }
      },
      "UsageReport": {
        "type": "object",
        "properties": {
          "month": {
            "type": "string",
            "example": "2026-11"
          },
          "accounts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CustomerUsage"
            }
          },
          "totals": {
            "type": "object",
            "properties": {
              "customers": {
                "type": "integer"
              },
              "mailboxes": {
                "type": "integer"
              },
              "domains": {
                "type": "integer"
              },
              "emails": {
                "type": "integer"
              },
              "received": {
                "type": "integer"
              },
              "sent": {
                "type": "integer"
              },
              "over_limit_emails": {
                "type": "integer"
              },
              "refused_emails": {
                "type": "integer"
              },
              "bounces": {
                "type": "integer"
              },
              "complaints": {
                "type": "integer"
              }
            }
          },
          "wholesale": {
            "type": "object",
            "description": "Your own plan this period: what it includes and what it costs beyond its price so far",
            "properties": {
              "plan": {
                "type": "string"
              },
              "interval": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "period_start": {
                "type": "string",
                "format": "date-time"
              },
              "period_end": {
                "type": "string",
                "format": "date-time"
              },
              "emails": {
                "type": "object"
              },
              "mailboxes": {
                "type": [
                  "object",
                  "null"
                ]
              },
              "extra_emails_cost_pence": {
                "type": "integer"
              },
              "extra_mailboxes_cost_pence": {
                "type": "integer"
              }
            }
          }
        }
      }
    },
    "parameters": {
      "AccountHeader": {
        "name": "Email-Parser-Account",
        "in": "header",
        "required": false,
        "schema": {
          "type": "string"
        },
        "description": "Resellers: act on one of your sub-accounts (acct_…). Needs a key with the accounts permission; the request then uses the key's other permissions on that sub-account."
      }
    }
  }
}