{
  "openapi": "3.1.0",
  "info": {
    "title": "mailbot API",
    "version": "0.1.0",
    "description": "mailbot API provides email API and MCP server for AI agents, including inbox lifecycle management, inbound and outbound messaging, webhook delivery, compliance checks, audit logs, and usage reporting.\n"
  },
  "servers": [
    {
      "url": "https://getmail.bot/v1"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "Auth"
    },
    {
      "name": "Account"
    },
    {
      "name": "API Keys"
    },
    {
      "name": "Inboxes"
    },
    {
      "name": "Domains"
    },
    {
      "name": "Messages"
    },
    {
      "name": "Threads"
    },
    {
      "name": "Webhooks"
    },
    {
      "name": "Engagement"
    },
    {
      "name": "Compliance"
    },
    {
      "name": "Audit"
    },
    {
      "name": "Usage"
    },
    {
      "name": "Product"
    }
  ],
  "paths": {
    "/product/manifest": {
      "get": {
        "tags": [
          "Product"
        ],
        "summary": "Get the public price and limit manifest",
        "operationId": "getProductManifest",
        "security": [],
        "responses": {
          "200": {
            "description": "Canonical public plans, prices, limits, and billing-unit definition",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/ProductManifest"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/auth/signup": {
      "post": {
        "tags": [
          "Auth"
        ],
        "summary": "Request signup verification code",
        "operationId": "requestSignupCode",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AuthSignupRequest"
              },
              "examples": {
                "default": {
                  "value": {
                    "name": "Yopie",
                    "email": "yopie@example.com"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Verification code sent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthSignupResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/auth/verify": {
      "post": {
        "tags": [
          "Auth"
        ],
        "summary": "Verify signup code and create account",
        "operationId": "verifySignupCode",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AuthVerifyRequest"
              },
              "examples": {
                "default": {
                  "value": {
                    "email": "yopie@example.com",
                    "code": "123456"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Account created after OTP verification",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthVerifyResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          }
        }
      }
    },
    "/account": {
      "get": {
        "tags": [
          "Account"
        ],
        "summary": "Get current account",
        "operationId": "getAccount",
        "responses": {
          "200": {
            "description": "Account detail",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      },
      "delete": {
        "tags": [
          "Account"
        ],
        "summary": "Delete current account",
        "operationId": "deleteAccount",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DeleteAccountRequest"
              },
              "examples": {
                "default": {
                  "value": {
                    "email": "yopie@example.com",
                    "confirmation": "DELETE"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Account deleted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteAccountResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/account/api-keys": {
      "post": {
        "tags": [
          "API Keys"
        ],
        "summary": "Create API key",
        "operationId": "createApiKey",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateApiKeyRequest"
              },
              "examples": {
                "default": {
                  "value": {
                    "name": "OpenClaw"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "API key created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateApiKeyResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      },
      "get": {
        "tags": [
          "API Keys"
        ],
        "summary": "List API keys",
        "operationId": "listApiKeys",
        "responses": {
          "200": {
            "description": "API key list",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiKeyListResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/account/api-keys/{keyId}": {
      "patch": {
        "tags": [
          "API Keys"
        ],
        "summary": "Update API key",
        "operationId": "updateApiKey",
        "parameters": [
          {
            "$ref": "#/components/parameters/ApiKeyId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateApiKeyRequest"
              },
              "examples": {
                "rename": {
                  "value": {
                    "name": "Production server",
                    "description": "Used by the production worker"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "API key updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiKeyResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "delete": {
        "tags": [
          "API Keys"
        ],
        "summary": "Delete API key",
        "operationId": "deleteApiKey",
        "parameters": [
          {
            "$ref": "#/components/parameters/ApiKeyId"
          }
        ],
        "responses": {
          "200": {
            "description": "API key deleted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteApiKeyResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/account/api-keys/{keyId}/rotate": {
      "post": {
        "tags": [
          "API Keys"
        ],
        "summary": "Rotate API key",
        "operationId": "rotateApiKey",
        "parameters": [
          {
            "$ref": "#/components/parameters/ApiKeyId"
          }
        ],
        "responses": {
          "200": {
            "description": "API key rotated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RotateApiKeyResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/domains": {
      "post": {
        "tags": [
          "Domains"
        ],
        "summary": "Create custom domain",
        "operationId": "createDomain",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateDomainRequest"
              },
              "examples": {
                "default": {
                  "value": {
                    "domain": "myapp.com"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Domain created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainResponse"
                },
                "examples": {
                  "default": {
                    "value": {
                      "data": {
                        "id": "dom_01hrz95d5ka2tpm19m0y7ex2tf",
                        "domain": "myapp.com",
                        "status": "pending",
                        "sync_status": "synced",
                        "sandbox_managed": false,
                        "spf_verified": false,
                        "dkim_verified": false,
                        "dmarc_verified": false,
                        "verified_at": null,
                        "last_check_at": null,
                        "created_at": "2026-03-20T08:20:00.000Z",
                        "updated_at": "2026-03-20T08:20:00.000Z",
                        "dns_records": [
                          {
                            "type": "TXT",
                            "host": "myapp.com",
                            "value": "v=spf1 include:_spf.example.com ~all",
                            "name": "SPF"
                          },
                          {
                            "type": "TXT",
                            "host": "mt1._domainkey.myapp.com",
                            "value": "v=DKIM1; k=rsa; p=MIIB...",
                            "name": "DKIM"
                          },
                          {
                            "type": "TXT",
                            "host": "_dmarc.myapp.com",
                            "value": "v=DMARC1; p=quarantine; rua=mailto:dmarc-reports@mailbot.id",
                            "name": "DMARC"
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          }
        }
      },
      "get": {
        "tags": [
          "Domains"
        ],
        "summary": "List domains",
        "operationId": "listDomains",
        "responses": {
          "200": {
            "description": "Domain list",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainListResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/domains/{id}": {
      "get": {
        "tags": [
          "Domains"
        ],
        "summary": "Get domain",
        "operationId": "getDomain",
        "parameters": [
          {
            "$ref": "#/components/parameters/DomainId"
          }
        ],
        "responses": {
          "200": {
            "description": "Domain detail",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DomainResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "delete": {
        "tags": [
          "Domains"
        ],
        "summary": "Delete domain",
        "operationId": "deleteDomain",
        "parameters": [
          {
            "$ref": "#/components/parameters/DomainId"
          }
        ],
        "responses": {
          "200": {
            "description": "Domain deleted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteDomainResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          }
        }
      }
    },
    "/domains/{id}/verify": {
      "post": {
        "tags": [
          "Domains"
        ],
        "summary": "Verify domain DNS",
        "operationId": "verifyDomain",
        "description": "Re-run DNS verification for a custom domain. Use after publishing\nthe SPF, DKIM, and DMARC records mailbot supplied.\n\n## Related\n\n- Concepts: [Domain compliance](/docs/compliance)\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/DomainId"
          }
        ],
        "responses": {
          "200": {
            "description": "Domain verification result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VerifyDomainResponse"
                },
                "examples": {
                  "default": {
                    "value": {
                      "data": {
                        "id": "dom_01hrz95d5ka2tpm19m0y7ex2tf",
                        "domain": "myapp.com",
                        "status": "dns_configured",
                        "sync_status": "synced",
                        "sandbox_managed": false,
                        "spf_verified": true,
                        "dkim_verified": false,
                        "dmarc_verified": true,
                        "verified_at": null,
                        "last_check_at": "2026-03-20T08:35:00.000Z",
                        "created_at": "2026-03-20T08:20:00.000Z",
                        "updated_at": "2026-03-20T08:35:00.000Z",
                        "dns_records": [
                          {
                            "type": "TXT",
                            "host": "myapp.com",
                            "value": "v=spf1 include:_spf.example.com ~all",
                            "name": "SPF"
                          },
                          {
                            "type": "TXT",
                            "host": "mt1._domainkey.myapp.com",
                            "value": "v=DKIM1; k=rsa; p=MIIB...",
                            "name": "DKIM"
                          },
                          {
                            "type": "TXT",
                            "host": "_dmarc.myapp.com",
                            "value": "v=DMARC1; p=quarantine; rua=mailto:dmarc-reports@mailbot.id",
                            "name": "DMARC"
                          }
                        ]
                      },
                      "next_step": "DKIM record is still missing. Check that you published the correct TXT record and wait for DNS propagation, then verify again."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/inboxes": {
      "post": {
        "tags": [
          "Inboxes"
        ],
        "summary": "Create inbox",
        "operationId": "createInbox",
        "description": "Provision a new inbox. Sandbox inboxes get an address on `mailbot.id`\nautomatically; custom-domain inboxes require a verified domain.\n\n## Related\n\n- Concepts: [Inboxes](/docs/concepts/inboxes-model)\n- Guides: [Email QA pipeline](/docs/guides/email-qa-pipeline)\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateInboxRequest"
              },
              "examples": {
                "default": {
                  "value": {
                    "username": "support-bot",
                    "display_name": "Support Bot",
                    "domain": "mailbot.id",
                    "daily_send_limit": 250,
                    "permissions": [
                      "send",
                      "receive",
                      "search"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Inbox created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InboxResponse"
                },
                "examples": {
                  "default": {
                    "value": {
                      "data": {
                        "id": "inbox_01hrz7nq9mvy7a6d2x2g8n3m4b",
                        "account_id": "acct_01hrz7j8j7v2yqq0fvfq1s3hdb",
                        "address": "support-bot--abc123@mailbot.id",
                        "username": "support-bot",
                        "display_name": "Support Bot",
                        "domain": "mailbot.id",
                        "status": "active",
                        "permissions": [
                          "send",
                          "receive",
                          "search"
                        ],
                        "daily_send_limit": 250,
                        "sends_today": 0,
                        "created_at": "2026-03-11T08:00:00.000Z"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          }
        }
      },
      "get": {
        "tags": [
          "Inboxes"
        ],
        "summary": "List inboxes",
        "operationId": "listInboxes",
        "description": "List inboxes on your account. Returns sandbox and custom-domain inboxes\ntogether; filter client-side by `domain` if you need only one kind.\n\n## Related\n\n- Concepts: [Inboxes](/docs/concepts/inboxes-model)\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/StatusQuery"
          },
          {
            "$ref": "#/components/parameters/PageQuery"
          },
          {
            "$ref": "#/components/parameters/LimitQuery"
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated inbox list",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InboxListResponse"
                },
                "examples": {
                  "default": {
                    "value": {
                      "data": [
                        {
                          "id": "inbox_01hrz7nq9mvy7a6d2x2g8n3m4b",
                          "account_id": "acct_01hrz7j8j7v2yqq0fvfq1s3hdb",
                          "address": "support-bot--abc123@mailbot.id",
                          "username": "support-bot",
                          "display_name": "Support Bot",
                          "domain": "mailbot.id",
                          "status": "active",
                          "permissions": [
                            "send",
                            "receive",
                            "search"
                          ],
                          "daily_send_limit": 250,
                          "sends_today": 12,
                          "created_at": "2026-03-11T08:00:00.000Z"
                        }
                      ],
                      "meta": {
                        "page": 1,
                        "limit": 20,
                        "total": 1
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/inboxes/{id}": {
      "get": {
        "tags": [
          "Inboxes"
        ],
        "summary": "Get inbox",
        "operationId": "getInbox",
        "description": "Fetch a single inbox by ID. Includes current usage, daily send limit,\nand sandbox metadata when applicable.\n\n## Related\n\n- Concepts: [Inboxes](/docs/concepts/inboxes-model)\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/InboxId"
          }
        ],
        "responses": {
          "200": {
            "description": "Inbox detail",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InboxResponse"
                },
                "examples": {
                  "default": {
                    "value": {
                      "data": {
                        "id": "inbox_01hrz7nq9mvy7a6d2x2g8n3m4b",
                        "account_id": "acct_01hrz7j8j7v2yqq0fvfq1s3hdb",
                        "address": "support-bot--abc123@mailbot.id",
                        "username": "support-bot",
                        "display_name": "Support Bot",
                        "domain": "mailbot.id",
                        "status": "active",
                        "permissions": [
                          "send",
                          "receive",
                          "search"
                        ],
                        "daily_send_limit": 250,
                        "sends_today": 12,
                        "created_at": "2026-03-11T08:00:00.000Z"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "patch": {
        "tags": [
          "Inboxes"
        ],
        "summary": "Update inbox",
        "operationId": "updateInbox",
        "parameters": [
          {
            "$ref": "#/components/parameters/InboxId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateInboxRequest"
              },
              "examples": {
                "display_name": {
                  "value": {
                    "display_name": "Support Bot"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Inbox updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InboxResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "delete": {
        "tags": [
          "Inboxes"
        ],
        "summary": "Disable inbox",
        "operationId": "deleteInbox",
        "description": "Soft-delete (disable) an inbox. The inbox can no longer send or\nreceive, but its message history and audit trail are preserved.\n\n## Related\n\n- Concepts: [Inboxes](/docs/concepts/inboxes-model)\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/InboxId"
          }
        ],
        "responses": {
          "200": {
            "description": "Inbox disabled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InboxStatusResponse"
                },
                "examples": {
                  "default": {
                    "value": {
                      "data": {
                        "id": "inbox_01hrz7nq9mvy7a6d2x2g8n3m4b",
                        "status": "disabled"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/inboxes/{id}/messages": {
      "get": {
        "tags": [
          "Messages"
        ],
        "summary": "List inbox messages",
        "operationId": "listMessages",
        "description": "List messages in an inbox. Filter by direction (`inbound` /\n`outbound`), label, thread, or date range. Includes delivery status\nand reply context for each message.\n\n## Related\n\n- Concepts: [Threads and conversation context](/docs/concepts/threads-conversation-context)\n- Concepts: [Inboxes](/docs/concepts/inboxes-model)\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/InboxId"
          },
          {
            "$ref": "#/components/parameters/DirectionQuery"
          },
          {
            "$ref": "#/components/parameters/PageQuery"
          },
          {
            "$ref": "#/components/parameters/LimitQuery"
          },
          {
            "$ref": "#/components/parameters/LabelsQuery"
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated message list",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageListResponse"
                },
                "examples": {
                  "default": {
                    "value": {
                      "data": [
                        {
                          "id": "msg_01hrz8b47p66w8b6wk0f55c2xj",
                          "inbox_id": "inbox_01hrz7nq9mvy7a6d2x2g8n3m4b",
                          "thread_id": "thr_01hrz8b47p66w8b6wk0f55c2xk",
                          "message_id_header": "<5d19c983-1806-470d-a678-992f5dca2d72@mailbot.id>",
                          "in_reply_to": null,
                          "references_header": null,
                          "from_address": "customer@example.com",
                          "to_addresses": [
                            "support-bot--abc123@mailbot.id"
                          ],
                          "cc_addresses": [],
                          "bcc_addresses": [],
                          "subject": "Refund request",
                          "body_text": "Hello, I need help with a refund.",
                          "body_html": null,
                          "direction": "inbound",
                          "compliance_status": null,
                          "compliance_details": null,
                          "labels": [
                            "support",
                            "priority"
                          ],
                          "created_at": "2026-03-11T08:05:00.000Z"
                        }
                      ],
                      "meta": {
                        "page": 1,
                        "limit": 20,
                        "total": 1
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "post": {
        "tags": [
          "Messages"
        ],
        "summary": "Send message",
        "operationId": "sendMessage",
        "description": "Send an outbound message from an inbox. Supports plain text, HTML,\nscheduling, and per-message tracking flags. Omit attachments or pass an\nempty array; every nonempty array is denied before persistence,\nreservation, debit, or transport.\n\n## Related\n\n- Concepts: [Threads and conversation context](/docs/concepts/threads-conversation-context)\n- Concepts: [Event delivery model](/docs/concepts/event-delivery-model)\n- Guides: [Outbound with engagement awareness](/docs/guides/outbound-engagement)\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/InboxId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendMessageRequest"
              },
              "examples": {
                "default": {
                  "value": {
                    "to": [
                      "customer@example.com"
                    ],
                    "cc": [
                      "manager@example.com"
                    ],
                    "bcc": [
                      "archive@example.com"
                    ],
                    "subject": "Re: Refund request",
                    "body_text": "We have processed your refund.",
                    "body_html": "<p>We have processed your refund.</p>",
                    "tags": [
                      "support",
                      "refund"
                    ],
                    "send_at": "2026-05-02T22:30:00.000Z"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Message queued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SendMessageResponse"
                },
                "examples": {
                  "default": {
                    "value": {
                      "data": {
                        "id": "msg_01hrz8mym5g0py2xaxv6psgt9p",
                        "thread_id": "thr_01hrz8b47p66w8b6wk0f55c2xk",
                        "compliance_status": "passed",
                        "created_at": "2026-03-11T08:10:00.000Z",
                        "delivery_status": "scheduled",
                        "scheduled_at": "2026-05-02T22:30:00.000Z"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/inboxes/{id}/messages/{msgId}": {
      "get": {
        "tags": [
          "Messages"
        ],
        "summary": "Get message",
        "operationId": "getMessage",
        "parameters": [
          {
            "$ref": "#/components/parameters/InboxId"
          },
          {
            "$ref": "#/components/parameters/MessageId"
          }
        ],
        "responses": {
          "200": {
            "description": "Message detail",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageResponse"
                },
                "examples": {
                  "default": {
                    "value": {
                      "data": {
                        "id": "msg_01hrz8b47p66w8b6wk0f55c2xj",
                        "inbox_id": "inbox_01hrz7nq9mvy7a6d2x2g8n3m4b",
                        "thread_id": "thr_01hrz8b47p66w8b6wk0f55c2xk",
                        "message_id_header": "<5d19c983-1806-470d-a678-992f5dca2d72@mailbot.id>",
                        "in_reply_to": null,
                        "references_header": null,
                        "from_address": "customer@example.com",
                        "to_addresses": [
                          "support-bot--abc123@mailbot.id"
                        ],
                        "cc_addresses": [],
                        "bcc_addresses": [],
                        "subject": "Refund request",
                        "body_text": "Hello, I need help with a refund.",
                        "body_html": null,
                        "direction": "inbound",
                        "compliance_status": null,
                        "compliance_details": null,
                        "labels": [
                          "support",
                          "priority"
                        ],
                        "created_at": "2026-03-11T08:05:00.000Z"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/inboxes/{id}/messages/{msgId}/reply": {
      "post": {
        "tags": [
          "Messages"
        ],
        "summary": "Reply to message",
        "operationId": "replyMessage",
        "description": "Reply to an existing message. mailbot generates a new `Message-ID`,\nsets `In-Reply-To` and `References` headers, and attaches the reply\nto the same thread.\n\n## Related\n\n- Concepts: [Threads and conversation context](/docs/concepts/threads-conversation-context)\n- Guides: [Build support automation](/docs/guides/support-automation)\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/InboxId"
          },
          {
            "$ref": "#/components/parameters/MessageId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReplyMessageRequest"
              },
              "examples": {
                "default": {
                  "value": {
                    "body_text": "Thanks, your refund has been processed.",
                    "body_html": "<p>Thanks, your refund has been processed.</p>"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Reply created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageResponse"
                },
                "examples": {
                  "default": {
                    "value": {
                      "data": {
                        "id": "msg_01hrz8r6mwg8n7dq11mpsab88z",
                        "inbox_id": "inbox_01hrz7nq9mvy7a6d2x2g8n3m4b",
                        "thread_id": "thr_01hrz8b47p66w8b6wk0f55c2xk",
                        "message_id_header": "<13c25a86-fd90-44e4-bafd-cfc1e2ce7f1f@mailbot.id>",
                        "in_reply_to": "<5d19c983-1806-470d-a678-992f5dca2d72@mailbot.id>",
                        "references_header": "<5d19c983-1806-470d-a678-992f5dca2d72@mailbot.id>",
                        "from_address": "support-bot--abc123@mailbot.id",
                        "to_addresses": [
                          "customer@example.com"
                        ],
                        "cc_addresses": [],
                        "bcc_addresses": [],
                        "subject": "Re: Refund request",
                        "body_text": "Thanks, your refund has been processed.",
                        "body_html": "<p>Thanks, your refund has been processed.</p>",
                        "direction": "outbound",
                        "compliance_status": "passed",
                        "compliance_details": {
                          "spf": "pass",
                          "dkim": "pass",
                          "dmarc": "pass",
                          "content_class": "transactional",
                          "readiness_score": 100
                        },
                        "labels": [
                          "support"
                        ],
                        "created_at": "2026-03-11T08:12:00.000Z"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/messages/{msgId}/schedule": {
      "delete": {
        "tags": [
          "Messages"
        ],
        "summary": "Cancel a scheduled message",
        "operationId": "cancelScheduledMessage",
        "description": "Cancels a pending scheduled send by setting scheduled_error to cancelled. Repeating cancellation returns 200. Cancellation does not recall a message already handed to the provider; cancellation racing an active worker is not guaranteed.",
        "parameters": [
          {
            "$ref": "#/components/parameters/MessageId"
          }
        ],
        "responses": {
          "200": {
            "description": "Schedule cancelled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CancelScheduleResponse"
                }
              }
            }
          },
          "400": {
            "description": "MESSAGE_NOT_SCHEDULED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "API key is not permitted to access this inbox"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "SCHEDULE_ALREADY_SENT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Messages"
        ],
        "summary": "Reschedule a message",
        "operationId": "rescheduleMessage",
        "description": "Changes send_at to a future ISO timestamp with timezone offset. Clears the previous scheduled error, including cancelled, and enqueues the message again. A 503 means the new time was saved but queue insertion failed. Concurrent worker dispatch is not protected by a schedule revision in this version.",
        "parameters": [
          {
            "$ref": "#/components/parameters/MessageId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RescheduleMessageRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Schedule updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RescheduleMessageResponse"
                }
              }
            }
          },
          "400": {
            "description": "MESSAGE_NOT_SCHEDULED or INVALID_SEND_AT / schema validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "API key is not permitted to access this inbox"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "SCHEDULE_ALREADY_SENT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "503": {
            "description": "SCHEDULE_ENQUEUE_FAILED; scheduled_at was saved but enqueue failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/inboxes/{id}/messages/{msgId}/schedule": {
      "delete": {
        "tags": [
          "Messages"
        ],
        "summary": "Cancel a scheduled message",
        "operationId": "cancelScheduledMessageInInbox",
        "description": "Cancels a pending scheduled send by setting scheduled_error to cancelled. Repeating cancellation returns 200. Cancellation does not recall a message already handed to the provider; cancellation racing an active worker is not guaranteed.",
        "parameters": [
          {
            "$ref": "#/components/parameters/InboxId"
          },
          {
            "$ref": "#/components/parameters/MessageId"
          }
        ],
        "responses": {
          "200": {
            "description": "Schedule cancelled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CancelScheduleResponse"
                }
              }
            }
          },
          "400": {
            "description": "MESSAGE_NOT_SCHEDULED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "API key is not permitted to access this inbox"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "SCHEDULE_ALREADY_SENT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Messages"
        ],
        "summary": "Reschedule a message",
        "operationId": "rescheduleMessageInInbox",
        "description": "Changes send_at to a future ISO timestamp with timezone offset. Clears the previous scheduled error, including cancelled, and enqueues the message again. A 503 means the new time was saved but queue insertion failed. Concurrent worker dispatch is not protected by a schedule revision in this version.",
        "parameters": [
          {
            "$ref": "#/components/parameters/InboxId"
          },
          {
            "$ref": "#/components/parameters/MessageId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RescheduleMessageRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Schedule updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RescheduleMessageResponse"
                }
              }
            }
          },
          "400": {
            "description": "MESSAGE_NOT_SCHEDULED or INVALID_SEND_AT / schema validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "API key is not permitted to access this inbox"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "SCHEDULE_ALREADY_SENT",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "503": {
            "description": "SCHEDULE_ENQUEUE_FAILED; scheduled_at was saved but enqueue failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/inboxes/{id}/threads": {
      "get": {
        "tags": [
          "Threads"
        ],
        "summary": "List inbox threads",
        "operationId": "listThreads",
        "description": "List conversation threads in an inbox. A thread groups every message\nin a back-and-forth exchange under one stable `thread_id`.\n\n## Related\n\n- Concepts: [Threads and conversation context](/docs/concepts/threads-conversation-context)\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/InboxId"
          },
          {
            "$ref": "#/components/parameters/PageQuery"
          },
          {
            "$ref": "#/components/parameters/LimitQuery"
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated thread list",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ThreadListResponse"
                },
                "examples": {
                  "default": {
                    "value": {
                      "data": [
                        {
                          "id": "thr_01hrz8b47p66w8b6wk0f55c2xk",
                          "inbox_id": "inbox_01hrz7nq9mvy7a6d2x2g8n3m4b",
                          "subject": "Refund request",
                          "last_message_at": "2026-03-11T08:12:00.000Z",
                          "message_count": 2,
                          "labels": [
                            "support"
                          ],
                          "created_at": "2026-03-11T08:05:00.000Z"
                        }
                      ],
                      "meta": {
                        "page": 1,
                        "limit": 20,
                        "total": 1
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/inboxes/{id}/threads/{threadId}": {
      "get": {
        "tags": [
          "Threads"
        ],
        "summary": "Get thread",
        "operationId": "getThread",
        "description": "Fetch a thread with its full ordered message history. Use this when\nan agent needs context to draft a reply or summarize an exchange.\n\n## Related\n\n- Concepts: [Threads and conversation context](/docs/concepts/threads-conversation-context)\n- Guides: [Integrate with Claude Desktop via MCP](/docs/guides/claude-desktop-mcp)\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/InboxId"
          },
          {
            "$ref": "#/components/parameters/ThreadId"
          }
        ],
        "responses": {
          "200": {
            "description": "Thread detail",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ThreadResponse"
                },
                "examples": {
                  "default": {
                    "value": {
                      "data": {
                        "id": "thr_01hrz8b47p66w8b6wk0f55c2xk",
                        "inbox_id": "inbox_01hrz7nq9mvy7a6d2x2g8n3m4b",
                        "subject": "Refund request",
                        "last_message_at": "2026-03-11T08:12:00.000Z",
                        "message_count": 2,
                        "labels": [
                          "support"
                        ],
                        "created_at": "2026-03-11T08:05:00.000Z"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/inboxes/{id}/messages/search": {
      "post": {
        "tags": [
          "Messages"
        ],
        "summary": "Search messages",
        "operationId": "searchMessages",
        "parameters": [
          {
            "$ref": "#/components/parameters/InboxId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SearchMessagesRequest"
              },
              "examples": {
                "default": {
                  "value": {
                    "query": "refund processed",
                    "limit": 10
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Search results",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageListResponse"
                },
                "examples": {
                  "default": {
                    "value": {
                      "data": [
                        {
                          "id": "msg_01hrz8r6mwg8n7dq11mpsab88z",
                          "inbox_id": "inbox_01hrz7nq9mvy7a6d2x2g8n3m4b",
                          "thread_id": "thr_01hrz8b47p66w8b6wk0f55c2xk",
                          "message_id_header": "<13c25a86-fd90-44e4-bafd-cfc1e2ce7f1f@mailbot.id>",
                          "in_reply_to": "<5d19c983-1806-470d-a678-992f5dca2d72@mailbot.id>",
                          "references_header": "<5d19c983-1806-470d-a678-992f5dca2d72@mailbot.id>",
                          "from_address": "support-bot--abc123@mailbot.id",
                          "to_addresses": [
                            "customer@example.com"
                          ],
                          "cc_addresses": [],
                          "bcc_addresses": [],
                          "subject": "Re: Refund request",
                          "body_text": "Thanks, your refund has been processed.",
                          "body_html": "<p>Thanks, your refund has been processed.</p>",
                          "direction": "outbound",
                          "compliance_status": "passed",
                          "compliance_details": {
                            "spf": "pass",
                            "dkim": "pass",
                            "dmarc": "pass",
                            "content_class": "transactional",
                            "readiness_score": 100
                          },
                          "labels": [
                            "support"
                          ],
                          "created_at": "2026-03-11T08:12:00.000Z"
                        }
                      ],
                      "meta": {
                        "page": 1,
                        "limit": 10,
                        "total": 1
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/inboxes/{id}/messages/{msgId}/labels": {
      "put": {
        "tags": [
          "Messages"
        ],
        "summary": "Update message labels",
        "operationId": "updateMessageLabels",
        "parameters": [
          {
            "$ref": "#/components/parameters/InboxId"
          },
          {
            "$ref": "#/components/parameters/MessageId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateLabelsRequest"
              },
              "examples": {
                "default": {
                  "value": {
                    "labels": [
                      "support",
                      "resolved"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Labels updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageResponse"
                },
                "examples": {
                  "default": {
                    "value": {
                      "data": {
                        "id": "msg_01hrz8r6mwg8n7dq11mpsab88z",
                        "inbox_id": "inbox_01hrz7nq9mvy7a6d2x2g8n3m4b",
                        "thread_id": "thr_01hrz8b47p66w8b6wk0f55c2xk",
                        "message_id_header": "<13c25a86-fd90-44e4-bafd-cfc1e2ce7f1f@mailbot.id>",
                        "in_reply_to": "<5d19c983-1806-470d-a678-992f5dca2d72@mailbot.id>",
                        "references_header": "<5d19c983-1806-470d-a678-992f5dca2d72@mailbot.id>",
                        "from_address": "support-bot--abc123@mailbot.id",
                        "to_addresses": [
                          "customer@example.com"
                        ],
                        "cc_addresses": [],
                        "bcc_addresses": [],
                        "subject": "Re: Refund request",
                        "body_text": "Thanks, your refund has been processed.",
                        "body_html": "<p>Thanks, your refund has been processed.</p>",
                        "direction": "outbound",
                        "compliance_status": "passed",
                        "compliance_details": {
                          "spf": "pass",
                          "dkim": "pass",
                          "dmarc": "pass",
                          "content_class": "transactional",
                          "readiness_score": 100
                        },
                        "labels": [
                          "support",
                          "resolved"
                        ],
                        "created_at": "2026-03-11T08:12:00.000Z"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/webhooks": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Create webhook",
        "operationId": "createWebhook",
        "description": "Register a webhook destination on an inbox. mailbot will POST events\nyou subscribe to (`message.received`, `message.opened`, etc.) to your\nURL with an `X-mailbot-Signature` header.\n\n## Related\n\n- Concepts: [Event delivery model](/docs/concepts/event-delivery-model)\n- Operations: [Webhook reliability](/docs/operations/webhook-reliability)\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateWebhookRequest"
              },
              "examples": {
                "default": {
                  "value": {
                    "url": "https://agent.example.com/webhooks/engagement",
                    "events": [
                      "message.received",
                      "message.sent",
                      "compliance.failed"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Webhook created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookResponse"
                },
                "examples": {
                  "default": {
                    "value": {
                      "data": {
                        "id": "wh_01hrz95d5ka2tpm19m0y7ex2tf",
                        "account_id": "acct_01hrz7j8j7v2yqq0fvfq1s3hdb",
                        "url": "https://agent.example.com/webhooks/engagement",
                        "events": [
                          "message.received",
                          "message.sent",
                          "compliance.failed"
                        ],
                        "secret": "whsec_live_redacted",
                        "active": true,
                        "created_at": "2026-03-11T08:20:00.000Z"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      },
      "get": {
        "tags": [
          "Webhooks"
        ],
        "summary": "List webhooks",
        "operationId": "listWebhooks",
        "description": "List webhook destinations registered on an inbox.\n\n## Related\n\n- Concepts: [Event delivery model](/docs/concepts/event-delivery-model)\n- Operations: [Webhook reliability](/docs/operations/webhook-reliability)\n",
        "responses": {
          "200": {
            "description": "Webhook list",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookListResponse"
                },
                "examples": {
                  "default": {
                    "value": {
                      "data": [
                        {
                          "id": "wh_01hrz95d5ka2tpm19m0y7ex2tf",
                          "account_id": "acct_01hrz7j8j7v2yqq0fvfq1s3hdb",
                          "url": "https://agent.example.com/webhooks/engagement",
                          "events": [
                            "message.received",
                            "message.sent",
                            "compliance.failed"
                          ],
                          "secret": "whsec_live_redacted",
                          "active": true,
                          "created_at": "2026-03-11T08:20:00.000Z"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/webhooks/{id}": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Get webhook",
        "operationId": "getWebhook",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookId"
          }
        ],
        "responses": {
          "200": {
            "description": "Webhook detail",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "patch": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Update webhook",
        "operationId": "updateWebhook",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateWebhookRequest"
              },
              "examples": {
                "pause": {
                  "value": {
                    "active": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Webhook updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "delete": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Delete webhook",
        "operationId": "deleteWebhook",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookId"
          }
        ],
        "responses": {
          "200": {
            "description": "Webhook deleted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteWebhookResponse"
                },
                "examples": {
                  "default": {
                    "value": {
                      "data": {
                        "id": "wh_01hrz95d5ka2tpm19m0y7ex2tf",
                        "deleted": true
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/webhooks/{id}/test": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Test webhook",
        "operationId": "testWebhook",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookId"
          }
        ],
        "responses": {
          "200": {
            "description": "Webhook test result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookTestResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/engagement/events": {
      "get": {
        "tags": [
          "Engagement"
        ],
        "summary": "List engagement events",
        "operationId": "listEngagementEvents",
        "description": "List delivery and engagement events on an inbox: sent, delivered,\nopened, clicked, bounced, received, parsed. Filter by `event_type`,\n`message_id`, or time window.\n\n## Related\n\n- Concepts: [Event delivery model](/docs/concepts/event-delivery-model)\n- Concepts: [Replay mechanics](/docs/concepts/replay-mechanics)\n- Operations: [Event replay troubleshooting](/docs/operations/event-replay-troubleshooting)\n",
        "parameters": [
          {
            "name": "inbox_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "event",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "delivered",
                "opened",
                "clicked",
                "bounced",
                "complained"
              ]
            }
          },
          {
            "$ref": "#/components/parameters/PageQuery"
          },
          {
            "$ref": "#/components/parameters/LimitQuery"
          }
        ],
        "responses": {
          "200": {
            "description": "Engagement event list",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EngagementEventListResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/engagement/stats": {
      "get": {
        "tags": [
          "Engagement"
        ],
        "summary": "Get engagement summary stats",
        "operationId": "getEngagementStats",
        "description": "Roll-up engagement stats for an inbox: delivery rate, open rate,\nclick rate, bounce rate, complaint rate. Use to monitor sender\nhealth.\n\n## Related\n\n- Operations: [Deliverability monitoring](/docs/operations/deliverability-monitoring)\n- Guides: [Outbound with engagement awareness](/docs/guides/outbound-engagement)\n",
        "parameters": [
          {
            "name": "inbox_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "period",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "24h",
                "7d",
                "30d"
              ],
              "default": "7d"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Engagement summary",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EngagementStatsResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/engagement/messages/{messageId}": {
      "get": {
        "tags": [
          "Engagement"
        ],
        "summary": "Get engagement events for one message",
        "operationId": "getMessageEngagement",
        "description": "Per-message engagement timeline: ordered list of every event on a\nsingle message (delivered, opened with count, clicked with count,\nbounced).\n\n## Related\n\n- Concepts: [Event delivery model](/docs/concepts/event-delivery-model)\n- Guides: [Outbound with engagement awareness](/docs/guides/outbound-engagement)\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/EngagementMessageId"
          }
        ],
        "responses": {
          "200": {
            "description": "Message engagement detail",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageEngagementResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/compliance/check": {
      "get": {
        "tags": [
          "Compliance"
        ],
        "summary": "Check domain compliance",
        "operationId": "checkCompliance",
        "description": "Run a live DNS lookup for SPF, DKIM, DMARC, and MX records on a\ncustom domain. Returns the per-record state plus actionable\nrecommendations when something is missing.\n\n## Related\n\n- Concepts: [Domain compliance](/docs/compliance)\n- Operations: [Deliverability monitoring](/docs/operations/deliverability-monitoring)\n",
        "parameters": [
          {
            "name": "domain",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "hostname"
            },
            "example": "example.com"
          }
        ],
        "responses": {
          "200": {
            "description": "Compliance result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ComplianceCheckResponse"
                },
                "examples": {
                  "default": {
                    "value": {
                      "data": {
                        "spf": "pass",
                        "dkim": "pass",
                        "dmarc": "pass",
                        "content_class": "transactional",
                        "readiness_score": 100
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/compliance/readiness/{inboxId}": {
      "get": {
        "tags": [
          "Compliance"
        ],
        "summary": "Get inbox readiness score",
        "operationId": "getReadiness",
        "description": "Get the readiness score (0–100) for a custom domain. The score rolls\nup DNS authentication, bounce posture, volume profile, and tracking\nhealth into a single number.\n\n## Related\n\n- Concepts: [Domain compliance](/docs/compliance)\n- Operations: [Deliverability monitoring](/docs/operations/deliverability-monitoring)\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/InboxIdReadiness"
          }
        ],
        "responses": {
          "200": {
            "description": "Readiness score",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReadinessResponse"
                },
                "examples": {
                  "default": {
                    "value": {
                      "data": {
                        "inbox_id": "inbox_01hrz7nq9mvy7a6d2x2g8n3m4b",
                        "domain": "mailbot.id",
                        "score": 92,
                        "checks": {
                          "spf": "pass",
                          "dkim": "pass",
                          "dmarc": "pass",
                          "sending_domain_verified": true,
                          "warmup_ready": false
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/audit-log": {
      "get": {
        "tags": [
          "Audit"
        ],
        "summary": "List audit log entries",
        "operationId": "listAuditLog",
        "description": "Audit log: every authentication event, inbox lifecycle change,\ndomain action, message action, replay attempt, and webhook\nconfiguration change, scoped to your account.\n\n## Related\n\n- Concepts: [Replay mechanics](/docs/concepts/replay-mechanics)\n- Operations: [Event replay troubleshooting](/docs/operations/event-replay-troubleshooting)\n",
        "parameters": [
          {
            "$ref": "#/components/parameters/PageQuery"
          },
          {
            "$ref": "#/components/parameters/LimitQuery"
          },
          {
            "name": "inbox_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "inbox_01hrz7nq9mvy7a6d2x2g8n3m4b"
          },
          {
            "name": "action",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "message.sent"
          },
          {
            "name": "start_date",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "example": "2026-03-01T00:00:00.000Z"
          },
          {
            "name": "end_date",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "example": "2026-03-31T23:59:59.999Z"
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated audit log",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuditLogListResponse"
                },
                "examples": {
                  "default": {
                    "value": {
                      "data": [
                        {
                          "id": "audit_01hrz9bz3p7kk5w19f1q1b8s8v",
                          "account_id": "acct_01hrz7j8j7v2yqq0fvfq1s3hdb",
                          "inbox_id": "inbox_01hrz7nq9mvy7a6d2x2g8n3m4b",
                          "action": "message.sent",
                          "details_json": {
                            "message_id": "msg_01hrz8r6mwg8n7dq11mpsab88z"
                          },
                          "compliance_result": {
                            "spf": "pass",
                            "dkim": "pass",
                            "dmarc": "pass"
                          },
                          "ip_address": "203.0.113.42",
                          "created_at": "2026-03-11T08:12:01.000Z"
                        }
                      ],
                      "meta": {
                        "page": 1,
                        "limit": 20,
                        "total": 1
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/usage": {
      "get": {
        "tags": [
          "Usage"
        ],
        "summary": "Get usage summary",
        "operationId": "getUsage",
        "parameters": [
          {
            "name": "period",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "day",
                "week",
                "month"
              ],
              "default": "month"
            },
            "example": "month"
          }
        ],
        "responses": {
          "200": {
            "description": "Usage summary",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UsageResponse"
                },
                "examples": {
                  "default": {
                    "value": {
                      "data": {
                        "account_id": "acct_01hrz7j8j7v2yqq0fvfq1s3hdb",
                        "period": "month",
                        "inbox_count": 2,
                        "inbound_messages": 482,
                        "outbound_messages": 197,
                        "webhooks_delivered": 129,
                        "compliance_failures": 4,
                        "quota": {
                          "plan": "growth",
                          "daily_send_limit": 1000,
                          "sends_today": 197
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/usage/daily": {
      "get": {
        "tags": [
          "Usage"
        ],
        "summary": "Get daily usage breakdown",
        "operationId": "getDailyUsage",
        "parameters": [
          {
            "name": "days",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 90,
              "default": 7
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Daily usage series",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UsageDailyResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/message-approvals": {
      "get": {
        "tags": [
          "Messages"
        ],
        "summary": "List messages awaiting approval",
        "operationId": "listMessageApprovals",
        "responses": {
          "200": {
            "description": "Pending approval drafts for the authenticated tenant"
          }
        }
      }
    },
    "/message-approvals/{messageId}": {
      "parameters": [
        {
          "name": "messageId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        }
      ],
      "get": {
        "tags": [
          "Messages"
        ],
        "summary": "Read an approval draft",
        "operationId": "getMessageApproval",
        "responses": {
          "200": {
            "description": "Approval draft"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/message-approvals/{messageId}/approve": {
      "parameters": [
        {
          "name": "messageId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        },
        {
          "name": "Idempotency-Key",
          "in": "header",
          "required": true,
          "schema": {
            "type": "string",
            "minLength": 8,
            "maxLength": 255
          }
        }
      ],
      "post": {
        "tags": [
          "Messages"
        ],
        "summary": "Approve and dispatch a draft",
        "operationId": "approveMessage",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ApprovalDecisionRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Decision accepted; provider outcome is included when known"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          }
        }
      }
    },
    "/message-approvals/{messageId}/reject": {
      "parameters": [
        {
          "name": "messageId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          }
        },
        {
          "name": "Idempotency-Key",
          "in": "header",
          "required": true,
          "schema": {
            "type": "string",
            "minLength": 8,
            "maxLength": 255
          }
        }
      ],
      "post": {
        "tags": [
          "Messages"
        ],
        "summary": "Reject a draft",
        "operationId": "rejectMessage",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ApprovalDecisionRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Draft rejected without provider delivery"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          }
        }
      }
    },
    "/messages/{messageId}/status-history": {
      "get": {
        "tags": [
          "Messages"
        ],
        "summary": "Read durable message delivery history",
        "operationId": "getMessageStatusHistory",
        "parameters": [
          {
            "name": "messageId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Up to 100 chronological status records"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "API Key",
        "description": "Bearer token carrying a mailbot API key."
      }
    },
    "parameters": {
      "InboxId": {
        "name": "id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        },
        "example": "inbox_01hrz7nq9mvy7a6d2x2g8n3m4b"
      },
      "InboxIdReadiness": {
        "name": "inboxId",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        },
        "example": "inbox_01hrz7nq9mvy7a6d2x2g8n3m4b"
      },
      "MessageId": {
        "name": "msgId",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        },
        "example": "msg_01hrz8b47p66w8b6wk0f55c2xj"
      },
      "ThreadId": {
        "name": "threadId",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        },
        "example": "thr_01hrz8b47p66w8b6wk0f55c2xk"
      },
      "WebhookId": {
        "name": "id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        },
        "example": "wh_01hrz95d5ka2tpm19m0y7ex2tf"
      },
      "ApiKeyId": {
        "name": "keyId",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        },
        "example": "key_01hrz95d5ka2tpm19m0y7ex2tf"
      },
      "DomainId": {
        "name": "id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        },
        "example": "dom_01hrz95d5ka2tpm19m0y7ex2tf"
      },
      "EngagementMessageId": {
        "name": "messageId",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        },
        "example": "msg_01hrz8b47p66w8b6wk0f55c2xj"
      },
      "StatusQuery": {
        "name": "status",
        "in": "query",
        "required": false,
        "schema": {
          "$ref": "#/components/schemas/InboxStatus"
        },
        "example": "active"
      },
      "DirectionQuery": {
        "name": "direction",
        "in": "query",
        "required": false,
        "schema": {
          "$ref": "#/components/schemas/Direction"
        },
        "example": "inbound"
      },
      "LabelsQuery": {
        "name": "labels",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string"
        },
        "example": "support,resolved"
      },
      "PageQuery": {
        "name": "page",
        "in": "query",
        "required": false,
        "schema": {
          "type": "integer",
          "minimum": 1,
          "default": 1
        },
        "example": 1
      },
      "LimitQuery": {
        "name": "limit",
        "in": "query",
        "required": false,
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100,
          "default": 20
        },
        "example": 20
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Bad request",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            },
            "examples": {
              "default": {
                "value": {
                  "error": {
                    "code": "invalid_request",
                    "message": "Request validation failed.",
                    "details": {
                      "field": "username"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Unauthorized",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            },
            "examples": {
              "default": {
                "value": {
                  "error": {
                    "code": "unauthorized",
                    "message": "Invalid API key."
                  }
                }
              }
            }
          }
        }
      },
      "Forbidden": {
        "description": "Forbidden",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            },
            "examples": {
              "default": {
                "value": {
                  "error": {
                    "code": "forbidden",
                    "message": "Inbox is disabled or key lacks permissions."
                  }
                }
              }
            }
          }
        }
      },
      "NotFound": {
        "description": "Not found",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            },
            "examples": {
              "default": {
                "value": {
                  "error": {
                    "code": "not_found",
                    "message": "Resource not found."
                  }
                }
              }
            }
          }
        }
      },
      "Conflict": {
        "description": "Conflict",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            },
            "examples": {
              "default": {
                "value": {
                  "error": {
                    "code": "conflict",
                    "message": "Username already exists."
                  }
                }
              }
            }
          }
        }
      },
      "RateLimited": {
        "description": "Rate limit exceeded",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            },
            "examples": {
              "default": {
                "value": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Daily send limit exceeded."
                  }
                }
              }
            }
          }
        }
      }
    },
    "schemas": {
      "ProductManifest": {
        "type": "object",
        "required": [
          "version",
          "billing",
          "plans",
          "capabilities"
        ],
        "properties": {
          "version": {
            "type": "string",
            "example": "2026-11-03"
          },
          "billing": {
            "type": "object",
            "required": [
              "unit",
              "counts",
              "excludes"
            ],
            "properties": {
              "unit": {
                "type": "string",
                "const": "outbound_recipient_delivery"
              },
              "counts": {
                "type": "string"
              },
              "excludes": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          },
          "plans": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "id",
                "currency",
                "prices",
                "limits"
              ],
              "properties": {
                "id": {
                  "type": "string",
                  "enum": [
                    "sandbox",
                    "builder",
                    "growth"
                  ]
                },
                "currency": {
                  "type": "string",
                  "const": "USD"
                },
                "prices": {
                  "type": "object",
                  "required": [
                    "monthly_cents",
                    "annual_cents"
                  ],
                  "properties": {
                    "monthly_cents": {
                      "type": "integer",
                      "minimum": 0
                    },
                    "annual_cents": {
                      "type": "integer",
                      "minimum": 0
                    }
                  }
                },
                "limits": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "integer",
                    "minimum": 0
                  }
                }
              }
            }
          },
          "capabilities": {
            "type": "object",
            "additionalProperties": {
              "type": "string",
              "enum": [
                "included"
              ]
            }
          }
        }
      },
      "ApprovalDecisionRequest": {
        "type": "object",
        "properties": {
          "reason": {
            "type": "string",
            "maxLength": 1000
          }
        }
      },
      "DeliveryState": {
        "type": "string",
        "enum": [
          "accepted",
          "provider_accepted",
          "delivered",
          "rejected",
          "bounced",
          "unknown"
        ]
      },
      "Plan": {
        "type": "string",
        "enum": [
          "sandbox",
          "builder",
          "growth",
          "enterprise",
          "custom",
          "free"
        ],
        "description": "Current plans are sandbox, builder, growth, enterprise and custom. The free value may appear on legacy accounts."
      },
      "InboxStatus": {
        "type": "string",
        "enum": [
          "active",
          "disabled",
          "suspended"
        ]
      },
      "Direction": {
        "type": "string",
        "enum": [
          "inbound",
          "outbound"
        ]
      },
      "ComplianceStatus": {
        "type": "string",
        "enum": [
          "passed",
          "failed",
          "skipped"
        ]
      },
      "InboxPermission": {
        "type": "string",
        "enum": [
          "send",
          "receive",
          "search"
        ]
      },
      "WebhookEvent": {
        "type": "string",
        "enum": [
          "message.received",
          "message.sent",
          "message.bounced",
          "message.complained",
          "message.scheduled_cancelled",
          "compliance.failed",
          "inbox.created"
        ]
      },
      "Account": {
        "type": "object",
        "required": [
          "id",
          "name",
          "email",
          "plan",
          "created_at",
          "updated_at"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "plan": {
            "$ref": "#/components/schemas/Plan"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ApiKey": {
        "type": "object",
        "required": [
          "id",
          "account_id",
          "key_prefix",
          "name",
          "permissions",
          "last_used_at",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "account_id": {
            "type": "string"
          },
          "key_prefix": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "permissions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "last_used_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "PublicAccount": {
        "type": "object",
        "required": [
          "id",
          "name",
          "email",
          "plan",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "plan": {
            "$ref": "#/components/schemas/Plan"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "PublicApiKey": {
        "type": "object",
        "required": [
          "id",
          "name",
          "key_prefix",
          "permissions",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": [
              "string",
              "null"
            ]
          },
          "key_prefix": {
            "type": "string"
          },
          "permissions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "last_used_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "SandboxProvisioning": {
        "type": "object",
        "required": [
          "domain",
          "account_short_id",
          "address_pattern",
          "daily_send_limit",
          "burst_limit_per_minute",
          "next_step"
        ],
        "properties": {
          "domain": {
            "type": "string"
          },
          "account_short_id": {
            "type": "string"
          },
          "address_pattern": {
            "type": "string"
          },
          "daily_send_limit": {
            "type": "integer"
          },
          "burst_limit_per_minute": {
            "type": "integer"
          },
          "next_step": {
            "type": "string"
          }
        }
      },
      "EngagementEvent": {
        "type": "object",
        "required": [
          "id",
          "account_id",
          "event",
          "recipient",
          "timestamp",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "account_id": {
            "type": "string"
          },
          "inbox_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "message_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "transmission_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "event": {
            "type": "string"
          },
          "recipient": {
            "type": "string",
            "format": "email"
          },
          "timestamp": {
            "type": "string",
            "format": "date-time"
          },
          "url": {
            "anyOf": [
              {
                "type": "string",
                "format": "uri"
              },
              {
                "type": "null"
              }
            ]
          },
          "ip": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "user_agent": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "bounce_type": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "bounce_code": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "bounce_reason": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "feedback_type": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "thread_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "raw_payload": {
            "anyOf": [
              {
                "type": "object",
                "additionalProperties": true
              },
              {
                "type": "null"
              }
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "DomainSyncStatus": {
        "type": "string",
        "enum": [
          "synced",
          "pending_sync",
          "local_only"
        ]
      },
      "DomainDnsRecord": {
        "type": "object",
        "required": [
          "type",
          "host",
          "value",
          "name"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "TXT"
            ]
          },
          "host": {
            "type": "string"
          },
          "value": {
            "type": "string"
          },
          "name": {
            "type": "string",
            "enum": [
              "SPF",
              "DKIM",
              "DMARC"
            ]
          }
        }
      },
      "Domain": {
        "type": "object",
        "required": [
          "id",
          "domain",
          "status",
          "sync_status",
          "sandbox_managed",
          "spf_verified",
          "dkim_verified",
          "dmarc_verified",
          "verified_at",
          "last_check_at",
          "created_at",
          "updated_at",
          "dns_records"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "domain": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "dns_configured",
              "verified",
              "active",
              "failed"
            ]
          },
          "sync_status": {
            "$ref": "#/components/schemas/DomainSyncStatus"
          },
          "sandbox_managed": {
            "type": "boolean"
          },
          "spf_verified": {
            "type": "boolean"
          },
          "dkim_verified": {
            "type": "boolean"
          },
          "dmarc_verified": {
            "type": "boolean"
          },
          "verified_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "last_check_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "dns_records": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DomainDnsRecord"
            }
          }
        }
      },
      "Inbox": {
        "type": "object",
        "required": [
          "id",
          "account_id",
          "address",
          "username",
          "display_name",
          "domain",
          "status",
          "permissions",
          "daily_send_limit",
          "sends_today",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "account_id": {
            "type": "string"
          },
          "address": {
            "type": "string",
            "format": "email"
          },
          "username": {
            "type": "string"
          },
          "display_name": {
            "type": "string"
          },
          "domain": {
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/InboxStatus"
          },
          "permissions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InboxPermission"
            }
          },
          "daily_send_limit": {
            "type": "integer"
          },
          "sends_today": {
            "type": "integer"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Thread": {
        "type": "object",
        "required": [
          "id",
          "inbox_id",
          "subject",
          "last_message_at",
          "message_count",
          "labels",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "inbox_id": {
            "type": "string"
          },
          "subject": {
            "type": "string"
          },
          "last_message_at": {
            "type": "string",
            "format": "date-time"
          },
          "message_count": {
            "type": "integer"
          },
          "labels": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "scheduled_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "scheduled_sent_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "scheduled_cancelled_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "scheduled_error": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ComplianceDetails": {
        "type": "object",
        "required": [
          "spf",
          "dkim",
          "dmarc",
          "content_class",
          "readiness_score"
        ],
        "properties": {
          "spf": {
            "type": "string",
            "enum": [
              "pass",
              "fail",
              "none"
            ]
          },
          "dkim": {
            "type": "string",
            "enum": [
              "pass",
              "fail",
              "none"
            ]
          },
          "dmarc": {
            "type": "string",
            "enum": [
              "pass",
              "fail",
              "none"
            ]
          },
          "content_class": {
            "type": "string",
            "enum": [
              "transactional",
              "promotional",
              "unknown"
            ]
          },
          "readiness_score": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100
          },
          "blocked_reasons": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "Message": {
        "type": "object",
        "required": [
          "id",
          "inbox_id",
          "thread_id",
          "message_id_header",
          "in_reply_to",
          "references_header",
          "from_address",
          "to_addresses",
          "cc_addresses",
          "bcc_addresses",
          "subject",
          "body_text",
          "body_html",
          "direction",
          "compliance_status",
          "compliance_details",
          "labels",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "inbox_id": {
            "type": "string"
          },
          "thread_id": {
            "type": "string"
          },
          "message_id_header": {
            "type": "string"
          },
          "in_reply_to": {
            "type": [
              "string",
              "null"
            ]
          },
          "references_header": {
            "type": [
              "string",
              "null"
            ]
          },
          "from_address": {
            "type": "string",
            "format": "email"
          },
          "to_addresses": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "email"
            }
          },
          "cc_addresses": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "email"
            }
          },
          "bcc_addresses": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "email"
            }
          },
          "subject": {
            "type": "string"
          },
          "body_text": {
            "type": "string"
          },
          "body_html": {
            "type": [
              "string",
              "null"
            ]
          },
          "direction": {
            "$ref": "#/components/schemas/Direction"
          },
          "compliance_status": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ComplianceStatus"
              },
              {
                "type": "null"
              }
            ]
          },
          "compliance_details": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ComplianceDetails"
              },
              {
                "type": "null"
              }
            ]
          },
          "labels": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Attachment": {
        "type": "object",
        "required": [
          "id",
          "message_id",
          "filename",
          "content_type",
          "size",
          "storage_path",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "message_id": {
            "type": "string"
          },
          "filename": {
            "type": "string"
          },
          "content_type": {
            "type": "string"
          },
          "size": {
            "type": "integer"
          },
          "storage_path": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Webhook": {
        "type": "object",
        "required": [
          "id",
          "account_id",
          "url",
          "events",
          "secret",
          "active",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "account_id": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WebhookEvent"
            }
          },
          "secret": {
            "type": "string"
          },
          "active": {
            "type": "boolean"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "AuditLogEntry": {
        "type": "object",
        "required": [
          "id",
          "account_id",
          "inbox_id",
          "action",
          "details_json",
          "compliance_result",
          "ip_address",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "account_id": {
            "type": "string"
          },
          "inbox_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "action": {
            "type": "string"
          },
          "details_json": {
            "type": "object",
            "additionalProperties": true
          },
          "compliance_result": {
            "anyOf": [
              {
                "type": "object",
                "additionalProperties": true
              },
              {
                "type": "null"
              }
            ]
          },
          "ip_address": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CreateInboxRequest": {
        "type": "object",
        "anyOf": [
          {
            "required": [
              "username"
            ]
          },
          {
            "required": [
              "address"
            ]
          }
        ],
        "properties": {
          "username": {
            "type": "string",
            "pattern": "^[a-z0-9._-]+$"
          },
          "address": {
            "type": "string",
            "format": "email"
          },
          "display_name": {
            "type": "string"
          },
          "domain": {
            "type": "string"
          },
          "daily_send_limit": {
            "type": "integer",
            "minimum": 1
          },
          "permissions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InboxPermission"
            }
          }
        }
      },
      "AuthSignupRequest": {
        "type": "object",
        "required": [
          "name",
          "email"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255
          },
          "email": {
            "type": "string",
            "format": "email",
            "maxLength": 255
          }
        }
      },
      "AuthVerifyRequest": {
        "type": "object",
        "required": [
          "email",
          "code"
        ],
        "properties": {
          "email": {
            "type": "string",
            "format": "email",
            "maxLength": 255
          },
          "code": {
            "type": "string",
            "pattern": "^\\d{6}$",
            "minLength": 6,
            "maxLength": 6
          }
        }
      },
      "DeleteAccountRequest": {
        "type": "object",
        "required": [
          "email",
          "confirmation"
        ],
        "properties": {
          "email": {
            "type": "string",
            "format": "email",
            "maxLength": 255
          },
          "confirmation": {
            "type": "string",
            "enum": [
              "DELETE"
            ]
          }
        }
      },
      "CreateApiKeyRequest": {
        "type": "object",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 2000
          },
          "permissions": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string",
              "enum": [
                "read",
                "write"
              ]
            }
          },
          "expires_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "UpdateApiKeyRequest": {
        "type": "object",
        "minProperties": 1,
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 2000
          },
          "permissions": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string",
              "enum": [
                "read",
                "write"
              ]
            }
          },
          "expires_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "UpdateInboxRequest": {
        "type": "object",
        "minProperties": 1,
        "properties": {
          "display_name": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 255
          }
        }
      },
      "CreateDomainRequest": {
        "type": "object",
        "required": [
          "domain"
        ],
        "properties": {
          "domain": {
            "type": "string",
            "format": "hostname"
          }
        }
      },
      "SendMessageRequest": {
        "type": "object",
        "required": [
          "to",
          "subject",
          "body_text"
        ],
        "properties": {
          "attachments": {
            "type": "array",
            "maxItems": 0,
            "example": [],
            "items": {},
            "description": "Omit or send an empty array. Every non-empty array is refused before persistence with 403 OUTBOUND_POLICY_DENIED and reason attachment_review_required. No outbound attachment type is currently allowed; inbound attachment limits are separate."
          },
          "to": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string",
              "format": "email"
            }
          },
          "cc": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "email"
            }
          },
          "bcc": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "email"
            }
          },
          "subject": {
            "type": "string"
          },
          "body_text": {
            "type": "string"
          },
          "body_html": {
            "type": "string"
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "send_at": {
            "type": "string",
            "format": "date-time",
            "description": "Optional future timestamp. Omit to send immediately; include to schedule the send for that UTC instant."
          }
        }
      },
      "ReplyMessageRequest": {
        "type": "object",
        "required": [
          "body_text"
        ],
        "properties": {
          "attachments": {
            "type": "array",
            "maxItems": 0,
            "example": [],
            "items": {},
            "description": "Omit or send an empty array. Every non-empty array is refused before persistence with 403 OUTBOUND_POLICY_DENIED and reason attachment_review_required. No outbound attachment type is currently allowed; inbound attachment limits are separate."
          },
          "body_text": {
            "type": "string"
          },
          "body_html": {
            "type": "string"
          }
        }
      },
      "SearchMessagesRequest": {
        "type": "object",
        "required": [
          "query"
        ],
        "properties": {
          "query": {
            "type": "string"
          },
          "limit": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100,
            "default": 20
          }
        }
      },
      "UpdateLabelsRequest": {
        "type": "object",
        "required": [
          "labels"
        ],
        "properties": {
          "labels": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "CreateWebhookRequest": {
        "type": "object",
        "required": [
          "url",
          "events"
        ],
        "properties": {
          "url": {
            "type": "string",
            "format": "uri"
          },
          "events": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/WebhookEvent"
            }
          }
        }
      },
      "UpdateWebhookRequest": {
        "type": "object",
        "minProperties": 1,
        "properties": {
          "url": {
            "type": "string",
            "format": "uri"
          },
          "events": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/WebhookEvent"
            }
          },
          "active": {
            "type": "boolean"
          }
        }
      },
      "PaginationMeta": {
        "type": "object",
        "required": [
          "page",
          "limit",
          "total"
        ],
        "properties": {
          "page": {
            "type": "integer"
          },
          "limit": {
            "type": "integer"
          },
          "total": {
            "type": "integer"
          }
        }
      },
      "ApiError": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "details": {
                "oneOf": [
                  {
                    "type": "object",
                    "additionalProperties": true
                  },
                  {
                    "type": "array",
                    "items": {}
                  },
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            }
          }
        }
      },
      "WebhookPayload": {
        "type": "object",
        "required": [
          "event",
          "timestamp",
          "data"
        ],
        "properties": {
          "event": {
            "$ref": "#/components/schemas/WebhookEvent"
          },
          "timestamp": {
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "MessageReceivedPayload": {
        "type": "object",
        "required": [
          "message_id",
          "inbox_id",
          "from",
          "subject",
          "snippet",
          "thread_id"
        ],
        "properties": {
          "message_id": {
            "type": "string"
          },
          "inbox_id": {
            "type": "string"
          },
          "from": {
            "type": "string",
            "format": "email"
          },
          "subject": {
            "type": "string"
          },
          "snippet": {
            "type": "string"
          },
          "thread_id": {
            "type": "string"
          }
        }
      },
      "MessageSentPayload": {
        "type": "object",
        "required": [
          "message_id",
          "inbox_id",
          "to",
          "compliance_status",
          "delivered_via"
        ],
        "properties": {
          "message_id": {
            "type": "string"
          },
          "inbox_id": {
            "type": "string"
          },
          "to": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "email"
            }
          },
          "compliance_status": {
            "$ref": "#/components/schemas/ComplianceStatus"
          },
          "delivered_via": {
            "type": "string"
          }
        }
      },
      "InboxResponse": {
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "$ref": "#/components/schemas/Inbox"
          }
        }
      },
      "InboxListResponse": {
        "type": "object",
        "required": [
          "data",
          "meta"
        ],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Inbox"
            }
          },
          "meta": {
            "$ref": "#/components/schemas/PaginationMeta"
          }
        }
      },
      "InboxStatusResponse": {
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "type": "object",
            "required": [
              "id",
              "status"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "status": {
                "$ref": "#/components/schemas/InboxStatus"
              }
            }
          }
        }
      },
      "AuthSignupResponse": {
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "type": "object",
            "required": [
              "message",
              "pending_id",
              "expires_in_seconds"
            ],
            "properties": {
              "message": {
                "type": "string"
              },
              "pending_id": {
                "type": "string"
              },
              "expires_in_seconds": {
                "type": "integer"
              }
            }
          }
        }
      },
      "AuthVerifyResponse": {
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "type": "object",
            "required": [
              "account",
              "apiKey",
              "sandbox"
            ],
            "properties": {
              "account": {
                "$ref": "#/components/schemas/PublicAccount"
              },
              "apiKey": {
                "type": "string"
              },
              "sandbox": {
                "$ref": "#/components/schemas/SandboxProvisioning"
              }
            }
          }
        }
      },
      "AccountResponse": {
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "allOf": [
              {
                "$ref": "#/components/schemas/PublicAccount"
              },
              {
                "type": "object",
                "required": [
                  "ownership_verified_at"
                ],
                "properties": {
                  "ownership_verified_at": {
                    "type": "string",
                    "format": "date-time",
                    "description": "Stored email ownership proof only, never full send permission. Null proof is refused with 403 OWNERSHIP_VERIFICATION_REQUIRED instead of a successful account response."
                  },
                  "webhook_addon": {
                    "type": "object",
                    "properties": {
                      "included": {
                        "type": "boolean",
                        "const": true
                      },
                      "features": {
                        "type": "object",
                        "description": "Retry, DLQ, replay, success chart and idempotency headers are included on every plan; legacy billing fields do not control these features."
                      }
                    }
                  }
                }
              }
            ]
          }
        }
      },
      "DeleteAccountResponse": {
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "type": "object",
            "required": [
              "id",
              "email",
              "deleted"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "email": {
                "type": "string",
                "format": "email"
              },
              "deleted": {
                "type": "boolean"
              }
            }
          }
        }
      },
      "CreateApiKeyResponse": {
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "type": "object",
            "required": [
              "id",
              "name",
              "key_prefix",
              "permissions",
              "api_key",
              "created_at"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "key_prefix": {
                "type": "string"
              },
              "permissions": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "api_key": {
                "type": "string"
              },
              "created_at": {
                "type": "string",
                "format": "date-time"
              }
            }
          }
        }
      },
      "ApiKeyListResponse": {
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicApiKey"
            }
          }
        }
      },
      "PublicApiKeyResponse": {
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "$ref": "#/components/schemas/PublicApiKey"
          }
        }
      },
      "RotateApiKeyResponse": {
        "type": "object",
        "required": [
          "data",
          "revoked_key_id"
        ],
        "properties": {
          "data": {
            "allOf": [
              {
                "$ref": "#/components/schemas/PublicApiKey"
              },
              {
                "type": "object",
                "required": [
                  "api_key"
                ],
                "properties": {
                  "api_key": {
                    "type": "string"
                  },
                  "key": {
                    "type": "string"
                  }
                }
              }
            ]
          },
          "revoked_key_id": {
            "type": "string"
          }
        }
      },
      "DeleteApiKeyResponse": {
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "type": "object",
            "required": [
              "id",
              "deleted"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "deleted": {
                "type": "boolean"
              }
            }
          }
        }
      },
      "DomainResponse": {
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "$ref": "#/components/schemas/Domain"
          }
        }
      },
      "DomainListResponse": {
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Domain"
            }
          }
        }
      },
      "VerifyDomainResponse": {
        "type": "object",
        "required": [
          "data",
          "next_step"
        ],
        "properties": {
          "data": {
            "$ref": "#/components/schemas/Domain"
          },
          "next_step": {
            "type": "string"
          }
        }
      },
      "DeleteDomainResponse": {
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "type": "object",
            "required": [
              "id",
              "deleted"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "deleted": {
                "type": "boolean"
              }
            }
          }
        }
      },
      "MessageResponse": {
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "$ref": "#/components/schemas/Message"
          }
        }
      },
      "MessageListResponse": {
        "type": "object",
        "required": [
          "data",
          "meta"
        ],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Message"
            }
          },
          "meta": {
            "$ref": "#/components/schemas/PaginationMeta"
          }
        }
      },
      "SendMessageResponse": {
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "type": "object",
            "required": [
              "id",
              "thread_id",
              "compliance_status",
              "created_at"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "thread_id": {
                "type": "string"
              },
              "compliance_status": {
                "$ref": "#/components/schemas/ComplianceStatus"
              },
              "created_at": {
                "type": "string",
                "format": "date-time"
              },
              "delivery_status": {
                "type": "string"
              },
              "scheduled_at": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              }
            }
          }
        }
      },
      "RescheduleMessageRequest": {
        "type": "object",
        "required": [
          "send_at"
        ],
        "properties": {
          "send_at": {
            "type": "string",
            "format": "date-time",
            "description": "Future ISO timestamp with timezone offset."
          }
        }
      },
      "CancelScheduleResponse": {
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "type": "object",
            "description": "Message fields plus the resulting schedule state. Additional message fields are returned.",
            "required": [
              "id",
              "delivery_status",
              "scheduled_at",
              "scheduled_error"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "delivery_status": {
                "type": "string",
                "enum": [
                  "cancelled"
                ]
              },
              "scheduled_at": {
                "type": "string",
                "format": "date-time"
              },
              "scheduled_error": {
                "type": "string",
                "enum": [
                  "cancelled"
                ]
              }
            }
          }
        }
      },
      "RescheduleMessageResponse": {
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "type": "object",
            "description": "Message fields plus the resulting schedule state. Additional message fields are returned.",
            "required": [
              "id",
              "delivery_status",
              "scheduled_at",
              "scheduled_error"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "delivery_status": {
                "type": "string",
                "enum": [
                  "scheduled"
                ]
              },
              "scheduled_at": {
                "type": "string",
                "format": "date-time"
              },
              "scheduled_error": {
                "type": "null"
              }
            }
          }
        }
      },
      "ThreadResponse": {
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "$ref": "#/components/schemas/Thread"
          }
        }
      },
      "ThreadListResponse": {
        "type": "object",
        "required": [
          "data",
          "meta"
        ],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Thread"
            }
          },
          "meta": {
            "$ref": "#/components/schemas/PaginationMeta"
          }
        }
      },
      "WebhookResponse": {
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "$ref": "#/components/schemas/Webhook"
          }
        }
      },
      "WebhookListResponse": {
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Webhook"
            }
          }
        }
      },
      "WebhookTestResponse": {
        "type": "object",
        "required": [
          "success",
          "status_code",
          "response_time_ms"
        ],
        "properties": {
          "success": {
            "type": "boolean"
          },
          "status_code": {
            "type": [
              "integer",
              "null"
            ]
          },
          "response_time_ms": {
            "type": "integer"
          },
          "error": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "DeleteWebhookResponse": {
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "type": "object",
            "required": [
              "id",
              "deleted"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "deleted": {
                "type": "boolean"
              }
            }
          }
        }
      },
      "ComplianceCheckResponse": {
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "$ref": "#/components/schemas/ComplianceDetails"
          }
        }
      },
      "ReadinessResponse": {
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "type": "object",
            "required": [
              "inbox_id",
              "domain",
              "score",
              "checks"
            ],
            "properties": {
              "inbox_id": {
                "type": "string"
              },
              "domain": {
                "type": "string"
              },
              "score": {
                "type": "integer"
              },
              "checks": {
                "type": "object",
                "required": [
                  "spf",
                  "dkim",
                  "dmarc",
                  "sending_domain_verified",
                  "warmup_ready"
                ],
                "properties": {
                  "spf": {
                    "type": "string",
                    "enum": [
                      "pass",
                      "fail",
                      "none"
                    ]
                  },
                  "dkim": {
                    "type": "string",
                    "enum": [
                      "pass",
                      "fail",
                      "none"
                    ]
                  },
                  "dmarc": {
                    "type": "string",
                    "enum": [
                      "pass",
                      "fail",
                      "none"
                    ]
                  },
                  "sending_domain_verified": {
                    "type": "boolean"
                  },
                  "warmup_ready": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        }
      },
      "AuditLogListResponse": {
        "type": "object",
        "required": [
          "data",
          "meta"
        ],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AuditLogEntry"
            }
          },
          "meta": {
            "$ref": "#/components/schemas/PaginationMeta"
          }
        }
      },
      "EngagementEventListResponse": {
        "type": "object",
        "required": [
          "data",
          "page",
          "limit"
        ],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EngagementEvent"
            }
          },
          "page": {
            "type": "integer"
          },
          "limit": {
            "type": "integer"
          }
        }
      },
      "EngagementStatsResponse": {
        "type": "object",
        "required": [
          "period",
          "stats",
          "rates"
        ],
        "properties": {
          "period": {
            "type": "string",
            "enum": [
              "24h",
              "7d",
              "30d"
            ]
          },
          "stats": {
            "type": "object",
            "required": [
              "delivered",
              "opened",
              "clicked",
              "bounced",
              "complained"
            ],
            "properties": {
              "delivered": {
                "type": "integer"
              },
              "opened": {
                "type": "integer"
              },
              "clicked": {
                "type": "integer"
              },
              "bounced": {
                "type": "integer"
              },
              "complained": {
                "type": "integer"
              }
            }
          },
          "rates": {
            "type": "object",
            "required": [
              "deliveryRate",
              "openRate",
              "clickRate",
              "bounceRate"
            ],
            "properties": {
              "deliveryRate": {
                "type": "string"
              },
              "openRate": {
                "type": "string"
              },
              "clickRate": {
                "type": "string"
              },
              "bounceRate": {
                "type": "string"
              }
            }
          }
        }
      },
      "MessageEngagementResponse": {
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EngagementEvent"
            }
          }
        }
      },
      "UsageResponse": {
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "type": "object",
            "required": [
              "account_id",
              "period",
              "inbox_count",
              "inbound_messages",
              "outbound_messages",
              "webhooks_delivered",
              "compliance_failures",
              "quota"
            ],
            "properties": {
              "account_id": {
                "type": "string"
              },
              "period": {
                "type": "string",
                "enum": [
                  "day",
                  "week",
                  "month"
                ]
              },
              "inbox_count": {
                "type": "integer"
              },
              "inbound_messages": {
                "type": "integer"
              },
              "outbound_messages": {
                "type": "integer"
              },
              "webhooks_delivered": {
                "type": "integer"
              },
              "compliance_failures": {
                "type": "integer"
              },
              "quota": {
                "type": "object",
                "required": [
                  "plan",
                  "daily_send_limit",
                  "sends_today"
                ],
                "properties": {
                  "plan": {
                    "$ref": "#/components/schemas/Plan"
                  },
                  "daily_send_limit": {
                    "type": "integer"
                  },
                  "sends_today": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        }
      },
      "UsageDailyResponse": {
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "date",
                "sent",
                "received"
              ],
              "properties": {
                "date": {
                  "type": "string"
                },
                "sent": {
                  "type": "integer"
                },
                "received": {
                  "type": "integer"
                }
              }
            }
          }
        }
      },
      "WebhookEventSchemas": {
        "type": "object",
        "description": "Webhook event payload definitions.",
        "properties": {
          "message.received": {
            "allOf": [
              {
                "$ref": "#/components/schemas/WebhookPayload"
              },
              {
                "type": "object",
                "properties": {
                  "data": {
                    "$ref": "#/components/schemas/MessageReceivedPayload"
                  }
                }
              }
            ]
          },
          "message.sent": {
            "allOf": [
              {
                "$ref": "#/components/schemas/WebhookPayload"
              },
              {
                "type": "object",
                "properties": {
                  "data": {
                    "$ref": "#/components/schemas/MessageSentPayload"
                  }
                }
              }
            ]
          },
          "message.bounced": {
            "$ref": "#/components/schemas/WebhookPayload"
          },
          "message.complained": {
            "$ref": "#/components/schemas/WebhookPayload"
          },
          "message.scheduled_cancelled": {
            "$ref": "#/components/schemas/WebhookPayload"
          },
          "compliance.failed": {
            "$ref": "#/components/schemas/WebhookPayload"
          },
          "inbox.created": {
            "$ref": "#/components/schemas/WebhookPayload"
          }
        }
      }
    }
  }
}
