{
  "openapi": "3.1.0",
  "info": {
    "title": "Specinbox API",
    "version": "1.0.0",
    "summary": "Catch OTPs and signup emails in your tests, no mail server.",
    "description": "Specinbox gives your test suite a real email inbox on demand: create one with a single call, trigger your signup, OTP or password-reset flow, then read the message as JSON or receive it by signed webhook.\n\nEvery request carries `Authorization: Bearer <api key>`. Keys are `tm_live_...` (real inbound mail on a public or your own verified domain) or `tm_test_...` (test mode: a fixture message with the code `424242` is seeded into every inbox, and `POST /v1/test/inboxes/{inbox_id}/messages` injects more; nothing counts against e-mail quotas). A key only ever sees its own organization's objects, in its own mode.\n\nErrors share one envelope: `{\"error\": {\"type\", \"message\", \"request_id\", \"param\"?}}`. Every response carries `Request-Id`, and authenticated ones `X-RateLimit-Limit`, `X-RateLimit-Remaining`, `X-RateLimit-Reset`; a 429 adds `Retry-After` (seconds). Lists paginate with `limit` (1-100, default 20) and the opaque `cursor` echoed back as `next_cursor`. Every `POST` honours `Idempotency-Key` (<= 255 chars, replayed for 24 h with `Idempotent-Replayed: true`; a reuse with a different body is a 422 `idempotency_mismatch`). Request bodies are capped at 64 KB (413 `payload_too_large`).\n\nSpecinbox is a service of NANDBYTE LLC. Support: contact@tronics.dev.",
    "contact": {"name": "Specinbox support", "email": "contact@tronics.dev"},
    "termsOfService": "https://specinbox.com/docs/aup"
  },
  "servers": [{"url": "https://api.specinbox.com", "description": "Production"}, {"url": "https://devapi.temp-mail.lol", "description": "Legacy alias of api.specinbox.com; same server, keeps working"}],
  "externalDocs": {"description": "Guides, quickstart and dashboard", "url": "https://specinbox.com/docs"},
  "security": [{"apiKey": []}],
  "tags": [
    {"name": "Account", "description": "Which key is calling and what its plan allows."},
    {"name": "Domains", "description": "Domains an inbox can be created on."},
    {"name": "Inboxes", "description": "Create, list, read and delete inboxes."},
    {"name": "Messages", "description": "Read and delete received messages and their attachments."},
    {"name": "Send", "description": "Loopback delivery between your own inboxes; never reaches the public internet."},
    {"name": "Usage", "description": "This month's meters against the plan's limits."},
    {"name": "Test mode", "description": "Deterministic helpers for `tm_test_` keys."},
    {"name": "Meta", "description": "This document."}
  ],
  "paths": {
    "/v1/openapi.json": {
      "get": {
        "tags": ["Meta"],
        "summary": "This OpenAPI document",
        "description": "Public and read-only; no API key needed. Served with `Access-Control-Allow-Origin: *`.",
        "operationId": "getOpenApi",
        "security": [],
        "responses": {
          "200": {"description": "The spec.", "content": {"application/json": {"schema": {"type": "object"}}}}
        }
      }
    },
    "/v1/me": {
      "get": {
        "tags": ["Account"],
        "summary": "Describe the calling key",
        "description": "Any scope. Confirms the key works and tells you its organization, mode, scopes and the plan whose limits apply right now.",
        "operationId": "getMe",
        "responses": {
          "200": {"description": "The key.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Key"}}}},
          "401": {"$ref": "#/components/responses/Unauthenticated"},
          "403": {"$ref": "#/components/responses/Forbidden"},
          "429": {"$ref": "#/components/responses/RateLimited"},
          "503": {"$ref": "#/components/responses/Unavailable"}
        }
      }
    },
    "/v1/domains": {
      "get": {
        "tags": ["Domains"],
        "summary": "List the domains this key may create inboxes on",
        "description": "Scope `inboxes:read`. Live keys: the shared public domains plus the organization's own `active` custom domains. Test keys: only the sandbox domain. Not paginated (`has_more` is always `false`).",
        "operationId": "listDomains",
        "responses": {
          "200": {
            "description": "The domain list.",
            "content": {"application/json": {"schema": {
              "allOf": [{"$ref": "#/components/schemas/ListEnvelope"}, {"type": "object", "properties": {"data": {"type": "array", "items": {"$ref": "#/components/schemas/Domain"}}}}]
            }}}
          },
          "401": {"$ref": "#/components/responses/Unauthenticated"},
          "403": {"$ref": "#/components/responses/Forbidden"},
          "429": {"$ref": "#/components/responses/RateLimited"}
        }
      }
    },
    "/v1/inboxes": {
      "post": {
        "tags": ["Inboxes"],
        "summary": "Create an inbox",
        "description": "Scope `inboxes:write`. Public domains and test mode always get a random 16-character local part (public-domain mail is readable by anyone who knows the address); `local_part` is accepted only on one of your organization's own `active` custom domains. Omit `domain` to get a random public domain (live) or the sandbox domain (test). Test keys ignore `domain` and refuse `local_part`. A test-mode inbox is seeded with one fixture message (`Your verification code is 424242`).\n\nLimits, in order: `inbox_creates_per_min` per organization and mode (429 `rate_limited`); on the Sandbox plan, `inboxes_day` live creations per UTC day (429 `quota_exceeded`); `inboxes_active` live inboxes, or 100 test inboxes (403 `limit_reached`). While `DEVAPI_SANDBOX_PAUSED` is set on the server, live creation on the Sandbox plan answers 503.",
        "operationId": "createInbox",
        "parameters": [{"$ref": "#/components/parameters/IdempotencyKey"}],
        "requestBody": {
          "required": false,
          "content": {"application/json": {"schema": {"$ref": "#/components/schemas/CreateInboxRequest"}, "examples": {
            "default": {"summary": "Random address on a random public domain", "value": {}},
            "ownDomain": {"summary": "Chosen address on your verified domain, expiring in 10 minutes", "value": {"domain": "mail.example.com", "local_part": "signup-test-42", "expires_in": 600}}
          }}}
        },
        "responses": {
          "201": {"description": "The new inbox.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Inbox"}}}},
          "400": {"$ref": "#/components/responses/InvalidRequest"},
          "401": {"$ref": "#/components/responses/Unauthenticated"},
          "403": {"description": "`insufficient_scope`, `ip_not_allowed`, `account_suspended`, or `limit_reached` (the plan's active-inbox cap).", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}},
          "404": {"description": "`not_found`: `domain` is another organization's custom domain.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}},
          "409": {"description": "`conflict`: the generated address collided (retry), no public domain is available, or an `Idempotency-Key` request is still in progress.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}},
          "422": {"$ref": "#/components/responses/IdempotencyMismatch"},
          "429": {"$ref": "#/components/responses/RateLimited"},
          "503": {"$ref": "#/components/responses/Unavailable"}
        }
      },
      "get": {
        "tags": ["Inboxes"],
        "summary": "List inboxes",
        "description": "Scope `inboxes:read`. Newest first; `active` and `expired` inboxes unless filtered. Deleted inboxes are never listed.",
        "operationId": "listInboxes",
        "parameters": [
          {"name": "status", "in": "query", "schema": {"type": "string", "enum": ["active", "expired"]}},
          {"$ref": "#/components/parameters/Limit"},
          {"$ref": "#/components/parameters/Cursor"}
        ],
        "responses": {
          "200": {"description": "A page of inboxes.", "content": {"application/json": {"schema": {
            "allOf": [{"$ref": "#/components/schemas/ListEnvelope"}, {"type": "object", "properties": {"data": {"type": "array", "items": {"$ref": "#/components/schemas/Inbox"}}}}]
          }}}},
          "400": {"$ref": "#/components/responses/InvalidRequest"},
          "401": {"$ref": "#/components/responses/Unauthenticated"},
          "403": {"$ref": "#/components/responses/Forbidden"},
          "429": {"$ref": "#/components/responses/RateLimited"}
        }
      }
    },
    "/v1/inboxes/{inbox_id}": {
      "parameters": [{"$ref": "#/components/parameters/InboxId"}],
      "get": {
        "tags": ["Inboxes"],
        "summary": "Retrieve an inbox",
        "description": "Scope `inboxes:read`.",
        "operationId": "getInbox",
        "responses": {
          "200": {"description": "The inbox.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Inbox"}}}},
          "401": {"$ref": "#/components/responses/Unauthenticated"},
          "403": {"$ref": "#/components/responses/Forbidden"},
          "404": {"$ref": "#/components/responses/NotFound"},
          "429": {"$ref": "#/components/responses/RateLimited"}
        }
      },
      "delete": {
        "tags": ["Inboxes"],
        "summary": "Delete an inbox",
        "description": "Scope `inboxes:write`. Deletes the inbox's messages with it and frees the active-inbox slot. The address may later be reused.",
        "operationId": "deleteInbox",
        "responses": {
          "204": {"description": "Deleted."},
          "401": {"$ref": "#/components/responses/Unauthenticated"},
          "403": {"$ref": "#/components/responses/Forbidden"},
          "404": {"$ref": "#/components/responses/NotFound"},
          "429": {"$ref": "#/components/responses/RateLimited"}
        }
      }
    },
    "/v1/inboxes/{inbox_id}/messages": {
      "parameters": [{"$ref": "#/components/parameters/InboxId"}],
      "get": {
        "tags": ["Messages"],
        "summary": "List an inbox's messages",
        "description": "Scope `messages:read`. Newest first by `received_at`. A live inbox is synced from the mail server first when its last sync is older than a few seconds, so polling this is the simplest way to wait for a message; `since` narrows to messages received at or after that instant (ISO 8601).",
        "operationId": "listInboxMessages",
        "parameters": [
          {"name": "since", "in": "query", "schema": {"type": "string", "format": "date-time"}, "example": "2026-12-07T14:05:00Z"},
          {"$ref": "#/components/parameters/Limit"},
          {"$ref": "#/components/parameters/Cursor"}
        ],
        "responses": {
          "200": {"description": "A page of message summaries.", "content": {"application/json": {"schema": {
            "allOf": [{"$ref": "#/components/schemas/ListEnvelope"}, {"type": "object", "properties": {"data": {"type": "array", "items": {"$ref": "#/components/schemas/MessageSummary"}}}}]
          }}}},
          "400": {"$ref": "#/components/responses/InvalidRequest"},
          "401": {"$ref": "#/components/responses/Unauthenticated"},
          "403": {"$ref": "#/components/responses/Forbidden"},
          "404": {"$ref": "#/components/responses/NotFound"},
          "429": {"$ref": "#/components/responses/RateLimited"}
        }
      }
    },
    "/v1/inboxes/{inbox_id}/send": {
      "parameters": [{"$ref": "#/components/parameters/InboxId"}],
      "post": {
        "tags": ["Send"],
        "summary": "Send a message between your own inboxes (loopback)",
        "description": "Scope `messages:write`. Delivers from this active inbox to 1-10 recipients that are all active inboxes of your own organization in the same mode; it never reaches real SMTP. Each delivered copy counts as a received e-mail (live mode) and against a bucket of 60 delivered copies per hour per organization. Omit `subject` with `in_reply_to` to get `Re: <original subject>`; `in_reply_to` also threads `message_id`/`in_reply_to`/`references`. `text` and `html` together are capped at min(plan `max_message_bytes`, 64 KB).",
        "operationId": "sendMessage",
        "parameters": [{"$ref": "#/components/parameters/IdempotencyKey"}],
        "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/SendRequest"}}}},
        "responses": {
          "201": {"description": "The send, with the copies delivered and the recipients dropped over the e-mail quota.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Send"}}}},
          "400": {"$ref": "#/components/responses/InvalidRequest"},
          "401": {"$ref": "#/components/responses/Unauthenticated"},
          "403": {"description": "`insufficient_scope`, or `forbidden`: the sender inbox is not active.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}},
          "404": {"$ref": "#/components/responses/NotFound"},
          "409": {"$ref": "#/components/responses/IdempotencyInProgress"},
          "422": {"description": "`recipient_not_allowed`: an address is not one of your organization's active inboxes; or `idempotency_mismatch`.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}},
          "429": {"description": "`rate_limited` (60 delivered copies per hour) or `quota_exceeded` (every copy was over the e-mail cap; nothing delivered).", "headers": {"Retry-After": {"$ref": "#/components/headers/RetryAfter"}}, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}
        }
      }
    },
    "/v1/messages/{message_id}": {
      "parameters": [{"$ref": "#/components/parameters/MessageId"}],
      "get": {
        "tags": ["Messages"],
        "summary": "Retrieve a message",
        "description": "Scope `messages:read`. The full message: `text`, `html`, threading headers and attachment metadata.",
        "operationId": "getMessage",
        "responses": {
          "200": {"description": "The message.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Message"}}}},
          "401": {"$ref": "#/components/responses/Unauthenticated"},
          "403": {"$ref": "#/components/responses/Forbidden"},
          "404": {"$ref": "#/components/responses/NotFound"},
          "429": {"$ref": "#/components/responses/RateLimited"}
        }
      },
      "delete": {
        "tags": ["Messages"],
        "summary": "Delete a message",
        "description": "Scope `messages:write`. The message is gone from every read; the same mail is never re-imported by a later sync.",
        "operationId": "deleteMessage",
        "responses": {
          "204": {"description": "Deleted."},
          "401": {"$ref": "#/components/responses/Unauthenticated"},
          "403": {"$ref": "#/components/responses/Forbidden"},
          "404": {"$ref": "#/components/responses/NotFound"},
          "429": {"$ref": "#/components/responses/RateLimited"}
        }
      }
    },
    "/v1/messages/{message_id}/attachments/{index}": {
      "parameters": [
        {"$ref": "#/components/parameters/MessageId"},
        {"name": "index", "in": "path", "required": true, "description": "The attachment's `index` from the message's `attachments` array.", "schema": {"type": "integer", "minimum": 0}}
      ],
      "get": {
        "tags": ["Messages"],
        "summary": "Download an attachment",
        "description": "Scope `messages:read`. The raw bytes with the attachment's own `Content-Type` and a `Content-Disposition: attachment` filename. A message stored `truncated` (over the size cap) kept attachment metadata only and answers 404 here.",
        "operationId": "getAttachment",
        "responses": {
          "200": {"description": "The attachment bytes.", "content": {"*/*": {"schema": {"type": "string", "format": "binary"}}}},
          "401": {"$ref": "#/components/responses/Unauthenticated"},
          "403": {"$ref": "#/components/responses/Forbidden"},
          "404": {"$ref": "#/components/responses/NotFound"},
          "429": {"$ref": "#/components/responses/RateLimited"}
        }
      }
    },
    "/v1/usage": {
      "get": {
        "tags": ["Usage"],
        "summary": "This month's usage against the plan",
        "description": "Scope `usage:read`. `requests` is this mode's own counter (live and test requests are metered separately against the same cap); `emails` and `inboxes_active` are the organization's live meters. `limits` is the effective limit set, admin overrides included.",
        "operationId": "getUsage",
        "responses": {
          "200": {"description": "The usage report.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Usage"}}}},
          "401": {"$ref": "#/components/responses/Unauthenticated"},
          "403": {"$ref": "#/components/responses/Forbidden"},
          "429": {"$ref": "#/components/responses/RateLimited"}
        }
      }
    },
    "/v1/test/inboxes/{inbox_id}/messages": {
      "parameters": [{"$ref": "#/components/parameters/InboxId"}],
      "post": {
        "tags": ["Test mode"],
        "summary": "Inject a message into a test-mode inbox",
        "description": "Scope `inboxes:write`; `tm_test_` keys only (a live key gets 403 `forbidden`). Stores the message exactly as inbound mail would be and fires `message.received` to your test-mode webhook endpoints, so CI can exercise the whole flow offline. No e-mail quota; when a test-mode webhook is enabled, 60 injections per hour per organization.",
        "operationId": "injectTestMessage",
        "parameters": [{"$ref": "#/components/parameters/IdempotencyKey"}],
        "requestBody": {"required": false, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/InjectTestMessageRequest"}, "example": {"from": "no-reply@yourapp.test", "subject": "Your code is 918273", "text": "Your code is 918273"}}}},
        "responses": {
          "201": {"description": "The stored message.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Message"}}}},
          "401": {"$ref": "#/components/responses/Unauthenticated"},
          "403": {"description": "`forbidden`: not a test-mode key; or `insufficient_scope`.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}},
          "404": {"$ref": "#/components/responses/NotFound"},
          "409": {"$ref": "#/components/responses/IdempotencyInProgress"},
          "422": {"$ref": "#/components/responses/IdempotencyMismatch"},
          "429": {"$ref": "#/components/responses/RateLimited"}
        }
      }
    }
  },
  "webhooks": {
    "message.received": {
      "post": {
        "summary": "A message arrived in one of your inboxes",
        "description": "Sent to each enabled endpoint of the inbox's mode (endpoints are managed in the dashboard). Headers: `Specinbox-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\" with the endpoint secret>` (verify this one; reject when `t` is more than 5 minutes from now), `Tempmail-Event-Id`, `Tempmail-Event-Type`. `Tempmail-Signature` is also sent with the identical value: a legacy duplicate kept for integrations written before the Specinbox rename. Answer 2xx within the timeout; failures are retried with backoff for 24 hours. Fetch the full message with `GET /v1/messages/{message_id}`.",
        "requestBody": {"content": {"application/json": {"schema": {"allOf": [{"$ref": "#/components/schemas/WebhookEvent"}, {"properties": {"type": {"const": "message.received"}, "data": {"type": "object", "properties": {
          "inbox": {"type": "object", "properties": {"id": {"type": "string"}, "address": {"type": "string"}}},
          "message": {"type": "object", "properties": {"id": {"type": "string"}, "from": {"type": "string"}, "subject": {"type": "string"}, "received_at": {"type": "string", "format": "date-time"}, "size": {"type": "integer"}}}
        }}}}]}}}},
        "responses": {"200": {"description": "Acknowledged."}}
      }
    },
    "inbox.expired": {
      "post": {
        "summary": "An inbox passed its `expires_at`",
        "description": "Its messages are deleted at the same moment. Sent to each enabled endpoint of the inbox's mode that subscribes to `inbox.expired`; headers, signature and retries as for `message.received`.",
        "requestBody": {"content": {"application/json": {"schema": {"allOf": [{"$ref": "#/components/schemas/WebhookEvent"}, {"properties": {"type": {"const": "inbox.expired"}, "data": {"type": "object", "properties": {"inbox": {"type": "object", "properties": {"id": {"type": "string"}, "address": {"type": "string"}, "expired_at": {"type": "string", "format": "date-time"}}}}}}}]}}}},
        "responses": {"200": {"description": "Acknowledged."}}
      }
    },
    "quota.threshold": {
      "post": {
        "summary": "Monthly usage crossed 80% or 100% of a limit",
        "description": "Live mode only; once per metric per calendar month at each of 80% and 100% of `requests_month` or `emails_month`. Sent only while the organization's webhook alerts are on in the dashboard, to each enabled live endpoint that subscribes to `quota.threshold`; headers, signature and retries as for `message.received`.",
        "requestBody": {"content": {"application/json": {"schema": {"allOf": [{"$ref": "#/components/schemas/WebhookEvent"}, {"properties": {"type": {"const": "quota.threshold"}, "data": {"type": "object", "properties": {"metric": {"type": "string", "enum": ["requests_month", "emails_month"]}, "threshold": {"type": "integer", "enum": [80, 100]}, "used": {"type": "integer"}, "limit": {"type": "integer"}, "period": {"type": "string", "example": "2026-12"}}}}}]}}}},
        "responses": {"200": {"description": "Acknowledged."}}
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKey": {"type": "http", "scheme": "bearer", "description": "`Authorization: Bearer tm_live_...` or `Bearer tm_test_...`. Secret keys carry every scope; restricted keys carry a subset of `inboxes:read`, `inboxes:write`, `messages:read`, `messages:write`, `usage:read`."}
    },
    "parameters": {
      "InboxId": {"name": "inbox_id", "in": "path", "required": true, "schema": {"type": "string", "pattern": "^inb_"}, "example": "inb_3k9fQ2mZp7Lx4Rt8vB1nWc"},
      "MessageId": {"name": "message_id", "in": "path", "required": true, "schema": {"type": "string", "pattern": "^msg_"}, "example": "msg_8Yt2Lq9vB4nX1kZp7Rm3Wd"},
      "Limit": {"name": "limit", "in": "query", "description": "Page size, 1-100.", "schema": {"type": "integer", "minimum": 1, "maximum": 100, "default": 20}},
      "Cursor": {"name": "cursor", "in": "query", "description": "The previous page's `next_cursor`.", "schema": {"type": "string"}},
      "IdempotencyKey": {"name": "Idempotency-Key", "in": "header", "required": false, "description": "Up to 255 characters. The first response is stored for 24 hours and replayed (with `Idempotent-Replayed: true`) to any retry with the same key, organization and mode; a 429 or 5xx is never stored.", "schema": {"type": "string", "maxLength": 255}}
    },
    "headers": {
      "RetryAfter": {"description": "Seconds to wait before retrying.", "schema": {"type": "integer"}}
    },
    "responses": {
      "InvalidRequest": {"description": "`invalid_request`: a parameter or body field is wrong; `param` names it.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}},
      "Unauthenticated": {"description": "`unauthenticated`: the key is missing, invalid, revoked or expired.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}},
      "Forbidden": {"description": "`insufficient_scope`, `ip_not_allowed` (the key's IP allowlist) or `account_suspended`.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}},
      "NotFound": {"description": "`not_found`: no such object in this organization and mode.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}},
      "IdempotencyInProgress": {"description": "`conflict`: a request with this `Idempotency-Key` is still in progress.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}},
      "IdempotencyMismatch": {"description": "`idempotency_mismatch`: the `Idempotency-Key` was reused with a different request.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}},
      "RateLimited": {"description": "`rate_limited` (per-key requests per second, or a route's own bucket) or `quota_exceeded` (the plan's monthly or daily cap). `Retry-After` says how long to wait.", "headers": {"Retry-After": {"$ref": "#/components/headers/RetryAfter"}}, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}},
      "Unavailable": {"description": "`unavailable`: the service (or, on the Sandbox plan, live inbox creation) is temporarily paused. Retry later.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": ["error"],
        "properties": {"error": {
          "type": "object",
          "required": ["type", "message", "request_id"],
          "properties": {
            "type": {"type": "string", "description": "A stable machine-readable code.", "enum": ["invalid_request", "unauthenticated", "insufficient_scope", "ip_not_allowed", "account_suspended", "forbidden", "not_found", "conflict", "limit_reached", "recipient_not_allowed", "idempotency_mismatch", "rate_limited", "quota_exceeded", "payload_too_large", "unavailable", "server_error"]},
            "message": {"type": "string"},
            "request_id": {"type": "string", "example": "req_5Hn2Kq8vB3xL1mZp9Rt4Wc"},
            "param": {"type": "string", "description": "The offending field, when there is one."}
          }
        }},
        "example": {"error": {"type": "invalid_request", "message": "expires_in must be an integer number of seconds between 60 and 2592000.", "request_id": "req_5Hn2Kq8vB3xL1mZp9Rt4Wc", "param": "expires_in"}}
      },
      "ListEnvelope": {
        "type": "object",
        "required": ["object", "data", "has_more", "next_cursor"],
        "properties": {
          "object": {"type": "string", "const": "list"},
          "data": {"type": "array"},
          "has_more": {"type": "boolean"},
          "next_cursor": {"type": ["string", "null"], "description": "Pass as `cursor` for the next page; null on the last page."}
        }
      },
      "Key": {
        "type": "object",
        "required": ["object", "org_id", "livemode", "scopes", "plan"],
        "properties": {
          "object": {"type": "string", "const": "key"},
          "org_id": {"type": "string", "example": "org_2Lq8vB3xK1mZp9Rt4Wc5Hn"},
          "livemode": {"type": "boolean"},
          "scopes": {"type": "array", "items": {"type": "string"}, "description": "`[\"*\"]` for a secret key."},
          "plan": {"type": "string", "enum": ["sandbox", "developer", "team", "business", "enterprise"]}
        }
      },
      "Domain": {
        "type": "object",
        "required": ["domain", "type"],
        "properties": {
          "domain": {"type": "string", "example": "mail.example.com"},
          "type": {"type": "string", "enum": ["public", "custom"]}
        }
      },
      "CreateInboxRequest": {
        "type": "object",
        "properties": {
          "domain": {"type": "string", "description": "A public domain from `GET /v1/domains`, or one of your organization's active custom domains. Omit for a random public domain. Ignored by test keys."},
          "local_part": {"type": "string", "pattern": "^[a-z0-9][a-z0-9._+-]{0,63}$", "description": "Only on your own active custom domain."},
          "expires_in": {"type": "integer", "minimum": 60, "maximum": 2592000, "description": "Seconds until the inbox expires on its own (1 minute to 30 days). Omit for no expiry; messages still follow the plan's retention."}
        }
      },
      "Inbox": {
        "type": "object",
        "required": ["id", "object", "address", "domain", "livemode", "status", "created_at", "expires_at"],
        "properties": {
          "id": {"type": "string", "example": "inb_3k9fQ2mZp7Lx4Rt8vB1nWc"},
          "object": {"type": "string", "const": "inbox"},
          "address": {"type": "string", "format": "email", "example": "k3v9mn2x7qa1@in.specinbox.com"},
          "domain": {"type": "string"},
          "livemode": {"type": "boolean"},
          "status": {"type": "string", "enum": ["active", "expired"]},
          "created_at": {"type": "string", "format": "date-time"},
          "expires_at": {"type": ["string", "null"], "format": "date-time"}
        }
      },
      "Attachment": {
        "type": "object",
        "required": ["index", "filename", "content_type", "size"],
        "properties": {
          "index": {"type": "integer", "description": "Use in `GET /v1/messages/{message_id}/attachments/{index}`."},
          "filename": {"type": ["string", "null"]},
          "content_type": {"type": ["string", "null"]},
          "size": {"type": ["integer", "null"]}
        }
      },
      "MessageSummary": {
        "type": "object",
        "required": ["id", "object", "inbox_id", "from", "to", "subject", "received_at", "size", "attachment_count"],
        "properties": {
          "id": {"type": "string", "example": "msg_8Yt2Lq9vB4nX1kZp7Rm3Wd"},
          "object": {"type": "string", "const": "message"},
          "inbox_id": {"type": "string"},
          "from": {"type": "string", "description": "The From header as received, e.g. `Acme <no-reply@acme.com>`."},
          "to": {"type": "string"},
          "subject": {"type": "string"},
          "received_at": {"type": "string", "format": "date-time"},
          "size": {"type": "integer", "description": "Bytes."},
          "attachment_count": {"type": "integer"}
        }
      },
      "Message": {
        "allOf": [
          {"$ref": "#/components/schemas/MessageSummary"},
          {
            "type": "object",
            "required": ["date", "text", "html", "truncated", "message_id", "in_reply_to", "references", "loopback", "attachments"],
            "properties": {
              "date": {"type": "string", "description": "The Date header as received."},
              "text": {"type": "string", "description": "The plain-text body (empty when the mail had none)."},
              "html": {"type": "string", "description": "The HTML body (empty when the mail had none)."},
              "truncated": {"type": "boolean", "description": "True when the stored message dropped its attachment bytes for size."},
              "message_id": {"type": ["string", "null"], "description": "The Message-ID header."},
              "in_reply_to": {"type": ["string", "null"]},
              "references": {"type": "array", "items": {"type": "string"}},
              "loopback": {"type": "boolean", "description": "True when it came from `POST /v1/inboxes/{inbox_id}/send`."},
              "attachments": {"type": "array", "items": {"$ref": "#/components/schemas/Attachment"}}
            }
          }
        ]
      },
      "SendRequest": {
        "type": "object",
        "required": ["to"],
        "properties": {
          "to": {"type": "array", "minItems": 1, "maxItems": 10, "items": {"type": "string", "format": "email"}, "description": "Addresses of your own organization's active inboxes, same mode as the key."},
          "subject": {"type": "string", "maxLength": 998},
          "text": {"type": "string"},
          "html": {"type": "string"},
          "in_reply_to": {"type": "string", "description": "A message id (`msg_...`) you own; threads the copy as a reply."}
        },
        "description": "Provide `text` and/or `html`."
      },
      "Send": {
        "type": "object",
        "required": ["id", "object", "from", "to", "subject", "delivered", "dropped"],
        "properties": {
          "id": {"type": "string", "example": "snd_1Qz7Lk4vB9nX2mRp8Yt3Wc"},
          "object": {"type": "string", "const": "send"},
          "from": {"type": "string", "format": "email"},
          "to": {"type": "array", "items": {"type": "string"}, "description": "Recipients, lower-cased and de-duplicated."},
          "subject": {"type": "string"},
          "delivered": {"type": "array", "items": {"type": "object", "required": ["inbox_id", "message_id"], "properties": {"inbox_id": {"type": "string"}, "message_id": {"type": "string"}}}},
          "dropped": {"type": "array", "items": {"type": "string"}, "description": "Inbox ids whose copy was refused by the e-mail quota (live mode only)."}
        }
      },
      "Limits": {
        "type": "object",
        "description": "The effective limit set for the organization's plan, admin overrides included. 0 means no cap for the daily fields.",
        "properties": {
          "requests_month": {"type": "integer"},
          "emails_month": {"type": "integer"},
          "emails_day": {"type": "integer"},
          "inboxes_active": {"type": "integer"},
          "domains": {"type": "integer"},
          "webhooks": {"type": "integer"},
          "seats": {"type": "integer"},
          "live_keys": {"type": "integer"},
          "retention_seconds": {"type": "integer"},
          "rate_per_sec": {"type": "integer"},
          "burst": {"type": "integer"},
          "inbox_creates_per_min": {"type": "integer"},
          "inboxes_day": {"type": "integer"},
          "ip_allowlist": {"type": "boolean"},
          "max_message_bytes": {"type": "integer"}
        }
      },
      "Meter": {
        "type": "object",
        "required": ["used", "limit"],
        "properties": {"used": {"type": "integer"}, "limit": {"type": "integer"}}
      },
      "Usage": {
        "type": "object",
        "required": ["period", "plan", "limits", "usage"],
        "properties": {
          "period": {"type": "object", "required": ["start", "end"], "properties": {"start": {"type": "string", "format": "date-time"}, "end": {"type": "string", "format": "date-time"}}},
          "plan": {"type": "string", "enum": ["sandbox", "developer", "team", "business", "enterprise"]},
          "limits": {"$ref": "#/components/schemas/Limits"},
          "usage": {"type": "object", "required": ["requests", "emails", "inboxes_active"], "properties": {
            "requests": {"$ref": "#/components/schemas/Meter"},
            "emails": {"$ref": "#/components/schemas/Meter"},
            "inboxes_active": {"$ref": "#/components/schemas/Meter"}
          }}
        }
      },
      "InjectTestMessageRequest": {
        "type": "object",
        "properties": {
          "from": {"type": "string", "description": "Defaults to the fixture sender."},
          "subject": {"type": "string", "description": "Defaults to `Test message`."},
          "text": {"type": "string"},
          "html": {"type": "string"}
        }
      },
      "WebhookEvent": {
        "type": "object",
        "required": ["id", "object", "type", "created", "livemode", "data"],
        "properties": {
          "id": {"type": "string", "example": "evt_6Rt2Kq9vB3xL1mZp8Hn4Wc"},
          "object": {"type": "string", "const": "event"},
          "type": {"type": "string", "enum": ["message.received", "inbox.expired", "quota.threshold"]},
          "created": {"type": "string", "format": "date-time"},
          "livemode": {"type": "boolean"},
          "data": {"type": "object", "description": "Shape depends on `type`; each entry under `webhooks` documents its own."}
        }
      }
    }
  }
}
