{
  "openapi": "3.1.0",
  "info": {
    "title": "recvmail API",
    "version": "v1",
    "description": "Receive-only email inboxes for AI agents. The contract in prose, with every rule this document cannot express: https://recvmail.net/docs/api. Paid calls are closed until the service opens; their payment challenge is not described yet. `x-recvmail-cost` on each operation says whether it is paid."
  },
  "externalDocs": {
    "url": "https://recvmail.net/docs/api"
  },
  "servers": [
    {
      "url": "https://api.recvmail.net"
    }
  ],
  "paths": {
    "/v1/health": {
      "get": {
        "operationId": "health",
        "summary": "Liveness",
        "externalDocs": {
          "url": "https://recvmail.net/docs/api#get-v1-health"
        },
        "x-recvmail-cost": "free",
        "security": [],
        "responses": {
          "200": {
            "description": "Up.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Health"
                }
              }
            }
          },
          "500": {
            "description": "`internal`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/inboxes": {
      "post": {
        "operationId": "provisionInbox",
        "summary": "Provision an inbox",
        "externalDocs": {
          "url": "https://recvmail.net/docs/api#post-v1-inboxes-provision-an-inbox"
        },
        "x-recvmail-cost": "paid",
        "security": [],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Send one on every paid call: a retry with the same key and body gets the original response.",
            "schema": {
              "type": "string",
              "pattern": "^[\\x21-\\x7e]{1,255}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProvisionRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The inbox and its two credentials, shown only here.",
            "headers": {
              "Idempotent-Replayed": {
                "description": "`true` when this is the stored response to an earlier request with the key.",
                "required": false,
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProvisionedInbox"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_request`, `out_of_bounds`",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/InvalidRequestError"
                    },
                    {
                      "$ref": "#/components/schemas/OutOfBoundsError"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "`unauthorized`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnauthorizedError"
                }
              }
            }
          },
          "409": {
            "description": "`idempotency_conflict`, `sender_opted_out`",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/IdempotencyConflictError"
                    },
                    {
                      "$ref": "#/components/schemas/SenderOptedOutError"
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "`internal`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/inboxes/{id}": {
      "get": {
        "operationId": "getInbox",
        "summary": "Inbox status",
        "externalDocs": {
          "url": "https://recvmail.net/docs/api#get-v1-inboxes-id-inbox-status"
        },
        "x-recvmail-cost": "free",
        "security": [
          {
            "owner": []
          },
          {
            "reader": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9abcdefghjkmnpqrstvwxyz]{20}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The inbox's status.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InboxStatus"
                }
              }
            }
          },
          "401": {
            "description": "`unauthorized`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnauthorizedError"
                }
              }
            }
          },
          "410": {
            "description": "`inbox_cancelled`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InboxCancelledError"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait.",
                "required": true,
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RateLimitedError"
                }
              }
            }
          },
          "500": {
            "description": "`internal`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/inboxes/{id}/messages": {
      "get": {
        "operationId": "pollMessages",
        "summary": "List messages and rejections since a cursor",
        "externalDocs": {
          "url": "https://recvmail.net/docs/api#get-v1-inboxes-id-messages-poll"
        },
        "x-recvmail-cost": "free",
        "security": [
          {
            "owner": []
          },
          {
            "reader": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9abcdefghjkmnpqrstvwxyz]{20}$"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^1\\.[0-9a-z]{1,11}$"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "default": 50,
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          }
        ],
        "responses": {
          "200": {
            "description": "What is new since the cursor.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PollResponse"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_request`, `out_of_bounds`",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/InvalidRequestError"
                    },
                    {
                      "$ref": "#/components/schemas/OutOfBoundsError"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "`unauthorized`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnauthorizedError"
                }
              }
            }
          },
          "410": {
            "description": "`inbox_cancelled`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InboxCancelledError"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait.",
                "required": true,
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RateLimitedError"
                }
              }
            }
          },
          "500": {
            "description": "`internal`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/inboxes/{id}/messages/{msg_id}": {
      "get": {
        "operationId": "downloadMessage",
        "summary": "Download a message as raw MIME; starts its five-minute deletion timer",
        "externalDocs": {
          "url": "https://recvmail.net/docs/api#get-v1-inboxes-id-messages-msg-id-download"
        },
        "x-recvmail-cost": "free",
        "security": [
          {
            "owner": []
          },
          {
            "reader": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9abcdefghjkmnpqrstvwxyz]{20}$"
            }
          },
          {
            "name": "msg_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^msg_[0-9abcdefghjkmnpqrstvwxyz]{20}$"
            }
          },
          {
            "name": "Range",
            "in": "header",
            "required": false,
            "description": "A single byte range: `bytes=0-99`, `bytes=100-`, `bytes=-50`.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The message exactly as received.",
            "headers": {
              "Content-Length": {
                "description": "Size in bytes.",
                "required": true,
                "schema": {
                  "type": "string"
                }
              },
              "ETag": {
                "description": "Entity tag of the stored message.",
                "required": true,
                "schema": {
                  "type": "string"
                }
              },
              "Accept-Ranges": {
                "description": "`bytes`.",
                "required": true,
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "message/rfc822": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "206": {
            "description": "The requested range.",
            "headers": {
              "Content-Range": {
                "description": "`bytes a-b/size`.",
                "required": true,
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "message/rfc822": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "description": "`unauthorized`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnauthorizedError"
                }
              }
            }
          },
          "404": {
            "description": "`message_not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageNotFoundError"
                }
              }
            }
          },
          "410": {
            "description": "`inbox_cancelled`, `message_gone`",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/InboxCancelledError"
                    },
                    {
                      "$ref": "#/components/schemas/MessageGoneError"
                    }
                  ]
                }
              }
            }
          },
          "416": {
            "description": "`range_not_satisfiable`",
            "headers": {
              "Content-Range": {
                "description": "`bytes */size`.",
                "required": true,
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RangeNotSatisfiableError"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait.",
                "required": true,
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RateLimitedError"
                }
              }
            }
          },
          "500": {
            "description": "`internal`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalError"
                }
              }
            }
          }
        }
      },
      "head": {
        "operationId": "inspectMessage",
        "summary": "The download's headers without the body; does not start the timer",
        "externalDocs": {
          "url": "https://recvmail.net/docs/api#get-v1-inboxes-id-messages-msg-id-download"
        },
        "x-recvmail-cost": "free",
        "security": [
          {
            "owner": []
          },
          {
            "reader": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9abcdefghjkmnpqrstvwxyz]{20}$"
            }
          },
          {
            "name": "msg_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^msg_[0-9abcdefghjkmnpqrstvwxyz]{20}$"
            }
          },
          {
            "name": "Range",
            "in": "header",
            "required": false,
            "description": "A single byte range: `bytes=0-99`, `bytes=100-`, `bytes=-50`.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The message exactly as received.",
            "headers": {
              "Content-Length": {
                "description": "Size in bytes.",
                "required": true,
                "schema": {
                  "type": "string"
                }
              },
              "ETag": {
                "description": "Entity tag of the stored message.",
                "required": true,
                "schema": {
                  "type": "string"
                }
              },
              "Accept-Ranges": {
                "description": "`bytes`.",
                "required": true,
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "`unauthorized`"
          },
          "404": {
            "description": "`message_not_found`"
          },
          "410": {
            "description": "`inbox_cancelled`, `message_gone`"
          },
          "416": {
            "description": "`range_not_satisfiable`",
            "headers": {
              "Content-Range": {
                "description": "`bytes */size`.",
                "required": true,
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait.",
                "required": true,
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "500": {
            "description": "`internal`"
          }
        }
      }
    },
    "/v1/inboxes/{id}/extend": {
      "post": {
        "operationId": "extendInbox",
        "summary": "Add one lifetime unit",
        "externalDocs": {
          "url": "https://recvmail.net/docs/api#post-v1-inboxes-id-extend-add-one-lifetime-unit"
        },
        "x-recvmail-cost": "paid",
        "security": [
          {
            "owner": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9abcdefghjkmnpqrstvwxyz]{20}$"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Send one on every paid call: a retry with the same key and body gets the original response.",
            "schema": {
              "type": "string",
              "pattern": "^[\\x21-\\x7e]{1,255}$"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExtendRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The status with the new values.",
            "headers": {
              "Idempotent-Replayed": {
                "description": "`true` when this is the stored response to an earlier request with the key.",
                "required": false,
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InboxStatus"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_request`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvalidRequestError"
                }
              }
            }
          },
          "401": {
            "description": "`unauthorized`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnauthorizedError"
                }
              }
            }
          },
          "403": {
            "description": "`forbidden`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ForbiddenError"
                }
              }
            }
          },
          "409": {
            "description": "`inbox_expired`, `idempotency_conflict`",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/InboxExpiredError"
                    },
                    {
                      "$ref": "#/components/schemas/IdempotencyConflictError"
                    }
                  ]
                }
              }
            }
          },
          "410": {
            "description": "`inbox_cancelled`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InboxCancelledError"
                }
              }
            }
          },
          "500": {
            "description": "`internal`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/inboxes/{id}/sender-domains": {
      "put": {
        "operationId": "setSenderDomains",
        "summary": "Replace the sender-domain allowlist",
        "externalDocs": {
          "url": "https://recvmail.net/docs/api#put-v1-inboxes-id-sender-domains-replace-the-sender-domain-allowlist"
        },
        "x-recvmail-cost": "free",
        "security": [
          {
            "owner": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9abcdefghjkmnpqrstvwxyz]{20}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SenderDomainsRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The status with the new list.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InboxStatus"
                }
              }
            }
          },
          "400": {
            "description": "`invalid_request`, `out_of_bounds`",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/InvalidRequestError"
                    },
                    {
                      "$ref": "#/components/schemas/OutOfBoundsError"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "`unauthorized`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnauthorizedError"
                }
              }
            }
          },
          "403": {
            "description": "`forbidden`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ForbiddenError"
                }
              }
            }
          },
          "409": {
            "description": "`inbox_expired`, `sender_opted_out`",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/InboxExpiredError"
                    },
                    {
                      "$ref": "#/components/schemas/SenderOptedOutError"
                    }
                  ]
                }
              }
            }
          },
          "410": {
            "description": "`inbox_cancelled`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InboxCancelledError"
                }
              }
            }
          },
          "429": {
            "description": "`rate_limited`",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait.",
                "required": true,
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RateLimitedError"
                }
              }
            }
          },
          "500": {
            "description": "`internal`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalError"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ProvisionRequest": {
        "type": "object",
        "properties": {
          "sender_domains": {
            "maxItems": 20,
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^(?=.{1,254}$)([A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?\\.)+[A-Za-z0-9-]{2,63}\\.?$"
            }
          }
        },
        "additionalProperties": false
      },
      "ExtendRequest": {
        "type": "object",
        "properties": {},
        "additionalProperties": false
      },
      "SenderDomainsRequest": {
        "type": "object",
        "properties": {
          "sender_domains": {
            "maxItems": 20,
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^(?=.{1,254}$)([A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?\\.)+[A-Za-z0-9-]{2,63}\\.?$"
            }
          }
        },
        "required": [
          "sender_domains"
        ]
      },
      "Health": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean",
            "const": true
          },
          "environment": {
            "type": "string",
            "enum": [
              "dev",
              "prod"
            ]
          }
        },
        "required": [
          "ok",
          "environment"
        ]
      },
      "ProvisionedInbox": {
        "type": "object",
        "properties": {
          "inbox_id": {
            "type": "string",
            "pattern": "^[0-9abcdefghjkmnpqrstvwxyz]{20}$"
          },
          "address": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "quota_bytes": {
            "type": "integer",
            "minimum": 0
          },
          "sender_domains": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "credentials": {
            "type": "object",
            "properties": {
              "owner": {
                "type": "string",
                "pattern": "^rmo_[0-9abcdefghjkmnpqrstvwxyz]{32}$"
              },
              "reader": {
                "type": "string",
                "pattern": "^rmr_[0-9abcdefghjkmnpqrstvwxyz]{32}$"
              }
            },
            "required": [
              "owner",
              "reader"
            ]
          }
        },
        "required": [
          "inbox_id",
          "address",
          "created_at",
          "expires_at",
          "quota_bytes",
          "sender_domains",
          "credentials"
        ]
      },
      "InboxStatus": {
        "type": "object",
        "properties": {
          "inbox_id": {
            "type": "string",
            "pattern": "^[0-9abcdefghjkmnpqrstvwxyz]{20}$"
          },
          "address": {
            "type": "string"
          },
          "state": {
            "type": "string",
            "enum": [
              "live",
              "expired"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "quota_bytes": {
            "type": "integer",
            "minimum": 0
          },
          "quota_used_bytes": {
            "type": "integer",
            "minimum": 0
          },
          "message_count": {
            "type": "integer",
            "minimum": 0
          },
          "rejection_count": {
            "type": "integer",
            "minimum": 0
          },
          "sender_domains": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "inbox_id",
          "address",
          "state",
          "created_at",
          "expires_at",
          "quota_bytes",
          "quota_used_bytes",
          "message_count",
          "rejection_count",
          "sender_domains"
        ]
      },
      "Mailbox": {
        "type": "object",
        "properties": {
          "name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "address": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "name",
          "address"
        ]
      },
      "AuthVerdict": {
        "type": "object",
        "properties": {
          "result": {
            "type": "string"
          },
          "domain": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "result",
          "domain"
        ]
      },
      "Authentication": {
        "type": "object",
        "properties": {
          "dmarc": {
            "$ref": "#/components/schemas/AuthVerdict"
          },
          "dkim": {
            "$ref": "#/components/schemas/AuthVerdict"
          },
          "spf": {
            "$ref": "#/components/schemas/AuthVerdict"
          }
        },
        "required": [
          "dmarc",
          "dkim",
          "spf"
        ]
      },
      "MessageSummary": {
        "type": "object",
        "properties": {
          "message_id": {
            "type": "string",
            "pattern": "^msg_[0-9abcdefghjkmnpqrstvwxyz]{20}$"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "from": {
            "$ref": "#/components/schemas/Mailbox"
          },
          "envelope_from": {
            "type": "string"
          },
          "subject": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "size_bytes": {
            "type": "integer",
            "minimum": 0
          },
          "received_at": {
            "type": "string",
            "format": "date-time"
          },
          "downloaded_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "delete_after": {
            "type": "string",
            "format": "date-time"
          },
          "internet_message_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "authentication": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Authentication"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "message_id",
          "url",
          "from",
          "envelope_from",
          "subject",
          "size_bytes",
          "received_at",
          "downloaded_at",
          "delete_after",
          "internet_message_id",
          "authentication"
        ]
      },
      "RejectionEvent": {
        "type": "object",
        "properties": {
          "at": {
            "type": "string",
            "format": "date-time"
          },
          "envelope_from": {
            "type": "string"
          },
          "reason": {
            "type": "string",
            "enum": [
              "quota",
              "sender_not_allowed",
              "sender_opted_out"
            ]
          },
          "sender_domain": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "size_bytes": {
            "type": "integer",
            "minimum": 0
          }
        },
        "required": [
          "at",
          "envelope_from",
          "reason",
          "sender_domain",
          "size_bytes"
        ]
      },
      "PollResponse": {
        "type": "object",
        "properties": {
          "inbox": {
            "$ref": "#/components/schemas/InboxStatus"
          },
          "server_time": {
            "type": "string",
            "format": "date-time"
          },
          "messages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MessageSummary"
            }
          },
          "rejections": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RejectionEvent"
            }
          },
          "next_cursor": {
            "type": "string",
            "pattern": "^1\\.[0-9a-z]{1,11}$"
          },
          "next_url": {
            "type": "string",
            "format": "uri"
          },
          "has_more": {
            "type": "boolean"
          }
        },
        "required": [
          "inbox",
          "server_time",
          "messages",
          "rejections",
          "next_cursor",
          "next_url",
          "has_more"
        ]
      },
      "UnauthorizedError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "const": "unauthorized"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ]
          }
        },
        "required": [
          "error"
        ]
      },
      "ForbiddenError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "const": "forbidden"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ]
          }
        },
        "required": [
          "error"
        ]
      },
      "NotFoundError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "const": "not_found"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ]
          }
        },
        "required": [
          "error"
        ]
      },
      "InboxNotFoundError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "const": "inbox_not_found"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ]
          }
        },
        "required": [
          "error"
        ]
      },
      "MessageNotFoundError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "const": "message_not_found"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ]
          }
        },
        "required": [
          "error"
        ]
      },
      "MessageGoneError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "const": "message_gone"
              },
              "message": {
                "type": "string"
              },
              "details": {
                "type": "object",
                "properties": {
                  "reason": {
                    "type": "string",
                    "enum": [
                      "downloaded",
                      "unclaimed",
                      "expired",
                      "lost"
                    ]
                  }
                },
                "required": [
                  "reason"
                ]
              }
            },
            "required": [
              "code",
              "message",
              "details"
            ]
          }
        },
        "required": [
          "error"
        ]
      },
      "InboxCancelledError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "const": "inbox_cancelled"
              },
              "message": {
                "type": "string"
              },
              "details": {
                "type": "object",
                "properties": {
                  "reason": {
                    "type": "string",
                    "const": "abuse"
                  },
                  "cancelled_at": {
                    "type": "string",
                    "format": "date-time"
                  }
                },
                "required": [
                  "reason",
                  "cancelled_at"
                ]
              }
            },
            "required": [
              "code",
              "message",
              "details"
            ]
          }
        },
        "required": [
          "error"
        ]
      },
      "InboxExpiredError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "const": "inbox_expired"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ]
          }
        },
        "required": [
          "error"
        ]
      },
      "IdempotencyConflictError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "const": "idempotency_conflict"
              },
              "message": {
                "type": "string"
              },
              "details": {
                "type": "object",
                "properties": {
                  "field": {
                    "type": "string",
                    "const": "Idempotency-Key"
                  }
                },
                "required": [
                  "field"
                ]
              }
            },
            "required": [
              "code",
              "message",
              "details"
            ]
          }
        },
        "required": [
          "error"
        ]
      },
      "SenderOptedOutError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "const": "sender_opted_out"
              },
              "message": {
                "type": "string"
              },
              "details": {
                "type": "object",
                "properties": {
                  "field": {
                    "type": "string",
                    "const": "sender_domains"
                  },
                  "domains": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                },
                "required": [
                  "field",
                  "domains"
                ]
              }
            },
            "required": [
              "code",
              "message",
              "details"
            ]
          }
        },
        "required": [
          "error"
        ]
      },
      "InvalidRequestError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "const": "invalid_request"
              },
              "message": {
                "type": "string"
              },
              "details": {
                "type": "object",
                "properties": {
                  "field": {
                    "type": "string"
                  }
                },
                "required": [
                  "field"
                ]
              }
            },
            "required": [
              "code",
              "message"
            ]
          }
        },
        "required": [
          "error"
        ]
      },
      "OutOfBoundsError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "const": "out_of_bounds"
              },
              "message": {
                "type": "string"
              },
              "details": {
                "type": "object",
                "properties": {
                  "field": {
                    "type": "string"
                  },
                  "min": {
                    "type": "integer"
                  },
                  "max": {
                    "type": "integer"
                  },
                  "got": {}
                },
                "required": [
                  "field",
                  "min",
                  "max"
                ]
              }
            },
            "required": [
              "code",
              "message",
              "details"
            ]
          }
        },
        "required": [
          "error"
        ]
      },
      "RangeNotSatisfiableError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "const": "range_not_satisfiable"
              },
              "message": {
                "type": "string"
              },
              "details": {
                "type": "object",
                "properties": {
                  "size_bytes": {
                    "type": "integer",
                    "minimum": 0
                  }
                },
                "required": [
                  "size_bytes"
                ]
              }
            },
            "required": [
              "code",
              "message",
              "details"
            ]
          }
        },
        "required": [
          "error"
        ]
      },
      "RateLimitedError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "const": "rate_limited"
              },
              "message": {
                "type": "string"
              },
              "details": {
                "type": "object",
                "properties": {
                  "retry_after_seconds": {
                    "type": "integer",
                    "minimum": 1
                  }
                },
                "required": [
                  "retry_after_seconds"
                ]
              }
            },
            "required": [
              "code",
              "message",
              "details"
            ]
          }
        },
        "required": [
          "error"
        ]
      },
      "InternalError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "const": "internal"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ]
          }
        },
        "required": [
          "error"
        ]
      }
    },
    "securitySchemes": {
      "owner": {
        "type": "http",
        "scheme": "bearer",
        "description": "The inbox's owner credential (`rmo_…`): every call on the inbox."
      },
      "reader": {
        "type": "http",
        "scheme": "bearer",
        "description": "The inbox's reader credential (`rmr_…`): poll and download only."
      }
    }
  }
}
