{
  "openapi": "3.1.0",
  "servers": [
    {
      "url": "https://inbound.new",
      "description": "Production API server"
    }
  ],
  "info": {
    "title": "Inbound Email API",
    "description": "\n# Inbound API\n\nThe Inbound API allows you to manage email infrastructure programmatically - domains, email addresses, webhooks, and more.\n\n## Authentication\n\nAll API requests require a Bearer token in the Authorization header:\n\n```bash\ncurl -H \"Authorization: Bearer YOUR_API_KEY\" \\\n  https://inbound.new/api/e2/domains\n```\n\n## Base URL\n\n```\nhttps://inbound.new/api/e2\n```\n\n## Quick Start\n\n1. **Create a domain** - Register your domain with Inbound\n2. **Configure DNS** - Add the provided DNS records to your domain\n3. **Create an email address** - Set up addresses to receive emails\n4. **Create an endpoint** - Configure where emails are delivered (webhook, forwarding, etc.)\n\n",
    "version": "2.0.0"
  },
  "webhooks": {
    "emailReceived": {
      "post": {
        "summary": "Email Received",
        "description": "\nWhen emails arrive at your configured addresses, Inbound sends a webhook to your endpoint with the complete email data.\n\n## Webhook Payload Structure\n\nWe provide a fully typed webhook payload for you to use in your endpoints:\n\n```typescript\nimport type { InboundWebhookPayload } from 'inboundemail'\n```\n\n### Example Payload\n\n```typescript\nconst payload: InboundWebhookPayload = {\n  event: 'email.received',\n  timestamp: '2024-01-15T10:30:00Z',\n  email: {\n    id: 'inbnd_abc123def456ghi',\n    messageId: '<unique-id@sender.com>',\n    from: {\n      text: 'John Doe <john@sender.com>',\n      addresses: [{\n        name: 'John Doe',\n        address: 'john@sender.com'\n      }]\n    },\n    to: {\n      text: 'support@yourdomain.com',\n      addresses: [{\n        name: null,\n        address: 'support@yourdomain.com'\n      }]\n    },\n    recipient: 'support@yourdomain.com',\n    subject: 'Help with my order',\n    receivedAt: '2024-01-15T10:30:00Z',\n    parsedData: {\n      messageId: '<unique-id@sender.com>',\n      date: new Date('2024-01-15T10:30:00Z'),\n      subject: 'Help with my order',\n      from: { /* ... */ },\n      to: { /* ... */ },\n      cc: null,\n      bcc: null,\n      replyTo: null,\n      textBody: 'Hello, I need help with my recent order...',\n      htmlBody: '<p>Hello, I need help with my recent order...</p>',\n      attachments: [\n        {\n          filename: 'order-receipt.pdf',\n          contentType: 'application/pdf',\n          size: 45678,\n          contentId: '<att_abc123>',\n          contentDisposition: 'attachment',\n          downloadUrl: 'https://inbound.new/api/e2/attachments/inbnd_abc123/parts/0'\n        }\n      ]\n    }\n  },\n  endpoint: {\n    id: 'endp_xyz789',\n    name: 'Support Webhook',\n    type: 'webhook'\n  }\n}\n```\n\n## Webhook Security\n\nAlways verify webhook requests before processing them to prevent unauthorized access.\n\n### Verification Headers\n\nEvery webhook request includes security headers:\n\n| Header | Description |\n|--------|-------------|\n| `X-Webhook-Verification-Token` | Unique verification token for your endpoint |\n| `X-Endpoint-ID` | ID of the endpoint that triggered this webhook |\n| `X-Webhook-Event` | Event type (e.g., `email.received`) |\n| `X-Webhook-Timestamp` | ISO 8601 timestamp of when the webhook was sent |\n\n### Verifying with the SDK\n\n```typescript\nimport { Inbound, verifyWebhookFromHeaders } from 'inboundemail'\n\nconst inbound = new Inbound(process.env.INBOUND_API_KEY!)\n\nexport async function POST(request: Request) {\n  // Verify webhook authenticity before processing\n  const isValid = await verifyWebhookFromHeaders(request.headers, inbound)\n  \n  if (!isValid) {\n    return new Response('Unauthorized', { status: 401 })\n  }\n  \n  // Process the verified webhook payload\n  const payload: InboundWebhookPayload = await request.json()\n  const { email } = payload\n  \n  console.log('Received verified email:', email.subject)\n  \n  return new Response('OK', { status: 200 })\n}\n```\n\n## Downloading Attachments\n\nEach attachment includes a `downloadUrl` for direct file access:\n\n```typescript\n// Download attachments from webhook payload\nfor (const attachment of email.parsedData.attachments) {\n  const response = await fetch(attachment.downloadUrl, {\n    headers: {\n      'Authorization': `Bearer ${process.env.INBOUND_API_KEY}`\n    }\n  })\n  \n  if (response.ok) {\n    const fileBuffer = await response.arrayBuffer()\n    // Process the file...\n  }\n}\n```\n\n> **Note:** Authentication via API key in the Authorization header is required to download attachments.\n",
        "tags": [
          "Webhooks"
        ],
        "requestBody": {
          "description": "Webhook payload sent when an email is received",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "event": {
                    "type": "string",
                    "example": "email.received",
                    "description": "The event type"
                  },
                  "timestamp": {
                    "type": "string",
                    "format": "date-time",
                    "example": "2024-01-15T10:30:00Z"
                  },
                  "email": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "example": "inbnd_abc123def456ghi"
                      },
                      "messageId": {
                        "type": "string",
                        "example": "<unique-id@sender.com>"
                      },
                      "subject": {
                        "type": "string",
                        "example": "Help with my order"
                      },
                      "recipient": {
                        "type": "string",
                        "example": "support@yourdomain.com"
                      },
                      "from": {
                        "type": "object",
                        "properties": {
                          "text": {
                            "type": "string"
                          },
                          "addresses": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "name": {
                                  "type": [
                                    "string",
                                    "null"
                                  ]
                                },
                                "address": {
                                  "type": "string"
                                }
                              }
                            }
                          }
                        }
                      },
                      "to": {
                        "type": "object",
                        "properties": {
                          "text": {
                            "type": "string"
                          },
                          "addresses": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "name": {
                                  "type": [
                                    "string",
                                    "null"
                                  ]
                                },
                                "address": {
                                  "type": "string"
                                }
                              }
                            }
                          }
                        }
                      },
                      "parsedData": {
                        "type": "object",
                        "properties": {
                          "textBody": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "htmlBody": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "attachments": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "filename": {
                                  "type": "string"
                                },
                                "contentType": {
                                  "type": "string"
                                },
                                "size": {
                                  "type": "integer"
                                },
                                "downloadUrl": {
                                  "type": "string"
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  },
                  "endpoint": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "example": "endp_xyz789"
                      },
                      "name": {
                        "type": "string",
                        "example": "Support Webhook"
                      },
                      "type": {
                        "type": "string",
                        "example": "webhook"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Webhook processed successfully"
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "Webhooks",
      "description": "Webhooks sent by Inbound to your configured endpoints when events occur."
    },
    {
      "name": "Emails",
      "description": "Send, list, and manage emails. Supports immediate sending, scheduling, replies, and retry functionality."
    },
    {
      "name": "Mail",
      "description": "Inbox and thread views for received emails. Filter by domain, address, or search."
    },
    {
      "name": "Domains",
      "description": "Manage domains for sending and receiving emails. Domains must be verified via DNS before use."
    },
    {
      "name": "Endpoints",
      "description": "Configure where incoming emails are delivered - webhooks, email forwarding, or custom handlers."
    },
    {
      "name": "Email Addresses",
      "description": "Create and manage email addresses on your verified domains."
    },
    {
      "name": "Attachments",
      "description": "Download email attachments using authenticated requests."
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "API Key",
        "description": "Your Inbound API key. Include it in the Authorization header as: Bearer <your-api-key>"
      }
    },
    "schemas": {}
  },
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/api/e2/domains": {
      "get": {
        "tags": [
          "Domains"
        ],
        "summary": "List all domains",
        "description": "Get paginated list of domains for authenticated user with optional filtering.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "anyOf": [
                {
                  "format": "integer",
                  "default": 0,
                  "type": "string"
                },
                {
                  "minimum": 1,
                  "maximum": 100,
                  "default": 50,
                  "type": "integer"
                }
              ]
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "minimum": 0,
              "default": 0,
              "anyOf": [
                {
                  "format": "integer",
                  "default": 0,
                  "type": "string"
                },
                {
                  "minimum": 0,
                  "default": 0,
                  "type": "integer"
                }
              ]
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "enum": [
                "pending",
                "verified",
                "failed"
              ],
              "type": "string"
            }
          },
          {
            "name": "canReceive",
            "in": "query",
            "required": false,
            "schema": {
              "enum": [
                "true",
                "false"
              ],
              "type": "string"
            }
          },
          {
            "name": "check",
            "in": "query",
            "required": false,
            "schema": {
              "enum": [
                "true"
              ],
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "domain": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "canReceiveEmails": {
                            "type": "boolean"
                          },
                          "hasMxRecords": {
                            "type": "boolean"
                          },
                          "domainProvider": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "providerConfidence": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "lastDnsCheck": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "lastSesCheck": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "isCatchAllEnabled": {
                            "type": "boolean"
                          },
                          "catchAllEndpointId": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "includeSubdomains": {
                            "type": "boolean"
                          },
                          "mailFromDomain": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "mailFromDomainStatus": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "mailFromDomainVerifiedAt": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "receiveDmarcEmails": {
                            "type": "boolean"
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updatedAt": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "userId": {
                            "type": "string"
                          },
                          "stats": {
                            "type": "object",
                            "properties": {
                              "totalEmailAddresses": {
                                "type": "number"
                              },
                              "activeEmailAddresses": {
                                "type": "number"
                              },
                              "hasCatchAll": {
                                "type": "boolean"
                              }
                            },
                            "required": [
                              "totalEmailAddresses",
                              "activeEmailAddresses",
                              "hasCatchAll"
                            ]
                          },
                          "catchAllEndpoint": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string"
                                  },
                                  "name": {
                                    "type": "string"
                                  },
                                  "type": {
                                    "type": "string"
                                  },
                                  "isActive": {
                                    "type": "boolean"
                                  }
                                },
                                "required": [
                                  "id",
                                  "name",
                                  "type",
                                  "isActive"
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "verificationCheck": {
                            "type": "object",
                            "properties": {
                              "dnsRecords": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string"
                                    },
                                    "name": {
                                      "type": "string"
                                    },
                                    "value": {
                                      "type": "string"
                                    },
                                    "isVerified": {
                                      "type": "boolean"
                                    },
                                    "error": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "name",
                                    "value",
                                    "isVerified"
                                  ]
                                }
                              },
                              "sesStatus": {
                                "type": "string"
                              },
                              "isFullyVerified": {
                                "type": "boolean"
                              },
                              "lastChecked": {
                                "format": "date-time",
                                "type": "string"
                              }
                            },
                            "required": [
                              "dnsRecords",
                              "sesStatus",
                              "isFullyVerified",
                              "lastChecked"
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "domain",
                          "status",
                          "canReceiveEmails",
                          "hasMxRecords",
                          "domainProvider",
                          "providerConfidence",
                          "lastDnsCheck",
                          "lastSesCheck",
                          "isCatchAllEnabled",
                          "catchAllEndpointId",
                          "includeSubdomains",
                          "mailFromDomain",
                          "mailFromDomainStatus",
                          "mailFromDomainVerifiedAt",
                          "receiveDmarcEmails",
                          "createdAt",
                          "updatedAt",
                          "userId",
                          "stats"
                        ]
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "limit": {
                          "type": "number"
                        },
                        "offset": {
                          "type": "number"
                        },
                        "total": {
                          "type": "number"
                        },
                        "hasMore": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "limit",
                        "offset",
                        "total",
                        "hasMore"
                      ]
                    },
                    "capabilities": {
                      "type": "object",
                      "properties": {
                        "envelopeRecipients": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "envelopeRecipients"
                      ]
                    }
                  },
                  "required": [
                    "data",
                    "pagination",
                    "capabilities"
                  ]
                }
              }
            }
          }
        },
        "operationId": "getApiE2Domains"
      },
      "post": {
        "tags": [
          "Domains"
        ],
        "summary": "Create new domain",
        "description": "Add a new domain for email receiving. Automatically initiates verification and returns required DNS records. Subdomains inherit verification from their verified parent domain.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "domain": {
                    "minLength": 1,
                    "maxLength": 253,
                    "type": "string"
                  }
                },
                "required": [
                  "domain"
                ]
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "domain": {
                    "minLength": 1,
                    "maxLength": 253,
                    "type": "string"
                  }
                },
                "required": [
                  "domain"
                ]
              }
            },
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "domain": {
                    "minLength": 1,
                    "maxLength": 253,
                    "type": "string"
                  }
                },
                "required": [
                  "domain"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Response for status 201",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "domain": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "pending",
                        "verified",
                        "failed"
                      ]
                    },
                    "canReceiveEmails": {
                      "type": "boolean"
                    },
                    "hasMxRecords": {
                      "type": "boolean"
                    },
                    "domainProvider": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "providerConfidence": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "mailFromDomain": {
                      "type": "string"
                    },
                    "mailFromDomainStatus": {
                      "type": "string"
                    },
                    "dnsRecords": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "value": {
                            "type": "string"
                          },
                          "description": {
                            "type": "string"
                          },
                          "isRequired": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "type",
                          "name",
                          "value",
                          "isRequired"
                        ]
                      }
                    },
                    "dnsConflict": {
                      "type": "object",
                      "properties": {
                        "hasConflict": {
                          "type": "boolean"
                        },
                        "conflictType": {
                          "type": "string",
                          "enum": [
                            "mx",
                            "cname",
                            "both"
                          ]
                        },
                        "message": {
                          "type": "string"
                        },
                        "existingRecords": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string"
                              },
                              "value": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "type",
                              "value"
                            ]
                          }
                        }
                      },
                      "required": [
                        "hasConflict",
                        "message"
                      ]
                    },
                    "createdAt": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updatedAt": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "parentDomain": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "domain",
                    "status",
                    "canReceiveEmails",
                    "hasMxRecords",
                    "domainProvider",
                    "providerConfidence",
                    "dnsRecords",
                    "createdAt",
                    "updatedAt"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Response for status 400",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Response for status 403",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Response for status 409",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "postApiE2Domains"
      }
    },
    "/api/e2/domains/{id}": {
      "get": {
        "tags": [
          "Domains"
        ],
        "summary": "Get domain by ID",
        "description": "Get detailed information about a specific domain including DNS records. Use `?check=true` for a live verification check.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "check",
            "in": "query",
            "required": false,
            "schema": {
              "enum": [
                "true"
              ],
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "domain": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "canReceiveEmails": {
                      "type": "boolean"
                    },
                    "hasMxRecords": {
                      "type": "boolean"
                    },
                    "domainProvider": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "providerConfidence": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "lastDnsCheck": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "lastSesCheck": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "isCatchAllEnabled": {
                      "type": "boolean"
                    },
                    "catchAllEndpointId": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "includeSubdomains": {
                      "type": "boolean"
                    },
                    "subdomainDnsRecords": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "value": {
                            "type": "string"
                          },
                          "description": {
                            "type": "string"
                          },
                          "isRequired": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "type",
                          "name",
                          "value",
                          "isRequired"
                        ]
                      }
                    },
                    "mailFromDomain": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "mailFromDomainStatus": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "mailFromDomainVerifiedAt": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "receiveDmarcEmails": {
                      "type": "boolean"
                    },
                    "createdAt": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updatedAt": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "userId": {
                      "type": "string"
                    },
                    "stats": {
                      "type": "object",
                      "properties": {
                        "totalEmailAddresses": {
                          "type": "number"
                        },
                        "activeEmailAddresses": {
                          "type": "number"
                        },
                        "emailsLast24h": {
                          "type": "number"
                        },
                        "emailsLast7d": {
                          "type": "number"
                        },
                        "emailsLast30d": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "totalEmailAddresses",
                        "activeEmailAddresses",
                        "emailsLast24h",
                        "emailsLast7d",
                        "emailsLast30d"
                      ]
                    },
                    "catchAllEndpoint": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            },
                            "type": {
                              "type": "string"
                            },
                            "isActive": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "id",
                            "name",
                            "type",
                            "isActive"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "dnsRecords": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "domainId": {
                            "type": "string"
                          },
                          "recordType": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "value": {
                            "type": "string"
                          },
                          "isRequired": {
                            "type": "boolean"
                          },
                          "isVerified": {
                            "type": "boolean"
                          },
                          "lastChecked": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "domainId",
                          "recordType",
                          "name",
                          "value",
                          "isRequired",
                          "isVerified",
                          "lastChecked",
                          "createdAt"
                        ]
                      }
                    },
                    "verificationCheck": {
                      "type": "object",
                      "properties": {
                        "dnsRecords": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string"
                              },
                              "name": {
                                "type": "string"
                              },
                              "value": {
                                "type": "string"
                              },
                              "isVerified": {
                                "type": "boolean"
                              },
                              "error": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "type",
                              "name",
                              "value",
                              "isVerified"
                            ]
                          }
                        },
                        "sesStatus": {
                          "type": "string"
                        },
                        "dkimStatus": {
                          "type": "string"
                        },
                        "dkimVerified": {
                          "type": "boolean"
                        },
                        "dkimTokens": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "mailFromDomain": {
                          "type": "string"
                        },
                        "mailFromStatus": {
                          "type": "string"
                        },
                        "mailFromVerified": {
                          "type": "boolean"
                        },
                        "isFullyVerified": {
                          "type": "boolean"
                        },
                        "lastChecked": {
                          "format": "date-time",
                          "type": "string"
                        }
                      },
                      "required": [
                        "dnsRecords",
                        "sesStatus",
                        "isFullyVerified",
                        "lastChecked"
                      ]
                    },
                    "authRecommendations": {
                      "type": "object",
                      "properties": {
                        "spf": {
                          "type": "object",
                          "properties": {
                            "name": {
                              "type": "string"
                            },
                            "value": {
                              "type": "string"
                            },
                            "description": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "name",
                            "value",
                            "description"
                          ]
                        },
                        "dmarc": {
                          "type": "object",
                          "properties": {
                            "name": {
                              "type": "string"
                            },
                            "value": {
                              "type": "string"
                            },
                            "description": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "name",
                            "value",
                            "description"
                          ]
                        }
                      }
                    },
                    "inheritsFromParent": {
                      "type": "boolean"
                    },
                    "parentDomain": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "kind": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "domain",
                    "status",
                    "canReceiveEmails",
                    "hasMxRecords",
                    "domainProvider",
                    "providerConfidence",
                    "lastDnsCheck",
                    "lastSesCheck",
                    "isCatchAllEnabled",
                    "catchAllEndpointId",
                    "includeSubdomains",
                    "subdomainDnsRecords",
                    "mailFromDomain",
                    "mailFromDomainStatus",
                    "mailFromDomainVerifiedAt",
                    "receiveDmarcEmails",
                    "createdAt",
                    "updatedAt",
                    "userId",
                    "stats",
                    "dnsRecords"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Response for status 404",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "getApiE2DomainsById"
      },
      "patch": {
        "tags": [
          "Domains"
        ],
        "summary": "Update domain catch-all and subdomain settings",
        "description": "Update catch-all email settings for a domain. Catch-all receives emails sent to any address on your domain. Set includeSubdomains on a verified root domain to also receive mail for every subdomain (publish the returned wildcard MX record); subdomain mail is delivered to the root domain's catch-all endpoint. Domain must be verified first.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "isCatchAllEnabled": {
                    "type": "boolean"
                  },
                  "catchAllEndpointId": {
                    "nullable": true,
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "includeSubdomains": {
                    "type": "boolean"
                  }
                }
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "isCatchAllEnabled": {
                    "type": "boolean"
                  },
                  "catchAllEndpointId": {
                    "nullable": true,
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "includeSubdomains": {
                    "type": "boolean"
                  }
                }
              }
            },
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "isCatchAllEnabled": {
                    "type": "boolean"
                  },
                  "catchAllEndpointId": {
                    "nullable": true,
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "includeSubdomains": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "domain": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "isCatchAllEnabled": {
                      "type": "boolean"
                    },
                    "catchAllEndpointId": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "catchAllEndpoint": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            },
                            "type": {
                              "type": "string"
                            },
                            "isActive": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "id",
                            "name",
                            "type",
                            "isActive"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "includeSubdomains": {
                      "type": "boolean"
                    },
                    "subdomainDnsRecords": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "value": {
                            "type": "string"
                          },
                          "description": {
                            "type": "string"
                          },
                          "isRequired": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "type",
                          "name",
                          "value",
                          "isRequired"
                        ]
                      }
                    },
                    "updatedAt": {
                      "format": "date-time",
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "domain",
                    "status",
                    "isCatchAllEnabled",
                    "catchAllEndpointId",
                    "includeSubdomains",
                    "subdomainDnsRecords",
                    "updatedAt"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Response for status 400",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Response for status 404",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Response for status 409",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "patchApiE2DomainsById"
      },
      "delete": {
        "tags": [
          "Domains"
        ],
        "summary": "Delete domain",
        "description": "Delete a domain and all associated resources including email addresses, DNS records, and SES configurations. Root domains with subdomains must have subdomains deleted first.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "deletedResources": {
                      "type": "object",
                      "properties": {
                        "domain": {
                          "type": "string"
                        },
                        "emailAddresses": {
                          "type": "number"
                        },
                        "dnsRecords": {
                          "type": "number"
                        },
                        "blockedEmails": {
                          "type": "number"
                        },
                        "sesIdentity": {
                          "type": "boolean"
                        },
                        "sesReceiptRules": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "domain",
                        "emailAddresses",
                        "dnsRecords",
                        "blockedEmails",
                        "sesIdentity",
                        "sesReceiptRules"
                      ]
                    }
                  },
                  "required": [
                    "success",
                    "message",
                    "deletedResources"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "dependentSubdomains": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "domain": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "domain",
                          "status"
                        ]
                      }
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Response for status 404",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "dependentSubdomains": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "domain": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "domain",
                          "status"
                        ]
                      }
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Response for status 409",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "dependentSubdomains": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "domain": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "domain",
                          "status"
                        ]
                      }
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "dependentSubdomains": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "domain": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "domain",
                          "status"
                        ]
                      }
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "deleteApiE2DomainsById"
      }
    },
    "/api/e2/domains/{id}/dkim": {
      "post": {
        "tags": [
          "Domains"
        ],
        "summary": "Enable DKIM",
        "description": "Start DKIM signing for a domain and return the three CNAME records to add to its DNS. Until they are published, mail is still sent and signed by Amazon SES. Safe to call again: it returns the existing records, or restarts setup after a failure.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "domain": {
                      "type": "string"
                    },
                    "dkimStatus": {
                      "description": "SES DKIM status: PENDING until the CNAME records are found, then SUCCESS",
                      "type": "string"
                    },
                    "dnsRecords": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "value": {
                            "type": "string"
                          },
                          "isRequired": {
                            "type": "boolean"
                          },
                          "description": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "type",
                          "name",
                          "value",
                          "isRequired",
                          "description"
                        ]
                      }
                    }
                  },
                  "required": [
                    "domain",
                    "dkimStatus",
                    "dnsRecords"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Response for status 404",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Response for status 409",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "502": {
            "description": "Response for status 502",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "postApiE2DomainsByIdDkim"
      }
    },
    "/api/e2/endpoints": {
      "get": {
        "tags": [
          "Endpoints"
        ],
        "summary": "List all endpoints",
        "description": "Get paginated list of endpoints for authenticated user with optional filtering by type, active status, sort order, and search by name",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "anyOf": [
                {
                  "format": "integer",
                  "default": 0,
                  "type": "string"
                },
                {
                  "minimum": 1,
                  "maximum": 100,
                  "default": 50,
                  "type": "integer"
                }
              ]
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "minimum": 0,
              "default": 0,
              "anyOf": [
                {
                  "format": "integer",
                  "default": 0,
                  "type": "string"
                },
                {
                  "minimum": 0,
                  "default": 0,
                  "type": "integer"
                }
              ]
            }
          },
          {
            "name": "type",
            "in": "query",
            "required": false,
            "schema": {
              "enum": [
                "webhook",
                "email",
                "email_group"
              ],
              "type": "string"
            }
          },
          {
            "name": "active",
            "in": "query",
            "required": false,
            "schema": {
              "enum": [
                "true",
                "false"
              ],
              "type": "string"
            }
          },
          {
            "name": "sortBy",
            "in": "query",
            "required": false,
            "schema": {
              "enum": [
                "newest",
                "oldest"
              ],
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "schema": {
              "maxLength": 100,
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "webhook",
                              "email",
                              "email_group"
                            ]
                          },
                          "config": {
                            "x-stainless-any": true
                          },
                          "isActive": {
                            "type": "boolean"
                          },
                          "description": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "userId": {
                            "type": "string"
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          },
                          "groupEmails": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "deliveryStats": {
                            "type": "object",
                            "properties": {
                              "total": {
                                "type": "number"
                              },
                              "successful": {
                                "type": "number"
                              },
                              "failed": {
                                "type": "number"
                              },
                              "lastDelivery": {
                                "nullable": true,
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              }
                            },
                            "required": [
                              "total",
                              "successful",
                              "failed",
                              "lastDelivery"
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "type",
                          "config",
                          "isActive",
                          "description",
                          "userId",
                          "createdAt",
                          "updatedAt",
                          "groupEmails",
                          "deliveryStats"
                        ]
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "limit": {
                          "type": "number"
                        },
                        "offset": {
                          "type": "number"
                        },
                        "total": {
                          "type": "number"
                        },
                        "hasMore": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "limit",
                        "offset",
                        "total",
                        "hasMore"
                      ]
                    }
                  },
                  "required": [
                    "data",
                    "pagination"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ]
                }
              }
            }
          }
        },
        "operationId": "getApiE2Endpoints"
      },
      "post": {
        "tags": [
          "Endpoints"
        ],
        "summary": "Create new endpoint",
        "description": "Create a new endpoint (webhook, email, or email_group) for the authenticated user",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "webhook",
                      "email",
                      "email_group"
                    ]
                  },
                  "config": {
                    "anyOf": [
                      {
                        "title": "WebhookConfig",
                        "type": "object",
                        "properties": {
                          "url": {
                            "type": "string"
                          },
                          "timeout": {
                            "minimum": 1,
                            "maximum": 300,
                            "type": "number"
                          },
                          "retryAttempts": {
                            "minimum": 0,
                            "maximum": 10,
                            "type": "number"
                          },
                          "headers": {
                            "description": "Custom headers to include with webhook requests",
                            "type": "object",
                            "patternProperties": {
                              "^(.*)$": {
                                "type": "string"
                              }
                            }
                          }
                        },
                        "required": [
                          "url"
                        ]
                      },
                      {
                        "title": "EmailConfig",
                        "type": "object",
                        "properties": {
                          "forwardTo": {
                            "format": "email",
                            "type": "string"
                          },
                          "includeAttachments": {
                            "type": "boolean"
                          },
                          "subjectPrefix": {
                            "maxLength": 255,
                            "type": "string"
                          },
                          "fromAddress": {
                            "format": "email",
                            "type": "string"
                          },
                          "senderName": {
                            "maxLength": 255,
                            "type": "string"
                          },
                          "preserveHeaders": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "forwardTo"
                        ]
                      },
                      {
                        "title": "EmailGroupConfig",
                        "type": "object",
                        "properties": {
                          "emails": {
                            "minItems": 1,
                            "maxItems": 50,
                            "type": "array",
                            "items": {
                              "format": "email",
                              "type": "string"
                            }
                          },
                          "includeAttachments": {
                            "type": "boolean"
                          },
                          "subjectPrefix": {
                            "maxLength": 255,
                            "type": "string"
                          },
                          "fromAddress": {
                            "format": "email",
                            "type": "string"
                          },
                          "senderName": {
                            "maxLength": 255,
                            "type": "string"
                          },
                          "preserveHeaders": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "emails"
                        ]
                      }
                    ]
                  },
                  "description": {
                    "maxLength": 1000,
                    "type": "string"
                  }
                },
                "required": [
                  "name",
                  "type",
                  "config"
                ]
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "webhook",
                      "email",
                      "email_group"
                    ]
                  },
                  "config": {
                    "anyOf": [
                      {
                        "title": "WebhookConfig",
                        "type": "object",
                        "properties": {
                          "url": {
                            "type": "string"
                          },
                          "timeout": {
                            "minimum": 1,
                            "maximum": 300,
                            "type": "number"
                          },
                          "retryAttempts": {
                            "minimum": 0,
                            "maximum": 10,
                            "type": "number"
                          },
                          "headers": {
                            "description": "Custom headers to include with webhook requests",
                            "type": "object",
                            "patternProperties": {
                              "^(.*)$": {
                                "type": "string"
                              }
                            }
                          }
                        },
                        "required": [
                          "url"
                        ]
                      },
                      {
                        "title": "EmailConfig",
                        "type": "object",
                        "properties": {
                          "forwardTo": {
                            "format": "email",
                            "type": "string"
                          },
                          "includeAttachments": {
                            "type": "boolean"
                          },
                          "subjectPrefix": {
                            "maxLength": 255,
                            "type": "string"
                          },
                          "fromAddress": {
                            "format": "email",
                            "type": "string"
                          },
                          "senderName": {
                            "maxLength": 255,
                            "type": "string"
                          },
                          "preserveHeaders": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "forwardTo"
                        ]
                      },
                      {
                        "title": "EmailGroupConfig",
                        "type": "object",
                        "properties": {
                          "emails": {
                            "minItems": 1,
                            "maxItems": 50,
                            "type": "array",
                            "items": {
                              "format": "email",
                              "type": "string"
                            }
                          },
                          "includeAttachments": {
                            "type": "boolean"
                          },
                          "subjectPrefix": {
                            "maxLength": 255,
                            "type": "string"
                          },
                          "fromAddress": {
                            "format": "email",
                            "type": "string"
                          },
                          "senderName": {
                            "maxLength": 255,
                            "type": "string"
                          },
                          "preserveHeaders": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "emails"
                        ]
                      }
                    ]
                  },
                  "description": {
                    "maxLength": 1000,
                    "type": "string"
                  }
                },
                "required": [
                  "name",
                  "type",
                  "config"
                ]
              }
            },
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "webhook",
                      "email",
                      "email_group"
                    ]
                  },
                  "config": {
                    "anyOf": [
                      {
                        "title": "WebhookConfig",
                        "type": "object",
                        "properties": {
                          "url": {
                            "type": "string"
                          },
                          "timeout": {
                            "minimum": 1,
                            "maximum": 300,
                            "type": "number"
                          },
                          "retryAttempts": {
                            "minimum": 0,
                            "maximum": 10,
                            "type": "number"
                          },
                          "headers": {
                            "description": "Custom headers to include with webhook requests",
                            "type": "object",
                            "patternProperties": {
                              "^(.*)$": {
                                "type": "string"
                              }
                            }
                          }
                        },
                        "required": [
                          "url"
                        ]
                      },
                      {
                        "title": "EmailConfig",
                        "type": "object",
                        "properties": {
                          "forwardTo": {
                            "format": "email",
                            "type": "string"
                          },
                          "includeAttachments": {
                            "type": "boolean"
                          },
                          "subjectPrefix": {
                            "maxLength": 255,
                            "type": "string"
                          },
                          "fromAddress": {
                            "format": "email",
                            "type": "string"
                          },
                          "senderName": {
                            "maxLength": 255,
                            "type": "string"
                          },
                          "preserveHeaders": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "forwardTo"
                        ]
                      },
                      {
                        "title": "EmailGroupConfig",
                        "type": "object",
                        "properties": {
                          "emails": {
                            "minItems": 1,
                            "maxItems": 50,
                            "type": "array",
                            "items": {
                              "format": "email",
                              "type": "string"
                            }
                          },
                          "includeAttachments": {
                            "type": "boolean"
                          },
                          "subjectPrefix": {
                            "maxLength": 255,
                            "type": "string"
                          },
                          "fromAddress": {
                            "format": "email",
                            "type": "string"
                          },
                          "senderName": {
                            "maxLength": 255,
                            "type": "string"
                          },
                          "preserveHeaders": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "emails"
                        ]
                      }
                    ]
                  },
                  "description": {
                    "maxLength": 1000,
                    "type": "string"
                  }
                },
                "required": [
                  "name",
                  "type",
                  "config"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Response for status 201",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "webhook",
                        "email",
                        "email_group"
                      ]
                    },
                    "config": {
                      "x-stainless-any": true
                    },
                    "isActive": {
                      "type": "boolean"
                    },
                    "description": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "userId": {
                      "type": "string"
                    },
                    "createdAt": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "type": "string"
                    },
                    "groupEmails": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "deliveryStats": {
                      "type": "object",
                      "properties": {
                        "total": {
                          "type": "number"
                        },
                        "successful": {
                          "type": "number"
                        },
                        "failed": {
                          "type": "number"
                        },
                        "lastDelivery": {
                          "nullable": true,
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      },
                      "required": [
                        "total",
                        "successful",
                        "failed",
                        "lastDelivery"
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "type",
                    "config",
                    "isActive",
                    "description",
                    "userId",
                    "createdAt",
                    "updatedAt",
                    "groupEmails",
                    "deliveryStats"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Response for status 400",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "details": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ]
                }
              }
            }
          }
        },
        "operationId": "postApiE2Endpoints"
      }
    },
    "/api/e2/endpoints/{id}": {
      "get": {
        "tags": [
          "Endpoints"
        ],
        "summary": "Get endpoint details",
        "description": "Get detailed information about a specific endpoint including delivery stats, recent deliveries, associated emails, and catch-all domains",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "webhook",
                        "email",
                        "email_group"
                      ]
                    },
                    "config": {
                      "x-stainless-any": true
                    },
                    "isActive": {
                      "type": "boolean"
                    },
                    "description": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "userId": {
                      "type": "string"
                    },
                    "createdAt": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "updatedAt": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "groupEmails": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "deliveryStats": {
                      "type": "object",
                      "properties": {
                        "total": {
                          "type": "number"
                        },
                        "successful": {
                          "type": "number"
                        },
                        "failed": {
                          "type": "number"
                        },
                        "lastDelivery": {
                          "nullable": true,
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      },
                      "required": [
                        "total",
                        "successful",
                        "failed",
                        "lastDelivery"
                      ]
                    },
                    "recentDeliveries": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "emailId": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "deliveryType": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "attempts": {
                            "type": "number"
                          },
                          "lastAttemptAt": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "responseData": {
                            "x-stainless-any": true
                          },
                          "createdAt": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "emailId",
                          "deliveryType",
                          "status",
                          "attempts",
                          "lastAttemptAt",
                          "responseData",
                          "createdAt"
                        ]
                      }
                    },
                    "associatedEmails": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "address": {
                            "type": "string"
                          },
                          "isActive": {
                            "type": "boolean"
                          },
                          "createdAt": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "address",
                          "isActive",
                          "createdAt"
                        ]
                      }
                    },
                    "catchAllDomains": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "domain": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "domain",
                          "status"
                        ]
                      }
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "type",
                    "config",
                    "isActive",
                    "description",
                    "userId",
                    "createdAt",
                    "updatedAt",
                    "groupEmails",
                    "deliveryStats",
                    "recentDeliveries",
                    "associatedEmails",
                    "catchAllDomains"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Response for status 404",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ]
                }
              }
            }
          }
        },
        "operationId": "getApiE2EndpointsById"
      },
      "put": {
        "tags": [
          "Endpoints"
        ],
        "summary": "Update endpoint",
        "description": "Update an existing endpoint's name, description, active status, config, or webhook format",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "description": {
                    "maxLength": 1000,
                    "type": "string"
                  },
                  "isActive": {
                    "type": "boolean"
                  },
                  "config": {
                    "anyOf": [
                      {
                        "title": "WebhookConfig",
                        "type": "object",
                        "properties": {
                          "url": {
                            "type": "string"
                          },
                          "timeout": {
                            "minimum": 1,
                            "maximum": 300,
                            "type": "number"
                          },
                          "retryAttempts": {
                            "minimum": 0,
                            "maximum": 10,
                            "type": "number"
                          },
                          "headers": {
                            "description": "Custom headers to include with webhook requests",
                            "type": "object",
                            "patternProperties": {
                              "^(.*)$": {
                                "type": "string"
                              }
                            }
                          }
                        },
                        "required": [
                          "url"
                        ]
                      },
                      {
                        "title": "EmailConfig",
                        "type": "object",
                        "properties": {
                          "forwardTo": {
                            "format": "email",
                            "type": "string"
                          },
                          "includeAttachments": {
                            "type": "boolean"
                          },
                          "subjectPrefix": {
                            "maxLength": 255,
                            "type": "string"
                          },
                          "fromAddress": {
                            "format": "email",
                            "type": "string"
                          },
                          "senderName": {
                            "maxLength": 255,
                            "type": "string"
                          },
                          "preserveHeaders": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "forwardTo"
                        ]
                      },
                      {
                        "title": "EmailGroupConfig",
                        "type": "object",
                        "properties": {
                          "emails": {
                            "minItems": 1,
                            "maxItems": 50,
                            "type": "array",
                            "items": {
                              "format": "email",
                              "type": "string"
                            }
                          },
                          "includeAttachments": {
                            "type": "boolean"
                          },
                          "subjectPrefix": {
                            "maxLength": 255,
                            "type": "string"
                          },
                          "fromAddress": {
                            "format": "email",
                            "type": "string"
                          },
                          "senderName": {
                            "maxLength": 255,
                            "type": "string"
                          },
                          "preserveHeaders": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "emails"
                        ]
                      }
                    ]
                  },
                  "webhookFormat": {
                    "type": "string",
                    "enum": [
                      "inbound",
                      "discord",
                      "slack"
                    ]
                  }
                }
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "description": {
                    "maxLength": 1000,
                    "type": "string"
                  },
                  "isActive": {
                    "type": "boolean"
                  },
                  "config": {
                    "anyOf": [
                      {
                        "title": "WebhookConfig",
                        "type": "object",
                        "properties": {
                          "url": {
                            "type": "string"
                          },
                          "timeout": {
                            "minimum": 1,
                            "maximum": 300,
                            "type": "number"
                          },
                          "retryAttempts": {
                            "minimum": 0,
                            "maximum": 10,
                            "type": "number"
                          },
                          "headers": {
                            "description": "Custom headers to include with webhook requests",
                            "type": "object",
                            "patternProperties": {
                              "^(.*)$": {
                                "type": "string"
                              }
                            }
                          }
                        },
                        "required": [
                          "url"
                        ]
                      },
                      {
                        "title": "EmailConfig",
                        "type": "object",
                        "properties": {
                          "forwardTo": {
                            "format": "email",
                            "type": "string"
                          },
                          "includeAttachments": {
                            "type": "boolean"
                          },
                          "subjectPrefix": {
                            "maxLength": 255,
                            "type": "string"
                          },
                          "fromAddress": {
                            "format": "email",
                            "type": "string"
                          },
                          "senderName": {
                            "maxLength": 255,
                            "type": "string"
                          },
                          "preserveHeaders": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "forwardTo"
                        ]
                      },
                      {
                        "title": "EmailGroupConfig",
                        "type": "object",
                        "properties": {
                          "emails": {
                            "minItems": 1,
                            "maxItems": 50,
                            "type": "array",
                            "items": {
                              "format": "email",
                              "type": "string"
                            }
                          },
                          "includeAttachments": {
                            "type": "boolean"
                          },
                          "subjectPrefix": {
                            "maxLength": 255,
                            "type": "string"
                          },
                          "fromAddress": {
                            "format": "email",
                            "type": "string"
                          },
                          "senderName": {
                            "maxLength": 255,
                            "type": "string"
                          },
                          "preserveHeaders": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "emails"
                        ]
                      }
                    ]
                  },
                  "webhookFormat": {
                    "type": "string",
                    "enum": [
                      "inbound",
                      "discord",
                      "slack"
                    ]
                  }
                }
              }
            },
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "description": {
                    "maxLength": 1000,
                    "type": "string"
                  },
                  "isActive": {
                    "type": "boolean"
                  },
                  "config": {
                    "anyOf": [
                      {
                        "title": "WebhookConfig",
                        "type": "object",
                        "properties": {
                          "url": {
                            "type": "string"
                          },
                          "timeout": {
                            "minimum": 1,
                            "maximum": 300,
                            "type": "number"
                          },
                          "retryAttempts": {
                            "minimum": 0,
                            "maximum": 10,
                            "type": "number"
                          },
                          "headers": {
                            "description": "Custom headers to include with webhook requests",
                            "type": "object",
                            "patternProperties": {
                              "^(.*)$": {
                                "type": "string"
                              }
                            }
                          }
                        },
                        "required": [
                          "url"
                        ]
                      },
                      {
                        "title": "EmailConfig",
                        "type": "object",
                        "properties": {
                          "forwardTo": {
                            "format": "email",
                            "type": "string"
                          },
                          "includeAttachments": {
                            "type": "boolean"
                          },
                          "subjectPrefix": {
                            "maxLength": 255,
                            "type": "string"
                          },
                          "fromAddress": {
                            "format": "email",
                            "type": "string"
                          },
                          "senderName": {
                            "maxLength": 255,
                            "type": "string"
                          },
                          "preserveHeaders": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "forwardTo"
                        ]
                      },
                      {
                        "title": "EmailGroupConfig",
                        "type": "object",
                        "properties": {
                          "emails": {
                            "minItems": 1,
                            "maxItems": 50,
                            "type": "array",
                            "items": {
                              "format": "email",
                              "type": "string"
                            }
                          },
                          "includeAttachments": {
                            "type": "boolean"
                          },
                          "subjectPrefix": {
                            "maxLength": 255,
                            "type": "string"
                          },
                          "fromAddress": {
                            "format": "email",
                            "type": "string"
                          },
                          "senderName": {
                            "maxLength": 255,
                            "type": "string"
                          },
                          "preserveHeaders": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "emails"
                        ]
                      }
                    ]
                  },
                  "webhookFormat": {
                    "type": "string",
                    "enum": [
                      "inbound",
                      "discord",
                      "slack"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "webhook",
                        "email",
                        "email_group"
                      ]
                    },
                    "config": {
                      "x-stainless-any": true
                    },
                    "isActive": {
                      "type": "boolean"
                    },
                    "description": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "userId": {
                      "type": "string"
                    },
                    "createdAt": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "updatedAt": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "groupEmails": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "name",
                    "type",
                    "config",
                    "isActive",
                    "description",
                    "userId",
                    "createdAt",
                    "updatedAt",
                    "groupEmails"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Response for status 400",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "details": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Response for status 404",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ]
                }
              }
            }
          }
        },
        "operationId": "putApiE2EndpointsById"
      },
      "delete": {
        "tags": [
          "Endpoints"
        ],
        "summary": "Delete endpoint",
        "description": "Delete an endpoint and clean up associated resources (email addresses become store-only, domains lose catch-all config, group entries and delivery history are deleted)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "cleanup": {
                      "type": "object",
                      "properties": {
                        "emailAddressesUpdated": {
                          "type": "number"
                        },
                        "emailAddresses": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "domainsUpdated": {
                          "type": "number"
                        },
                        "domains": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "groupEmailsDeleted": {
                          "type": "number"
                        },
                        "deliveriesDeleted": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "emailAddressesUpdated",
                        "emailAddresses",
                        "domainsUpdated",
                        "domains",
                        "groupEmailsDeleted",
                        "deliveriesDeleted"
                      ]
                    }
                  },
                  "required": [
                    "message",
                    "cleanup"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Response for status 404",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ]
                }
              }
            }
          }
        },
        "operationId": "deleteApiE2EndpointsById"
      }
    },
    "/api/e2/endpoints/{id}/test": {
      "post": {
        "tags": [
          "Endpoints"
        ],
        "summary": "Test endpoint",
        "description": "Test an endpoint by sending a test payload. For webhooks, supports inbound, discord, and slack formats. For email endpoints, simulates the forwarding process.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "webhookFormat": {
                    "type": "string",
                    "enum": [
                      "inbound",
                      "discord",
                      "slack"
                    ]
                  },
                  "overrideUrl": {
                    "type": "string"
                  }
                }
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "webhookFormat": {
                    "type": "string",
                    "enum": [
                      "inbound",
                      "discord",
                      "slack"
                    ]
                  },
                  "overrideUrl": {
                    "type": "string"
                  }
                }
              }
            },
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "webhookFormat": {
                    "type": "string",
                    "enum": [
                      "inbound",
                      "discord",
                      "slack"
                    ]
                  },
                  "overrideUrl": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "responseTime": {
                      "type": "number"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "responseBody": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "testPayload": {
                      "x-stainless-any": true
                    },
                    "webhookFormat": {
                      "type": "string",
                      "enum": [
                        "inbound",
                        "discord",
                        "slack"
                      ]
                    },
                    "urlTested": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "success",
                    "message",
                    "responseTime"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Response for status 400",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "type": "object",
                      "properties": {
                        "error": {
                          "type": "string"
                        },
                        "validFormats": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        }
                      },
                      "required": [
                        "error"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "success": {
                          "const": false,
                          "type": "boolean"
                        },
                        "message": {
                          "type": "string"
                        },
                        "responseTime": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "success",
                        "message",
                        "responseTime"
                      ]
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Response for status 404",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ]
                }
              }
            }
          }
        },
        "operationId": "postApiE2EndpointsByIdTest"
      }
    },
    "/api/e2/email-addresses": {
      "get": {
        "tags": [
          "Email Addresses"
        ],
        "summary": "List all email addresses",
        "description": "Get paginated list of email addresses for authenticated user with optional filtering by domain, active status, and receipt rule configuration",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "anyOf": [
                {
                  "format": "integer",
                  "default": 0,
                  "type": "string"
                },
                {
                  "minimum": 1,
                  "maximum": 100,
                  "default": 50,
                  "type": "integer"
                }
              ]
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "minimum": 0,
              "default": 0,
              "anyOf": [
                {
                  "format": "integer",
                  "default": 0,
                  "type": "string"
                },
                {
                  "minimum": 0,
                  "default": 0,
                  "type": "integer"
                }
              ]
            }
          },
          {
            "name": "domainId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "isActive",
            "in": "query",
            "required": false,
            "schema": {
              "enum": [
                "true",
                "false"
              ],
              "type": "string"
            }
          },
          {
            "name": "isReceiptRuleConfigured",
            "in": "query",
            "required": false,
            "schema": {
              "enum": [
                "true",
                "false"
              ],
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "address": {
                            "type": "string"
                          },
                          "domainId": {
                            "type": "string"
                          },
                          "webhookId": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "endpointId": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "isActive": {
                            "type": "boolean"
                          },
                          "isReceiptRuleConfigured": {
                            "type": "boolean"
                          },
                          "receiptRuleName": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updatedAt": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "userId": {
                            "type": "string"
                          },
                          "domain": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "name": {
                                "type": "string"
                              },
                              "status": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "id",
                              "name",
                              "status"
                            ]
                          },
                          "routing": {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "enum": [
                                  "webhook",
                                  "endpoint",
                                  "none"
                                ]
                              },
                              "id": {
                                "nullable": true,
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "name": {
                                "nullable": true,
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "config": {
                                "x-stainless-any": true
                              },
                              "isActive": {
                                "type": "boolean"
                              }
                            },
                            "required": [
                              "type",
                              "id",
                              "name",
                              "isActive"
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "address",
                          "domainId",
                          "webhookId",
                          "endpointId",
                          "isActive",
                          "isReceiptRuleConfigured",
                          "receiptRuleName",
                          "createdAt",
                          "updatedAt",
                          "userId",
                          "domain",
                          "routing"
                        ]
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "limit": {
                          "type": "number"
                        },
                        "offset": {
                          "type": "number"
                        },
                        "total": {
                          "type": "number"
                        },
                        "hasMore": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "limit",
                        "offset",
                        "total",
                        "hasMore"
                      ]
                    }
                  },
                  "required": [
                    "data",
                    "pagination"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "getApiE2Email-addresses"
      },
      "post": {
        "tags": [
          "Email Addresses"
        ],
        "summary": "Create email address",
        "description": "Create a new email address for an authenticated user's domain, optionally routing to a webhook or endpoint.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "address": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "domainId": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "endpointId": {
                    "type": "string"
                  },
                  "webhookId": {
                    "type": "string"
                  },
                  "isActive": {
                    "default": true,
                    "type": "boolean"
                  }
                },
                "required": [
                  "address",
                  "domainId"
                ]
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "address": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "domainId": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "endpointId": {
                    "type": "string"
                  },
                  "webhookId": {
                    "type": "string"
                  },
                  "isActive": {
                    "default": true,
                    "type": "boolean"
                  }
                },
                "required": [
                  "address",
                  "domainId"
                ]
              }
            },
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "address": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "domainId": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "endpointId": {
                    "type": "string"
                  },
                  "webhookId": {
                    "type": "string"
                  },
                  "isActive": {
                    "default": true,
                    "type": "boolean"
                  }
                },
                "required": [
                  "address",
                  "domainId"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Response for status 201",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "address": {
                      "type": "string"
                    },
                    "domainId": {
                      "type": "string"
                    },
                    "webhookId": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "endpointId": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "isActive": {
                      "type": "boolean"
                    },
                    "isReceiptRuleConfigured": {
                      "type": "boolean"
                    },
                    "receiptRuleName": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updatedAt": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "userId": {
                      "type": "string"
                    },
                    "domain": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "status": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "status"
                      ]
                    },
                    "routing": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "webhook",
                            "endpoint",
                            "none"
                          ]
                        },
                        "id": {
                          "nullable": true,
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "name": {
                          "nullable": true,
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "config": {
                          "x-stainless-any": true
                        },
                        "isActive": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "type",
                        "id",
                        "name",
                        "isActive"
                      ]
                    },
                    "warning": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "address",
                    "domainId",
                    "webhookId",
                    "endpointId",
                    "isActive",
                    "isReceiptRuleConfigured",
                    "receiptRuleName",
                    "createdAt",
                    "updatedAt",
                    "userId",
                    "domain",
                    "routing"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Response for status 400",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "required": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "required": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Response for status 404",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "required": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Response for status 409",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "required": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "required": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "postApiE2Email-addresses"
      }
    },
    "/api/e2/email-addresses/{id}": {
      "get": {
        "tags": [
          "Email Addresses"
        ],
        "summary": "Get email address",
        "description": "Get a specific email address by ID with detailed information including routing configuration",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "address": {
                      "type": "string"
                    },
                    "domainId": {
                      "type": "string"
                    },
                    "webhookId": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "endpointId": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "isActive": {
                      "type": "boolean"
                    },
                    "isReceiptRuleConfigured": {
                      "type": "boolean"
                    },
                    "receiptRuleName": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updatedAt": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "userId": {
                      "type": "string"
                    },
                    "domain": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "status": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "status"
                      ]
                    },
                    "routing": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "webhook",
                            "endpoint",
                            "none"
                          ]
                        },
                        "id": {
                          "nullable": true,
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "name": {
                          "nullable": true,
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "config": {
                          "x-stainless-any": true
                        },
                        "isActive": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "type",
                        "id",
                        "name",
                        "isActive"
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "address",
                    "domainId",
                    "webhookId",
                    "endpointId",
                    "isActive",
                    "isReceiptRuleConfigured",
                    "receiptRuleName",
                    "createdAt",
                    "updatedAt",
                    "userId",
                    "domain",
                    "routing"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Response for status 404",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "getApiE2Email-addressesById"
      },
      "put": {
        "tags": [
          "Email Addresses"
        ],
        "summary": "Update email address",
        "description": "Update an email address's routing (endpoint/webhook) or active status. Cannot have both endpoint and webhook.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "endpointId": {
                    "nullable": true,
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "webhookId": {
                    "nullable": true,
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "isActive": {
                    "type": "boolean"
                  }
                }
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "endpointId": {
                    "nullable": true,
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "webhookId": {
                    "nullable": true,
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "isActive": {
                    "type": "boolean"
                  }
                }
              }
            },
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "endpointId": {
                    "nullable": true,
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "webhookId": {
                    "nullable": true,
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "isActive": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "address": {
                      "type": "string"
                    },
                    "domainId": {
                      "type": "string"
                    },
                    "webhookId": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "endpointId": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "isActive": {
                      "type": "boolean"
                    },
                    "isReceiptRuleConfigured": {
                      "type": "boolean"
                    },
                    "receiptRuleName": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updatedAt": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "userId": {
                      "type": "string"
                    },
                    "domain": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "status": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "status"
                      ]
                    },
                    "routing": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "webhook",
                            "endpoint",
                            "none"
                          ]
                        },
                        "id": {
                          "nullable": true,
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "name": {
                          "nullable": true,
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "config": {
                          "x-stainless-any": true
                        },
                        "isActive": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "type",
                        "id",
                        "name",
                        "isActive"
                      ]
                    },
                    "warning": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "address",
                    "domainId",
                    "webhookId",
                    "endpointId",
                    "isActive",
                    "isReceiptRuleConfigured",
                    "receiptRuleName",
                    "createdAt",
                    "updatedAt",
                    "userId",
                    "domain",
                    "routing"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Response for status 400",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Response for status 404",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "putApiE2Email-addressesById"
      },
      "delete": {
        "tags": [
          "Email Addresses"
        ],
        "summary": "Delete email address",
        "description": "Delete an email address. Returns cleanup status.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "cleanup": {
                      "type": "object",
                      "properties": {
                        "sesRuleUpdated": {
                          "type": "boolean"
                        },
                        "emailAddress": {
                          "type": "string"
                        },
                        "domain": {
                          "type": "string"
                        },
                        "warning": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "sesRuleUpdated",
                        "emailAddress",
                        "domain"
                      ]
                    }
                  },
                  "required": [
                    "message",
                    "cleanup"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Response for status 404",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "deleteApiE2Email-addressesById"
      }
    },
    "/api/e2/attachments/{id}": {
      "get": {
        "tags": [
          "Attachments"
        ],
        "summary": "List email attachments",
        "description": "List every attachment in a received email, including ones without a filename, with a download URL for each.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "emailId": {
                      "type": "string"
                    },
                    "attachments": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "index": {
                            "description": "Position of the attachment in the email, starting at 0",
                            "type": "number"
                          },
                          "filename": {
                            "description": "Filename from the email; null when the sender didn't provide one",
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "contentType": {
                            "type": "string"
                          },
                          "size": {
                            "type": "number"
                          },
                          "contentId": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "inline": {
                            "description": "True for inline parts such as embedded images",
                            "type": "boolean"
                          },
                          "downloadUrl": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "index",
                          "filename",
                          "contentType",
                          "size",
                          "contentId",
                          "inline",
                          "downloadUrl"
                        ]
                      }
                    }
                  },
                  "required": [
                    "emailId",
                    "attachments"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "details": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Response for status 404",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "details": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "getApiE2AttachmentsById"
      }
    },
    "/api/e2/attachments/{id}/parts/{index}": {
      "get": {
        "tags": [
          "Attachments"
        ],
        "summary": "Download attachment by position",
        "description": "Download an attachment by its position in the email (the `index` from List email attachments; webhook `downloadUrl`s use this form). Works for attachments without a filename and for several attachments sharing one name.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "index",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "400": {
            "description": "Response for status 400",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "details": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "details": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Response for status 404",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "details": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "getApiE2AttachmentsByIdPartsByIndex"
      }
    },
    "/api/e2/attachments/{id}/{filename}": {
      "get": {
        "tags": [
          "Attachments"
        ],
        "summary": "Download email attachment",
        "description": "Download an attachment by filename. If several attachments share the name, the first is returned; use Download attachment by position to get a specific one.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "filename",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "400": {
            "description": "Response for status 400",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "details": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "details": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Response for status 404",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "details": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "details": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "getApiE2AttachmentsByIdByFilename"
      }
    },
    "/api/e2/auth/revoke-key": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "summary": "Revoke the current API key",
        "description": "Permanently revokes the API key used to authenticate this request.",
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "const": true,
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "postApiE2AuthRevoke-key"
      }
    },
    "/api/e2/emails": {
      "post": {
        "tags": [
          "Emails"
        ],
        "summary": "Send an email",
        "description": "Send an email immediately or schedule it for later using the scheduled_at parameter. Supports HTML/text content, attachments, and custom headers.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "from": {
                    "description": "Sender email address",
                    "type": "string"
                  },
                  "to": {
                    "description": "Recipient email address(es)",
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    ]
                  },
                  "subject": {
                    "description": "Email subject",
                    "type": "string"
                  },
                  "html": {
                    "description": "HTML content of the email",
                    "type": "string"
                  },
                  "text": {
                    "description": "Plain text content of the email",
                    "type": "string"
                  },
                  "cc": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    ]
                  },
                  "bcc": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    ]
                  },
                  "reply_to": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    ]
                  },
                  "headers": {
                    "description": "Custom email headers",
                    "type": "object",
                    "patternProperties": {
                      "^(.*)$": {
                        "type": "string"
                      }
                    }
                  },
                  "attachments": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "filename": {
                          "description": "Filename shown to the recipient",
                          "type": "string"
                        },
                        "content": {
                          "description": "Base64-encoded file content",
                          "type": "string"
                        },
                        "content_type": {
                          "type": "string"
                        },
                        "content_id": {
                          "maxLength": 128,
                          "type": "string"
                        },
                        "path": {
                          "description": "Public or signed URL for Inbound to fetch",
                          "type": "string"
                        }
                      },
                      "required": [
                        "filename"
                      ]
                    }
                  },
                  "tags": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string"
                        },
                        "value": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "name",
                        "value"
                      ]
                    }
                  },
                  "scheduled_at": {
                    "description": "ISO 8601 date or natural language for scheduling",
                    "type": "string"
                  },
                  "timezone": {
                    "description": "Timezone for natural language parsing",
                    "type": "string"
                  }
                },
                "required": [
                  "from",
                  "to",
                  "subject"
                ]
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "from": {
                    "description": "Sender email address",
                    "type": "string"
                  },
                  "to": {
                    "description": "Recipient email address(es)",
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    ]
                  },
                  "subject": {
                    "description": "Email subject",
                    "type": "string"
                  },
                  "html": {
                    "description": "HTML content of the email",
                    "type": "string"
                  },
                  "text": {
                    "description": "Plain text content of the email",
                    "type": "string"
                  },
                  "cc": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    ]
                  },
                  "bcc": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    ]
                  },
                  "reply_to": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    ]
                  },
                  "headers": {
                    "description": "Custom email headers",
                    "type": "object",
                    "patternProperties": {
                      "^(.*)$": {
                        "type": "string"
                      }
                    }
                  },
                  "attachments": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "filename": {
                          "description": "Filename shown to the recipient",
                          "type": "string"
                        },
                        "content": {
                          "description": "Base64-encoded file content",
                          "type": "string"
                        },
                        "content_type": {
                          "type": "string"
                        },
                        "content_id": {
                          "maxLength": 128,
                          "type": "string"
                        },
                        "path": {
                          "description": "Public or signed URL for Inbound to fetch",
                          "type": "string"
                        }
                      },
                      "required": [
                        "filename"
                      ]
                    }
                  },
                  "tags": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string"
                        },
                        "value": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "name",
                        "value"
                      ]
                    }
                  },
                  "scheduled_at": {
                    "description": "ISO 8601 date or natural language for scheduling",
                    "type": "string"
                  },
                  "timezone": {
                    "description": "Timezone for natural language parsing",
                    "type": "string"
                  }
                },
                "required": [
                  "from",
                  "to",
                  "subject"
                ]
              }
            },
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "from": {
                    "description": "Sender email address",
                    "type": "string"
                  },
                  "to": {
                    "description": "Recipient email address(es)",
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    ]
                  },
                  "subject": {
                    "description": "Email subject",
                    "type": "string"
                  },
                  "html": {
                    "description": "HTML content of the email",
                    "type": "string"
                  },
                  "text": {
                    "description": "Plain text content of the email",
                    "type": "string"
                  },
                  "cc": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    ]
                  },
                  "bcc": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    ]
                  },
                  "reply_to": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    ]
                  },
                  "headers": {
                    "description": "Custom email headers",
                    "type": "object",
                    "patternProperties": {
                      "^(.*)$": {
                        "type": "string"
                      }
                    }
                  },
                  "attachments": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "filename": {
                          "description": "Filename shown to the recipient",
                          "type": "string"
                        },
                        "content": {
                          "description": "Base64-encoded file content",
                          "type": "string"
                        },
                        "content_type": {
                          "type": "string"
                        },
                        "content_id": {
                          "maxLength": 128,
                          "type": "string"
                        },
                        "path": {
                          "description": "Public or signed URL for Inbound to fetch",
                          "type": "string"
                        }
                      },
                      "required": [
                        "filename"
                      ]
                    }
                  },
                  "tags": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string"
                        },
                        "value": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "name",
                        "value"
                      ]
                    }
                  },
                  "scheduled_at": {
                    "description": "ISO 8601 date or natural language for scheduling",
                    "type": "string"
                  },
                  "timezone": {
                    "description": "Timezone for natural language parsing",
                    "type": "string"
                  }
                },
                "required": [
                  "from",
                  "to",
                  "subject"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "message_id": {
                      "type": "string"
                    },
                    "scheduled_at": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "sent",
                        "scheduled"
                      ]
                    },
                    "timezone": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Response for status 400",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Response for status 403",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Response for status 409",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Response for status 429",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "postApiE2Emails"
      },
      "get": {
        "tags": [
          "Emails"
        ],
        "summary": "List all emails",
        "description": "List all email activity (sent, received, and scheduled) with comprehensive filtering options.",
        "parameters": [
          {
            "name": "type",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "all",
                "sent",
                "received",
                "scheduled"
              ]
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "all",
                "delivered",
                "pending",
                "failed",
                "bounced",
                "scheduled",
                "cancelled",
                "paused",
                "unread",
                "read",
                "archived"
              ]
            }
          },
          {
            "name": "time_range",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "1h",
                "24h",
                "7d",
                "30d",
                "90d",
                "all"
              ]
            }
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "schema": {
              "description": "Search query to filter emails by subject, sender, or recipient. Case-insensitive partial match.",
              "type": "string"
            }
          },
          {
            "name": "domain",
            "in": "query",
            "required": false,
            "schema": {
              "description": "Filter by domain. Accepts domain ID (e.g., 'dom_xxx') or domain name (e.g., 'example.com').",
              "type": "string"
            }
          },
          {
            "name": "address",
            "in": "query",
            "required": false,
            "schema": {
              "description": "Filter by email address. Accepts address ID (e.g., 'addr_xxx') or raw email address (e.g., 'user@example.com').",
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "description": "Maximum number of emails to return (1-100). Default is 50.",
              "default": "50",
              "type": "string"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "description": "Number of emails to skip for pagination. Default is 0.",
              "default": "0",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "description": "Array of email objects matching the query",
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "description": "Unique identifier for the email",
                            "type": "string"
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "sent",
                              "received",
                              "scheduled"
                            ]
                          },
                          "message_id": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "description": "RFC 2822 Message-ID header value",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "from": {
                            "description": "Sender email address",
                            "type": "string"
                          },
                          "from_name": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "description": "Sender display name if available",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "to": {
                            "description": "Array of recipient email addresses",
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "envelope_recipient": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "description": "Primary envelope recipient (first of envelope_recipients). Deprecated: use envelope_recipients",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "envelope_recipients": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "description": "All envelope recipients this email was delivered to on your domains, including BCC recipients, independent of message headers",
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "cc": {
                            "description": "Array of CC recipient email addresses",
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "subject": {
                            "description": "Email subject line",
                            "type": "string"
                          },
                          "preview": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "description": "First 200 characters of the email body as a preview",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "description": "Current status of the email (delivered, pending, failed, bounced, scheduled, cancelled)",
                            "type": "string"
                          },
                          "created_at": {
                            "description": "ISO 8601 timestamp when the email was created/received",
                            "type": "string"
                          },
                          "sent_at": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "description": "ISO 8601 timestamp when the email was sent",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "scheduled_at": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "description": "ISO 8601 timestamp when the email is scheduled to be sent",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "has_attachments": {
                            "description": "Whether the email has any attachments",
                            "type": "boolean"
                          },
                          "attachment_count": {
                            "description": "Number of attachments on the email",
                            "type": "number"
                          },
                          "is_read": {
                            "description": "Whether the email has been read (only for received emails)",
                            "type": "boolean"
                          },
                          "read_at": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "description": "ISO 8601 timestamp when the email was marked as read (only for received emails)",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "is_archived": {
                            "description": "Whether the email has been archived (only for received emails)",
                            "type": "boolean"
                          },
                          "thread_id": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "description": "ID of the thread this email belongs to, if threaded",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "type",
                          "from",
                          "to",
                          "subject",
                          "status",
                          "created_at",
                          "has_attachments"
                        ]
                      }
                    },
                    "pagination": {
                      "description": "Pagination metadata",
                      "type": "object",
                      "properties": {
                        "limit": {
                          "description": "Number of results per page",
                          "type": "number"
                        },
                        "offset": {
                          "description": "Number of results skipped",
                          "type": "number"
                        },
                        "total": {
                          "description": "Total number of matching emails",
                          "type": "number"
                        },
                        "has_more": {
                          "description": "Whether there are more results available",
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "limit",
                        "offset",
                        "total",
                        "has_more"
                      ]
                    },
                    "filters": {
                      "description": "Applied filters for this query",
                      "type": "object",
                      "properties": {
                        "type": {
                          "description": "Applied type filter",
                          "type": "string"
                        },
                        "status": {
                          "description": "Applied status filter",
                          "type": "string"
                        },
                        "time_range": {
                          "description": "Applied time range filter",
                          "type": "string"
                        },
                        "search": {
                          "description": "Applied search query",
                          "type": "string"
                        },
                        "domain": {
                          "description": "Applied domain filter",
                          "type": "string"
                        },
                        "address": {
                          "description": "Applied address filter",
                          "type": "string"
                        }
                      }
                    }
                  },
                  "required": [
                    "data",
                    "pagination",
                    "filters"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Response for status 400",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "description": "Error message describing what went wrong",
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "description": "Error message describing what went wrong",
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "description": "Error message describing what went wrong",
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "getApiE2Emails"
      }
    },
    "/api/e2/emails/{id}": {
      "get": {
        "tags": [
          "Emails"
        ],
        "summary": "Get email by ID",
        "description": "Retrieve a single email by ID. Works for sent, received, and scheduled emails.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "const": "email",
                      "type": "string"
                    },
                    "id": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "sent",
                        "received",
                        "scheduled"
                      ]
                    },
                    "from": {
                      "type": "string"
                    },
                    "to": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "envelope_recipient": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "description": "Primary envelope recipient (first of envelope_recipients). Deprecated: use envelope_recipients",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "envelope_recipients": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "description": "All envelope recipients this email was delivered to on your domains, including BCC recipients, independent of message headers",
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "cc": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "bcc": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "reply_to": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "subject": {
                      "type": "string"
                    },
                    "html": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "text": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "string"
                    },
                    "created_at": {
                      "type": "string"
                    },
                    "sent_at": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "scheduled_at": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "has_attachments": {
                      "type": "boolean"
                    },
                    "attachments": {
                      "type": "array",
                      "items": {
                        "x-stainless-any": true
                      }
                    },
                    "is_read": {
                      "type": "boolean"
                    },
                    "thread_id": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "thread_position": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "headers": {
                      "x-stainless-any": true
                    },
                    "tags": {
                      "type": "array",
                      "items": {
                        "x-stainless-any": true
                      }
                    }
                  },
                  "required": [
                    "object",
                    "id",
                    "type",
                    "from",
                    "to",
                    "subject",
                    "status",
                    "created_at",
                    "has_attachments"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Response for status 404",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "getApiE2EmailsById"
      },
      "patch": {
        "tags": [
          "Emails"
        ],
        "summary": "Update email",
        "description": "Update metadata for a received email. Supports marking emails as read/unread and archived/unarchived.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "is_read": {
                    "type": "boolean"
                  },
                  "is_archived": {
                    "type": "boolean"
                  }
                }
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "is_read": {
                    "type": "boolean"
                  },
                  "is_archived": {
                    "type": "boolean"
                  }
                }
              }
            },
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "is_read": {
                    "type": "boolean"
                  },
                  "is_archived": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "const": "email",
                      "type": "string"
                    },
                    "id": {
                      "type": "string"
                    },
                    "is_read": {
                      "type": "boolean"
                    },
                    "is_archived": {
                      "type": "boolean"
                    },
                    "updated_at": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "object",
                    "id",
                    "is_read",
                    "is_archived",
                    "updated_at"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Response for status 400",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Response for status 404",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "patchApiE2EmailsById"
      },
      "delete": {
        "tags": [
          "Emails"
        ],
        "summary": "Cancel scheduled email",
        "description": "Cancel a scheduled email by ID. Only works for emails that haven't been sent yet.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "success",
                    "message",
                    "id"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Response for status 400",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Response for status 404",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "deleteApiE2EmailsById"
      }
    },
    "/api/e2/emails/{id}/pause": {
      "post": {
        "tags": [
          "Emails"
        ],
        "summary": "Pause scheduled email",
        "description": "Pause a scheduled email by ID. The email is removed from the delivery queue but kept in the database and can be resumed later with POST /emails/:id/resume. Only works for emails with status \"scheduled\".",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "success",
                    "message",
                    "id",
                    "status"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Response for status 400",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Response for status 404",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "postApiE2EmailsByIdPause"
      }
    },
    "/api/e2/emails/{id}/resume": {
      "post": {
        "tags": [
          "Emails"
        ],
        "summary": "Resume paused scheduled email",
        "description": "Resume a paused scheduled email by ID. The email is re-queued for its original send time, or sent shortly if that time has already passed.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "scheduled_at": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "success",
                    "message",
                    "id",
                    "status",
                    "scheduled_at"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Response for status 400",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Response for status 404",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "postApiE2EmailsByIdResume"
      }
    },
    "/api/e2/emails/{id}/reply": {
      "post": {
        "tags": [
          "Emails"
        ],
        "summary": "Reply to an email",
        "description": "Reply to an email or thread. Accepts either an email ID or thread ID (replies to latest message in thread). Supports reply all functionality.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "description": "Email ID or Thread ID to reply to",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "from": {
                    "description": "Sender email address",
                    "type": "string"
                  },
                  "to": {
                    "description": "Recipient email address(es) - defaults to original sender",
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    ]
                  },
                  "subject": {
                    "description": "Email subject - defaults to Re: original subject",
                    "type": "string"
                  },
                  "html": {
                    "description": "HTML content of the email",
                    "type": "string"
                  },
                  "text": {
                    "description": "Plain text content of the email",
                    "type": "string"
                  },
                  "headers": {
                    "description": "Custom email headers",
                    "type": "object",
                    "patternProperties": {
                      "^(.*)$": {
                        "type": "string"
                      }
                    }
                  },
                  "attachments": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "filename": {
                          "description": "Filename shown to the recipient",
                          "type": "string"
                        },
                        "content": {
                          "description": "Base64-encoded file content",
                          "type": "string"
                        },
                        "content_type": {
                          "type": "string"
                        },
                        "path": {
                          "description": "Public or signed URL for Inbound to fetch",
                          "type": "string"
                        }
                      },
                      "required": [
                        "filename"
                      ]
                    }
                  },
                  "reply_all": {
                    "description": "Include original CC recipients",
                    "type": "boolean"
                  },
                  "tags": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string"
                        },
                        "value": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "name",
                        "value"
                      ]
                    }
                  }
                },
                "required": [
                  "from"
                ]
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "from": {
                    "description": "Sender email address",
                    "type": "string"
                  },
                  "to": {
                    "description": "Recipient email address(es) - defaults to original sender",
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    ]
                  },
                  "subject": {
                    "description": "Email subject - defaults to Re: original subject",
                    "type": "string"
                  },
                  "html": {
                    "description": "HTML content of the email",
                    "type": "string"
                  },
                  "text": {
                    "description": "Plain text content of the email",
                    "type": "string"
                  },
                  "headers": {
                    "description": "Custom email headers",
                    "type": "object",
                    "patternProperties": {
                      "^(.*)$": {
                        "type": "string"
                      }
                    }
                  },
                  "attachments": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "filename": {
                          "description": "Filename shown to the recipient",
                          "type": "string"
                        },
                        "content": {
                          "description": "Base64-encoded file content",
                          "type": "string"
                        },
                        "content_type": {
                          "type": "string"
                        },
                        "path": {
                          "description": "Public or signed URL for Inbound to fetch",
                          "type": "string"
                        }
                      },
                      "required": [
                        "filename"
                      ]
                    }
                  },
                  "reply_all": {
                    "description": "Include original CC recipients",
                    "type": "boolean"
                  },
                  "tags": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string"
                        },
                        "value": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "name",
                        "value"
                      ]
                    }
                  }
                },
                "required": [
                  "from"
                ]
              }
            },
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "from": {
                    "description": "Sender email address",
                    "type": "string"
                  },
                  "to": {
                    "description": "Recipient email address(es) - defaults to original sender",
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    ]
                  },
                  "subject": {
                    "description": "Email subject - defaults to Re: original subject",
                    "type": "string"
                  },
                  "html": {
                    "description": "HTML content of the email",
                    "type": "string"
                  },
                  "text": {
                    "description": "Plain text content of the email",
                    "type": "string"
                  },
                  "headers": {
                    "description": "Custom email headers",
                    "type": "object",
                    "patternProperties": {
                      "^(.*)$": {
                        "type": "string"
                      }
                    }
                  },
                  "attachments": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "filename": {
                          "description": "Filename shown to the recipient",
                          "type": "string"
                        },
                        "content": {
                          "description": "Base64-encoded file content",
                          "type": "string"
                        },
                        "content_type": {
                          "type": "string"
                        },
                        "path": {
                          "description": "Public or signed URL for Inbound to fetch",
                          "type": "string"
                        }
                      },
                      "required": [
                        "filename"
                      ]
                    }
                  },
                  "reply_all": {
                    "description": "Include original CC recipients",
                    "type": "boolean"
                  },
                  "tags": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string"
                        },
                        "value": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "name",
                        "value"
                      ]
                    }
                  }
                },
                "required": [
                  "from"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "message_id": {
                      "type": "string"
                    },
                    "aws_message_id": {
                      "type": "string"
                    },
                    "replied_to_email_id": {
                      "type": "string"
                    },
                    "replied_to_thread_id": {
                      "type": "string"
                    },
                    "is_thread_reply": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "id",
                    "message_id",
                    "aws_message_id",
                    "replied_to_email_id",
                    "is_thread_reply"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Response for status 400",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Response for status 403",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Response for status 404",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Response for status 409",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Response for status 429",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "postApiE2EmailsByIdReply"
      }
    },
    "/api/e2/emails/{id}/retry": {
      "post": {
        "tags": [
          "Emails"
        ],
        "summary": "Retry email delivery",
        "description": "Retry delivery of a received email. Can retry to a specific endpoint, retry a specific failed delivery, or retry to all configured endpoints.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "endpoint_id": {
                    "description": "Endpoint ID to retry delivery to. If not provided, retries to all configured endpoints.",
                    "type": "string"
                  },
                  "delivery_id": {
                    "description": "Specific delivery ID to retry. If provided, retries that specific delivery.",
                    "type": "string"
                  }
                }
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "endpoint_id": {
                    "description": "Endpoint ID to retry delivery to. If not provided, retries to all configured endpoints.",
                    "type": "string"
                  },
                  "delivery_id": {
                    "description": "Specific delivery ID to retry. If provided, retries that specific delivery.",
                    "type": "string"
                  }
                }
              }
            },
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "endpoint_id": {
                    "description": "Endpoint ID to retry delivery to. If not provided, retries to all configured endpoints.",
                    "type": "string"
                  },
                  "delivery_id": {
                    "description": "Specific delivery ID to retry. If provided, retries that specific delivery.",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "delivery_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "success",
                    "message"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Response for status 400",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Response for status 404",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "postApiE2EmailsByIdRetry"
      }
    },
    "/api/e2/mail/threads": {
      "get": {
        "tags": [
          "Inbox"
        ],
        "summary": "List inbox threads",
        "description": "List email threads (conversations) for your inbox with cursor-based pagination. This is the primary endpoint for building an inbox UI.\n\n**What is a Thread?**\nA thread groups related emails together based on the In-Reply-To and References headers, similar to how Gmail groups conversations. Each thread contains both inbound (received) and outbound (sent) messages.\n\n**Use with /mail/threads/:id:**\nUse this endpoint to list threads, then use `GET /mail/threads/:id` to fetch all messages in a specific thread.",
        "parameters": [
          {
            "name": "domain",
            "in": "query",
            "required": false,
            "schema": {
              "description": "Filter threads by domain. Accepts domain ID (e.g., 'dom_xxx') or domain name (e.g., 'example.com'). Returns threads where any participant email matches the domain.",
              "type": "string"
            }
          },
          {
            "name": "address",
            "in": "query",
            "required": false,
            "schema": {
              "description": "Filter threads by email address. Accepts address ID (e.g., 'addr_xxx') or raw email address (e.g., 'user@example.com'). Returns threads where the address is a participant.",
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "description": "Maximum number of threads to return (1-100). Default is 25.",
              "default": "25",
              "type": "string"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "description": "Cursor for pagination. Pass the thread ID from `pagination.next_cursor` of the previous response to get the next page.",
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "schema": {
              "description": "Search query to filter threads by subject or participant emails. Case-insensitive partial match.",
              "type": "string"
            }
          },
          {
            "name": "unread",
            "in": "query",
            "required": false,
            "schema": {
              "description": "Filter by unread status. Set to 'true' to only return threads with unread messages.",
              "default": "false",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "threads": {
                      "description": "Array of thread objects matching the query, sorted by last message date (newest first)",
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "description": "Unique identifier for the thread",
                            "type": "string"
                          },
                          "root_message_id": {
                            "description": "RFC 2822 Message-ID of the first message in the thread",
                            "type": "string"
                          },
                          "normalized_subject": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "description": "Normalized subject line (stripped of Re:, Fwd:, etc.) used for thread grouping",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "participant_emails": {
                            "description": "Array of all unique email addresses that have participated in this thread",
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "participant_names": {
                            "description": "Array of formatted participant names in the format 'First Last <email@domain.com>' or just 'email@domain.com' if no name is available",
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "message_count": {
                            "description": "Total number of messages in the thread (both inbound and outbound)",
                            "type": "number"
                          },
                          "last_message_at": {
                            "description": "ISO 8601 timestamp of the most recent message in the thread",
                            "type": "string"
                          },
                          "created_at": {
                            "description": "ISO 8601 timestamp when the thread was created (first message received)",
                            "type": "string"
                          },
                          "latest_message": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "description": "Unique identifier of the message",
                                    "type": "string"
                                  },
                                  "type": {
                                    "description": "Whether the message was received (inbound) or sent (outbound)",
                                    "anyOf": [
                                      {
                                        "const": "inbound",
                                        "type": "string"
                                      },
                                      {
                                        "const": "outbound",
                                        "type": "string"
                                      }
                                    ]
                                  },
                                  "subject": {
                                    "nullable": true,
                                    "anyOf": [
                                      {
                                        "description": "Subject line of the message",
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "from_text": {
                                    "description": "Formatted sender information (name and/or email)",
                                    "type": "string"
                                  },
                                  "text_preview": {
                                    "nullable": true,
                                    "anyOf": [
                                      {
                                        "description": "First 200 characters of the message body as a preview",
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "is_read": {
                                    "description": "Whether the message has been read (always true for outbound)",
                                    "type": "boolean"
                                  },
                                  "has_attachments": {
                                    "description": "Whether the message has any attachments",
                                    "type": "boolean"
                                  },
                                  "date": {
                                    "nullable": true,
                                    "anyOf": [
                                      {
                                        "description": "ISO 8601 timestamp of when the message was sent/received",
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                },
                                "required": [
                                  "id",
                                  "type",
                                  "from_text",
                                  "is_read",
                                  "has_attachments"
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "has_unread": {
                            "description": "Whether the thread has any unread inbound messages",
                            "type": "boolean"
                          },
                          "is_archived": {
                            "description": "Whether the thread has been archived",
                            "type": "boolean"
                          },
                          "unread_count": {
                            "description": "Number of unread messages in the thread",
                            "type": "number"
                          }
                        },
                        "required": [
                          "id",
                          "root_message_id",
                          "participant_emails",
                          "participant_names",
                          "message_count",
                          "last_message_at",
                          "created_at",
                          "has_unread",
                          "is_archived"
                        ]
                      }
                    },
                    "pagination": {
                      "description": "Pagination metadata for cursor-based pagination",
                      "type": "object",
                      "properties": {
                        "limit": {
                          "description": "Number of results per page",
                          "type": "number"
                        },
                        "has_more": {
                          "description": "Whether there are more threads available after this page",
                          "type": "boolean"
                        },
                        "next_cursor": {
                          "nullable": true,
                          "anyOf": [
                            {
                              "description": "Cursor to pass as the `cursor` parameter to fetch the next page. Null if no more results.",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      },
                      "required": [
                        "limit",
                        "has_more"
                      ]
                    },
                    "filters": {
                      "description": "Applied filters for this query",
                      "type": "object",
                      "properties": {
                        "search": {
                          "description": "Applied search query",
                          "type": "string"
                        },
                        "unread_only": {
                          "description": "Whether filtering for unread threads only",
                          "type": "boolean"
                        },
                        "domain": {
                          "description": "Applied domain filter (resolved domain name)",
                          "type": "string"
                        },
                        "address": {
                          "description": "Applied address filter (resolved email address)",
                          "type": "string"
                        }
                      }
                    }
                  },
                  "required": [
                    "threads",
                    "pagination",
                    "filters"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Response for status 400",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "description": "Error message describing what went wrong",
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "description": "Error message describing what went wrong",
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "description": "Error message describing what went wrong",
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "getApiE2MailThreads"
      }
    },
    "/api/e2/mail/threads/{id}": {
      "get": {
        "tags": [
          "Inbox"
        ],
        "summary": "Get thread by ID",
        "description": "Retrieve a complete email thread (conversation) with all messages.\n\n**What You Get:**\n- Thread metadata (subject, participants, timestamps)\n- All messages in the thread (both inbound and outbound)\n- Messages sorted chronologically by thread position\n\n**Message Types:**\n- `inbound` - Emails you received\n- `outbound` - Emails you sent (includes delivery status)\n",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "description": "The unique thread ID to retrieve",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "thread": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "description": "Unique identifier for the thread",
                          "type": "string"
                        },
                        "root_message_id": {
                          "description": "RFC 2822 Message-ID of the first message in the thread",
                          "type": "string"
                        },
                        "normalized_subject": {
                          "nullable": true,
                          "anyOf": [
                            {
                              "description": "Normalized subject line (stripped of Re:, Fwd:, etc.)",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "participant_emails": {
                          "description": "Array of all unique email addresses that have participated in this thread",
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "participant_names": {
                          "description": "Array of formatted participant names in the format 'First Last <email@domain.com>' or just 'email@domain.com' if no name is available",
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "message_count": {
                          "description": "Total number of messages in the thread",
                          "type": "number"
                        },
                        "last_message_at": {
                          "description": "ISO 8601 timestamp of the most recent message",
                          "type": "string"
                        },
                        "created_at": {
                          "description": "ISO 8601 timestamp when the thread was created",
                          "type": "string"
                        },
                        "updated_at": {
                          "description": "ISO 8601 timestamp when the thread was last updated",
                          "type": "string"
                        }
                      },
                      "required": [
                        "id",
                        "root_message_id",
                        "participant_emails",
                        "participant_names",
                        "message_count",
                        "last_message_at",
                        "created_at",
                        "updated_at"
                      ]
                    },
                    "messages": {
                      "description": "Array of all messages in the thread, sorted by thread position (chronological)",
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "description": "Unique identifier for the message",
                            "type": "string"
                          },
                          "message_id": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "description": "RFC 2822 Message-ID header value",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "inbound",
                              "outbound"
                            ]
                          },
                          "thread_position": {
                            "description": "Position of the message in the thread (0 = first message)",
                            "type": "number"
                          },
                          "subject": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "description": "Subject line of the message",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "text_body": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "description": "Plain text body of the message",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "html_body": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "description": "HTML body of the message",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "from": {
                            "description": "Formatted sender (display name and email)",
                            "type": "string"
                          },
                          "from_name": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "description": "Sender display name if available",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "from_address": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "description": "Sender email address",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "to": {
                            "description": "Array of recipient email addresses",
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "envelope_recipient": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "description": "Primary envelope recipient (first of envelope_recipients). Deprecated: use envelope_recipients",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "envelope_recipients": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "description": "All envelope recipients this email was delivered to on your domains, including BCC recipients, independent of message headers",
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "cc": {
                            "description": "Array of CC recipient email addresses",
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "bcc": {
                            "description": "Array of BCC recipient email addresses",
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "date": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "description": "ISO 8601 timestamp from the Date header",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "received_at": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "description": "ISO 8601 timestamp when the message was received (inbound only)",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sent_at": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "description": "ISO 8601 timestamp when the message was sent (outbound only)",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "is_read": {
                            "description": "Whether the message has been read (always true for outbound)",
                            "type": "boolean"
                          },
                          "read_at": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "description": "ISO 8601 timestamp when the message was marked as read",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "has_attachments": {
                            "description": "Whether the message has any attachments",
                            "type": "boolean"
                          },
                          "attachments": {
                            "description": "Array of attachment metadata",
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "filename": {
                                  "description": "Original filename of the attachment",
                                  "type": "string"
                                },
                                "contentType": {
                                  "description": "MIME type of the attachment",
                                  "type": "string"
                                },
                                "size": {
                                  "description": "Size of the attachment in bytes",
                                  "type": "number"
                                },
                                "contentId": {
                                  "nullable": true,
                                  "anyOf": [
                                    {
                                      "description": "Content-ID for inline attachments",
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "content": {
                                  "description": "Base64-encoded content (if included)",
                                  "type": "string"
                                }
                              }
                            }
                          },
                          "in_reply_to": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "description": "RFC 2822 In-Reply-To header value",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "references": {
                            "description": "Array of Message-IDs from the References header",
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "headers": {
                            "x-stainless-any": true,
                            "description": "Raw email headers as key-value pairs"
                          },
                          "tags": {
                            "description": "Array of tags attached to the message (outbound only)",
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "name": {
                                  "description": "Tag name",
                                  "type": "string"
                                },
                                "value": {
                                  "description": "Tag value",
                                  "type": "string"
                                }
                              },
                              "required": [
                                "name",
                                "value"
                              ]
                            }
                          },
                          "status": {
                            "description": "Delivery status for outbound messages (pending, sent, failed, bounced)",
                            "type": "string"
                          },
                          "failure_reason": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "description": "Error message if the outbound message failed to send",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "type",
                          "thread_position",
                          "from",
                          "to",
                          "cc",
                          "bcc",
                          "is_read",
                          "has_attachments",
                          "attachments",
                          "references",
                          "headers",
                          "tags"
                        ]
                      }
                    },
                    "total_count": {
                      "description": "Total number of messages returned",
                      "type": "number"
                    }
                  },
                  "required": [
                    "thread",
                    "messages",
                    "total_count"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Response for status 400",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "description": "Error message describing what went wrong",
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "description": "Error message describing what went wrong",
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Response for status 404",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "description": "Error message describing what went wrong",
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "description": "Error message describing what went wrong",
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "getApiE2MailThreadsById"
      }
    },
    "/api/e2/mailboxes": {
      "get": {
        "tags": [
          "Mailboxes"
        ],
        "summary": "List managed mailboxes",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "anyOf": [
                {
                  "format": "integer",
                  "default": 0,
                  "type": "string"
                },
                {
                  "minimum": 1,
                  "maximum": 100,
                  "default": 50,
                  "type": "integer"
                }
              ]
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "minimum": 0,
              "default": 0,
              "anyOf": [
                {
                  "format": "integer",
                  "default": 0,
                  "type": "string"
                },
                {
                  "minimum": 0,
                  "default": 0,
                  "type": "integer"
                }
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "loginAddress": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "mailbox",
                              "smtp"
                            ]
                          },
                          "accessMode": {
                            "type": "string",
                            "enum": [
                              "read",
                              "read_write"
                            ]
                          },
                          "sendingMode": {
                            "type": "string",
                            "enum": [
                              "identity",
                              "scoped_domains"
                            ]
                          },
                          "sendingName": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sendingAddress": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "enabled": {
                            "type": "boolean"
                          },
                          "scopes": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "string"
                                },
                                "type": {
                                  "type": "string",
                                  "enum": [
                                    "domain",
                                    "address"
                                  ]
                                },
                                "domainId": {
                                  "type": "string"
                                },
                                "domain": {
                                  "type": "string"
                                },
                                "address": {
                                  "nullable": true,
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                }
                              },
                              "required": [
                                "id",
                                "type",
                                "domainId",
                                "domain",
                                "address"
                              ]
                            }
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updatedAt": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "lastUsedAt": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "loginAddress",
                          "type",
                          "accessMode",
                          "sendingMode",
                          "sendingName",
                          "sendingAddress",
                          "enabled",
                          "scopes",
                          "createdAt",
                          "updatedAt",
                          "lastUsedAt"
                        ]
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "limit": {
                          "type": "number"
                        },
                        "offset": {
                          "type": "number"
                        },
                        "total": {
                          "type": "number"
                        },
                        "hasMore": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "limit",
                        "offset",
                        "total",
                        "hasMore"
                      ]
                    }
                  },
                  "required": [
                    "data",
                    "pagination"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Response for status 403",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Response for status 429",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "getApiE2Mailboxes"
      },
      "post": {
        "tags": [
          "Mailboxes"
        ],
        "summary": "Create a managed mailbox",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "loginAddress": {
                    "minLength": 3,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "mailbox",
                      "smtp"
                    ]
                  },
                  "accessMode": {
                    "type": "string",
                    "enum": [
                      "read",
                      "read_write"
                    ]
                  },
                  "sendingMode": {
                    "type": "string",
                    "enum": [
                      "identity",
                      "scoped_domains"
                    ]
                  },
                  "sendingName": {
                    "nullable": true,
                    "anyOf": [
                      {
                        "maxLength": 255,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "sendingAddress": {
                    "nullable": true,
                    "anyOf": [
                      {
                        "maxLength": 255,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "scopes": {
                    "minItems": 1,
                    "maxItems": 100,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "domain",
                            "address"
                          ]
                        },
                        "domainId": {
                          "minLength": 1,
                          "maxLength": 255,
                          "type": "string"
                        },
                        "address": {
                          "minLength": 3,
                          "maxLength": 255,
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "domainId"
                      ]
                    }
                  }
                },
                "required": [
                  "name",
                  "loginAddress",
                  "type",
                  "accessMode",
                  "sendingMode",
                  "sendingName",
                  "sendingAddress",
                  "scopes"
                ]
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "loginAddress": {
                    "minLength": 3,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "mailbox",
                      "smtp"
                    ]
                  },
                  "accessMode": {
                    "type": "string",
                    "enum": [
                      "read",
                      "read_write"
                    ]
                  },
                  "sendingMode": {
                    "type": "string",
                    "enum": [
                      "identity",
                      "scoped_domains"
                    ]
                  },
                  "sendingName": {
                    "nullable": true,
                    "anyOf": [
                      {
                        "maxLength": 255,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "sendingAddress": {
                    "nullable": true,
                    "anyOf": [
                      {
                        "maxLength": 255,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "scopes": {
                    "minItems": 1,
                    "maxItems": 100,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "domain",
                            "address"
                          ]
                        },
                        "domainId": {
                          "minLength": 1,
                          "maxLength": 255,
                          "type": "string"
                        },
                        "address": {
                          "minLength": 3,
                          "maxLength": 255,
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "domainId"
                      ]
                    }
                  }
                },
                "required": [
                  "name",
                  "loginAddress",
                  "type",
                  "accessMode",
                  "sendingMode",
                  "sendingName",
                  "sendingAddress",
                  "scopes"
                ]
              }
            },
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "loginAddress": {
                    "minLength": 3,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "mailbox",
                      "smtp"
                    ]
                  },
                  "accessMode": {
                    "type": "string",
                    "enum": [
                      "read",
                      "read_write"
                    ]
                  },
                  "sendingMode": {
                    "type": "string",
                    "enum": [
                      "identity",
                      "scoped_domains"
                    ]
                  },
                  "sendingName": {
                    "nullable": true,
                    "anyOf": [
                      {
                        "maxLength": 255,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "sendingAddress": {
                    "nullable": true,
                    "anyOf": [
                      {
                        "maxLength": 255,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "scopes": {
                    "minItems": 1,
                    "maxItems": 100,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "domain",
                            "address"
                          ]
                        },
                        "domainId": {
                          "minLength": 1,
                          "maxLength": 255,
                          "type": "string"
                        },
                        "address": {
                          "minLength": 3,
                          "maxLength": 255,
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "domainId"
                      ]
                    }
                  }
                },
                "required": [
                  "name",
                  "loginAddress",
                  "type",
                  "accessMode",
                  "sendingMode",
                  "sendingName",
                  "sendingAddress",
                  "scopes"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Response for status 201",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "loginAddress": {
                          "type": "string"
                        },
                        "type": {
                          "type": "string",
                          "enum": [
                            "mailbox",
                            "smtp"
                          ]
                        },
                        "accessMode": {
                          "type": "string",
                          "enum": [
                            "read",
                            "read_write"
                          ]
                        },
                        "sendingMode": {
                          "type": "string",
                          "enum": [
                            "identity",
                            "scoped_domains"
                          ]
                        },
                        "sendingName": {
                          "nullable": true,
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "sendingAddress": {
                          "nullable": true,
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "enabled": {
                          "type": "boolean"
                        },
                        "scopes": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "type": {
                                "type": "string",
                                "enum": [
                                  "domain",
                                  "address"
                                ]
                              },
                              "domainId": {
                                "type": "string"
                              },
                              "domain": {
                                "type": "string"
                              },
                              "address": {
                                "nullable": true,
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              }
                            },
                            "required": [
                              "id",
                              "type",
                              "domainId",
                              "domain",
                              "address"
                            ]
                          }
                        },
                        "createdAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "updatedAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "lastUsedAt": {
                          "nullable": true,
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "loginAddress",
                        "type",
                        "accessMode",
                        "sendingMode",
                        "sendingName",
                        "sendingAddress",
                        "enabled",
                        "scopes",
                        "createdAt",
                        "updatedAt",
                        "lastUsedAt"
                      ]
                    },
                    "password": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "data",
                    "password"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Response for status 400",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Response for status 403",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Response for status 409",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Response for status 429",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "postApiE2Mailboxes"
      }
    },
    "/api/e2/mailboxes/{id}": {
      "put": {
        "tags": [
          "Mailboxes"
        ],
        "summary": "Update a managed mailbox",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "minProperties": 1,
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "loginAddress": {
                    "minLength": 3,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "mailbox",
                      "smtp"
                    ]
                  },
                  "accessMode": {
                    "type": "string",
                    "enum": [
                      "read",
                      "read_write"
                    ]
                  },
                  "sendingMode": {
                    "type": "string",
                    "enum": [
                      "identity",
                      "scoped_domains"
                    ]
                  },
                  "sendingName": {
                    "nullable": true,
                    "anyOf": [
                      {
                        "maxLength": 255,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "sendingAddress": {
                    "nullable": true,
                    "anyOf": [
                      {
                        "maxLength": 255,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "enabled": {
                    "type": "boolean"
                  },
                  "scopes": {
                    "minItems": 1,
                    "maxItems": 100,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "domain",
                            "address"
                          ]
                        },
                        "domainId": {
                          "minLength": 1,
                          "maxLength": 255,
                          "type": "string"
                        },
                        "address": {
                          "minLength": 3,
                          "maxLength": 255,
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "domainId"
                      ]
                    }
                  }
                }
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "minProperties": 1,
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "loginAddress": {
                    "minLength": 3,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "mailbox",
                      "smtp"
                    ]
                  },
                  "accessMode": {
                    "type": "string",
                    "enum": [
                      "read",
                      "read_write"
                    ]
                  },
                  "sendingMode": {
                    "type": "string",
                    "enum": [
                      "identity",
                      "scoped_domains"
                    ]
                  },
                  "sendingName": {
                    "nullable": true,
                    "anyOf": [
                      {
                        "maxLength": 255,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "sendingAddress": {
                    "nullable": true,
                    "anyOf": [
                      {
                        "maxLength": 255,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "enabled": {
                    "type": "boolean"
                  },
                  "scopes": {
                    "minItems": 1,
                    "maxItems": 100,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "domain",
                            "address"
                          ]
                        },
                        "domainId": {
                          "minLength": 1,
                          "maxLength": 255,
                          "type": "string"
                        },
                        "address": {
                          "minLength": 3,
                          "maxLength": 255,
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "domainId"
                      ]
                    }
                  }
                }
              }
            },
            "multipart/form-data": {
              "schema": {
                "minProperties": 1,
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "loginAddress": {
                    "minLength": 3,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "mailbox",
                      "smtp"
                    ]
                  },
                  "accessMode": {
                    "type": "string",
                    "enum": [
                      "read",
                      "read_write"
                    ]
                  },
                  "sendingMode": {
                    "type": "string",
                    "enum": [
                      "identity",
                      "scoped_domains"
                    ]
                  },
                  "sendingName": {
                    "nullable": true,
                    "anyOf": [
                      {
                        "maxLength": 255,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "sendingAddress": {
                    "nullable": true,
                    "anyOf": [
                      {
                        "maxLength": 255,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "enabled": {
                    "type": "boolean"
                  },
                  "scopes": {
                    "minItems": 1,
                    "maxItems": 100,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "domain",
                            "address"
                          ]
                        },
                        "domainId": {
                          "minLength": 1,
                          "maxLength": 255,
                          "type": "string"
                        },
                        "address": {
                          "minLength": 3,
                          "maxLength": 255,
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "domainId"
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "loginAddress": {
                          "type": "string"
                        },
                        "type": {
                          "type": "string",
                          "enum": [
                            "mailbox",
                            "smtp"
                          ]
                        },
                        "accessMode": {
                          "type": "string",
                          "enum": [
                            "read",
                            "read_write"
                          ]
                        },
                        "sendingMode": {
                          "type": "string",
                          "enum": [
                            "identity",
                            "scoped_domains"
                          ]
                        },
                        "sendingName": {
                          "nullable": true,
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "sendingAddress": {
                          "nullable": true,
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "enabled": {
                          "type": "boolean"
                        },
                        "scopes": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "type": {
                                "type": "string",
                                "enum": [
                                  "domain",
                                  "address"
                                ]
                              },
                              "domainId": {
                                "type": "string"
                              },
                              "domain": {
                                "type": "string"
                              },
                              "address": {
                                "nullable": true,
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              }
                            },
                            "required": [
                              "id",
                              "type",
                              "domainId",
                              "domain",
                              "address"
                            ]
                          }
                        },
                        "createdAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "updatedAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "lastUsedAt": {
                          "nullable": true,
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      },
                      "required": [
                        "id",
                        "name",
                        "loginAddress",
                        "type",
                        "accessMode",
                        "sendingMode",
                        "sendingName",
                        "sendingAddress",
                        "enabled",
                        "scopes",
                        "createdAt",
                        "updatedAt",
                        "lastUsedAt"
                      ]
                    }
                  },
                  "required": [
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Response for status 400",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Response for status 403",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Response for status 404",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Response for status 409",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Response for status 429",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "putApiE2MailboxesById"
      },
      "delete": {
        "tags": [
          "Mailboxes"
        ],
        "summary": "Delete a managed mailbox",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "const": true,
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Response for status 403",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Response for status 404",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Response for status 429",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "deleteApiE2MailboxesById"
      },
      "get": {
        "tags": [
          "Mailboxes"
        ],
        "summary": "Get a mailbox",
        "description": "Get a mailbox's identity, scopes and unread count. Authenticate with the account API key, or with the mailbox password and the ID `me`.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "loginAddress": {
                      "type": "string"
                    },
                    "accessMode": {
                      "type": "string",
                      "enum": [
                        "read",
                        "read_write"
                      ]
                    },
                    "sendingMode": {
                      "type": "string",
                      "enum": [
                        "identity",
                        "scoped_domains"
                      ]
                    },
                    "sendingName": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "sendingAddress": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "allowedSendingDomains": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "scopes": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "enum": [
                              "domain",
                              "address"
                            ]
                          },
                          "domain": {
                            "type": "string"
                          },
                          "address": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "type",
                          "domain",
                          "address"
                        ]
                      }
                    },
                    "unreadCount": {
                      "type": "number"
                    },
                    "authenticatedAs": {
                      "type": "string",
                      "enum": [
                        "account",
                        "mailbox"
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "loginAddress",
                    "accessMode",
                    "sendingMode",
                    "sendingName",
                    "sendingAddress",
                    "allowedSendingDomains",
                    "scopes",
                    "unreadCount",
                    "authenticatedAs"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Response for status 400",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Response for status 403",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Response for status 404",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Response for status 409",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "getApiE2MailboxesById"
      }
    },
    "/api/e2/mailboxes/{id}/rotate-password": {
      "post": {
        "tags": [
          "Mailboxes"
        ],
        "summary": "Rotate a mailbox password",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "password": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "password"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Response for status 403",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Response for status 404",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Response for status 409",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Response for status 429",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "postApiE2MailboxesByIdRotate-password"
      }
    },
    "/api/e2/mailboxes/authenticate": {
      "post": {
        "tags": [
          "Mailboxes"
        ],
        "summary": "Authenticate a mailbox",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "loginAddress": {
                    "minLength": 3,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "password": {
                    "minLength": 1,
                    "maxLength": 1024,
                    "type": "string"
                  }
                },
                "required": [
                  "loginAddress",
                  "password"
                ]
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "loginAddress": {
                    "minLength": 3,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "password": {
                    "minLength": 1,
                    "maxLength": 1024,
                    "type": "string"
                  }
                },
                "required": [
                  "loginAddress",
                  "password"
                ]
              }
            },
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "loginAddress": {
                    "minLength": 3,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "password": {
                    "minLength": 1,
                    "maxLength": 1024,
                    "type": "string"
                  }
                },
                "required": [
                  "loginAddress",
                  "password"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "credentialId": {
                      "type": "string"
                    },
                    "userId": {
                      "type": "string"
                    },
                    "loginAddress": {
                      "type": "string"
                    },
                    "type": {
                      "const": "mailbox",
                      "type": "string"
                    },
                    "sendingMode": {
                      "type": "string",
                      "enum": [
                        "identity",
                        "scoped_domains"
                      ]
                    },
                    "sendingName": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "sendingAddress": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "accessMode": {
                      "type": "string",
                      "enum": [
                        "read",
                        "read_write"
                      ]
                    },
                    "scopes": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "domain",
                              "address"
                            ]
                          },
                          "domainId": {
                            "type": "string"
                          },
                          "domain": {
                            "type": "string"
                          },
                          "address": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "type",
                          "domainId",
                          "domain",
                          "address"
                        ]
                      }
                    }
                  },
                  "required": [
                    "credentialId",
                    "userId",
                    "loginAddress",
                    "type",
                    "sendingMode",
                    "sendingName",
                    "sendingAddress",
                    "accessMode",
                    "scopes"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Response for status 400",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Response for status 403",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Response for status 429",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Response for status 503",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "postApiE2MailboxesAuthenticate"
      }
    },
    "/api/e2/mailboxes/authenticate-smtp": {
      "post": {
        "tags": [
          "Mailboxes"
        ],
        "summary": "Authenticate for SMTP",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "loginAddress": {
                    "minLength": 3,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "password": {
                    "minLength": 1,
                    "maxLength": 1024,
                    "type": "string"
                  }
                },
                "required": [
                  "loginAddress",
                  "password"
                ]
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "loginAddress": {
                    "minLength": 3,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "password": {
                    "minLength": 1,
                    "maxLength": 1024,
                    "type": "string"
                  }
                },
                "required": [
                  "loginAddress",
                  "password"
                ]
              }
            },
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "loginAddress": {
                    "minLength": 3,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "password": {
                    "minLength": 1,
                    "maxLength": 1024,
                    "type": "string"
                  }
                },
                "required": [
                  "loginAddress",
                  "password"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "credentialId": {
                      "type": "string"
                    },
                    "userId": {
                      "type": "string"
                    },
                    "loginAddress": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "mailbox",
                        "smtp"
                      ]
                    },
                    "sendingMode": {
                      "type": "string",
                      "enum": [
                        "identity",
                        "scoped_domains"
                      ]
                    },
                    "sendingName": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "sendingAddress": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "allowedDomains": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "accessMode": {
                      "type": "string",
                      "enum": [
                        "read",
                        "read_write"
                      ]
                    },
                    "scopes": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "domain",
                              "address"
                            ]
                          },
                          "domainId": {
                            "type": "string"
                          },
                          "domain": {
                            "type": "string"
                          },
                          "address": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "type",
                          "domainId",
                          "domain",
                          "address"
                        ]
                      }
                    }
                  },
                  "required": [
                    "credentialId",
                    "userId",
                    "loginAddress",
                    "type",
                    "sendingMode",
                    "sendingName",
                    "sendingAddress",
                    "allowedDomains",
                    "accessMode",
                    "scopes"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Response for status 400",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Response for status 403",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Response for status 429",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "503": {
            "description": "Response for status 503",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "postApiE2MailboxesAuthenticate-smtp"
      }
    },
    "/api/e2/mailboxes/{id}/messages": {
      "get": {
        "tags": [
          "Mailboxes"
        ],
        "summary": "List mailbox messages",
        "description": "List messages in a mailbox folder, newest first. Only mail within the mailbox's scopes is visible.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "folder",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "inbox",
                "archive",
                "sent"
              ]
            }
          },
          {
            "name": "unread",
            "in": "query",
            "required": false,
            "schema": {
              "description": "'true' for unread only",
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "schema": {
              "description": "Match subject or sender (received) / recipients (sent)",
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "description": "1-100, default 25",
              "type": "string"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "description": "Default 0",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "folder": {
                      "type": "string"
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "folder": {
                            "type": "string",
                            "enum": [
                              "inbox",
                              "archive",
                              "sent"
                            ]
                          },
                          "threadId": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "subject": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "from": {
                            "type": "string"
                          },
                          "to": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "date": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "preview": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "isRead": {
                            "type": "boolean"
                          },
                          "hasAttachments": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "id",
                          "folder",
                          "threadId",
                          "subject",
                          "from",
                          "to",
                          "date",
                          "preview",
                          "isRead",
                          "hasAttachments"
                        ]
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "limit": {
                          "type": "number"
                        },
                        "offset": {
                          "type": "number"
                        },
                        "hasMore": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "limit",
                        "offset",
                        "hasMore"
                      ]
                    }
                  },
                  "required": [
                    "folder",
                    "messages",
                    "pagination"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Response for status 400",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Response for status 403",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Response for status 404",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Response for status 409",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "getApiE2MailboxesByIdMessages"
      }
    },
    "/api/e2/mailboxes/{id}/messages/{messageId}": {
      "get": {
        "tags": [
          "Mailboxes"
        ],
        "summary": "Get a mailbox message",
        "description": "Get a received or sent message with its full text and HTML body.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "messageId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "folder": {
                      "type": "string",
                      "enum": [
                        "inbox",
                        "archive",
                        "sent"
                      ]
                    },
                    "threadId": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "subject": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "from": {
                      "type": "string"
                    },
                    "to": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "date": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "preview": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "isRead": {
                      "type": "boolean"
                    },
                    "hasAttachments": {
                      "type": "boolean"
                    },
                    "messageId": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "inReplyTo": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "cc": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "replyTo": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "envelopeRecipients": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "text": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "html": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "attachments": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "index": {
                            "type": "number"
                          },
                          "filename": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "contentType": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "size": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "index",
                          "filename",
                          "contentType",
                          "size"
                        ]
                      }
                    },
                    "status": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "folder",
                    "threadId",
                    "subject",
                    "from",
                    "to",
                    "date",
                    "preview",
                    "isRead",
                    "hasAttachments",
                    "messageId",
                    "inReplyTo",
                    "cc",
                    "replyTo",
                    "envelopeRecipients",
                    "text",
                    "html",
                    "attachments"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Response for status 400",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Response for status 403",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Response for status 404",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Response for status 409",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "getApiE2MailboxesByIdMessagesByMessageId"
      },
      "patch": {
        "tags": [
          "Mailboxes"
        ],
        "summary": "Mark a mailbox message read or archived",
        "description": "Requires a read_write mailbox. Changes are shared with the dashboard.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "messageId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "isRead": {
                    "type": "boolean"
                  },
                  "isArchived": {
                    "type": "boolean"
                  }
                }
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "isRead": {
                    "type": "boolean"
                  },
                  "isArchived": {
                    "type": "boolean"
                  }
                }
              }
            },
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "isRead": {
                    "type": "boolean"
                  },
                  "isArchived": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "folder": {
                      "type": "string",
                      "enum": [
                        "inbox",
                        "archive",
                        "sent"
                      ]
                    },
                    "threadId": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "subject": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "from": {
                      "type": "string"
                    },
                    "to": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "date": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "preview": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "isRead": {
                      "type": "boolean"
                    },
                    "hasAttachments": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "id",
                    "folder",
                    "threadId",
                    "subject",
                    "from",
                    "to",
                    "date",
                    "preview",
                    "isRead",
                    "hasAttachments"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Response for status 400",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Response for status 403",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Response for status 404",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Response for status 409",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "patchApiE2MailboxesByIdMessagesByMessageId"
      }
    },
    "/api/e2/mailboxes/{id}/threads/{threadId}": {
      "get": {
        "tags": [
          "Mailboxes"
        ],
        "summary": "Get a mailbox thread",
        "description": "Get every message of a conversation that is visible to the mailbox, oldest first.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "threadId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "threadId": {
                      "type": "string"
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "folder": {
                            "type": "string",
                            "enum": [
                              "inbox",
                              "archive",
                              "sent"
                            ]
                          },
                          "threadId": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "subject": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "from": {
                            "type": "string"
                          },
                          "to": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "date": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "preview": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "isRead": {
                            "type": "boolean"
                          },
                          "hasAttachments": {
                            "type": "boolean"
                          },
                          "messageId": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "inReplyTo": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "cc": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "replyTo": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "envelopeRecipients": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "text": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "html": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "attachments": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "index": {
                                  "type": "number"
                                },
                                "filename": {
                                  "nullable": true,
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "contentType": {
                                  "nullable": true,
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "size": {
                                  "nullable": true,
                                  "anyOf": [
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                }
                              },
                              "required": [
                                "index",
                                "filename",
                                "contentType",
                                "size"
                              ]
                            }
                          },
                          "status": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "folder",
                          "threadId",
                          "subject",
                          "from",
                          "to",
                          "date",
                          "preview",
                          "isRead",
                          "hasAttachments",
                          "messageId",
                          "inReplyTo",
                          "cc",
                          "replyTo",
                          "envelopeRecipients",
                          "text",
                          "html",
                          "attachments"
                        ]
                      }
                    }
                  },
                  "required": [
                    "threadId",
                    "messages"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Response for status 400",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Response for status 403",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Response for status 404",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Response for status 409",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "getApiE2MailboxesByIdThreadsByThreadId"
      }
    },
    "/api/e2/mailboxes/{id}/messages/{messageId}/attachments/{index}": {
      "get": {
        "tags": [
          "Mailboxes"
        ],
        "summary": "Download a mailbox attachment",
        "description": "Download an attachment of a received message by its position (0-based).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "messageId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "index",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "400": {
            "description": "Response for status 400",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Response for status 403",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Response for status 404",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Response for status 409",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "getApiE2MailboxesByIdMessagesByMessageIdAttachmentsByIndex"
      }
    },
    "/api/e2/onboarding/demo": {
      "post": {
        "tags": [
          "Onboarding"
        ],
        "summary": "Send onboarding demo email",
        "description": "Send a demo email during onboarding to verify email setup. User must reply to complete onboarding.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "apiKey": {
                    "description": "User's API key for sending",
                    "type": "string"
                  },
                  "to": {
                    "description": "Recipient email address",
                    "type": "string"
                  }
                },
                "required": [
                  "apiKey",
                  "to"
                ]
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "apiKey": {
                    "description": "User's API key for sending",
                    "type": "string"
                  },
                  "to": {
                    "description": "Recipient email address",
                    "type": "string"
                  }
                },
                "required": [
                  "apiKey",
                  "to"
                ]
              }
            },
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "apiKey": {
                    "description": "User's API key for sending",
                    "type": "string"
                  },
                  "to": {
                    "description": "Recipient email address",
                    "type": "string"
                  }
                },
                "required": [
                  "apiKey",
                  "to"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Response for status 201",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "messageId": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Response for status 400",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "postApiE2OnboardingDemo"
      }
    },
    "/api/e2/onboarding/check-reply": {
      "get": {
        "tags": [
          "Onboarding"
        ],
        "summary": "Check for onboarding demo reply",
        "description": "Check if the user has replied to their onboarding demo email. Used during onboarding to detect reply.",
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "hasReply": {
                      "type": "boolean"
                    },
                    "reply": {
                      "type": "object",
                      "properties": {
                        "from": {
                          "type": "string"
                        },
                        "subject": {
                          "type": "string"
                        },
                        "body": {
                          "type": "string"
                        },
                        "receivedAt": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "from",
                        "subject",
                        "body",
                        "receivedAt"
                      ]
                    }
                  },
                  "required": [
                    "hasReply"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "getApiE2OnboardingCheck-reply"
      }
    },
    "/api/e2/guard": {
      "get": {
        "tags": [
          "Guard"
        ],
        "summary": "List guard rules",
        "description": "Get all guard rules for the authenticated user with optional filtering and pagination.",
        "parameters": [
          {
            "name": "search",
            "in": "query",
            "required": false,
            "schema": {
              "description": "Search by rule name or description",
              "type": "string"
            }
          },
          {
            "name": "type",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "explicit",
                "ai_prompt"
              ]
            }
          },
          {
            "name": "isActive",
            "in": "query",
            "required": false,
            "schema": {
              "description": "Filter by active status (true/false)",
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "description": "Max results (1-100, default 50)",
              "type": "string"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "description": "Number to skip (default 0)",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "const": true,
                      "type": "boolean"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "userId": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "description": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "type": {
                            "type": "string"
                          },
                          "config": {
                            "type": "string"
                          },
                          "isActive": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "boolean"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "priority": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "lastTriggeredAt": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "triggerCount": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "actions": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "createdAt": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "updatedAt": {
                            "nullable": true,
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "userId",
                          "name",
                          "description",
                          "type",
                          "config",
                          "isActive",
                          "priority",
                          "lastTriggeredAt",
                          "triggerCount",
                          "actions",
                          "createdAt",
                          "updatedAt"
                        ]
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "total": {
                          "type": "number"
                        },
                        "limit": {
                          "type": "number"
                        },
                        "offset": {
                          "type": "number"
                        },
                        "hasMore": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "total",
                        "limit",
                        "offset",
                        "hasMore"
                      ]
                    }
                  },
                  "required": [
                    "success",
                    "data",
                    "pagination"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "getApiE2Guard"
      },
      "post": {
        "tags": [
          "Guard"
        ],
        "summary": "Create guard rule",
        "description": "Create an active email filtering rule for the authenticated account.\n\nFor an `explicit` rule, configure one or more of `subject`, `from`, `to`, `hasAttachment`, and `hasWords`. Different configured criteria are combined with AND. Within a criterion, `OR` matches any value and `AND` requires every value.\n\nAddress criteria support exact, case-insensitive addresses and whole-domain patterns such as `*@example.com`. The `to` criterion matches the actual delivered recipient, which makes it suitable for limiting a rule to one inbox. Subject and body criteria use case-insensitive substring matching.\n\nRules are evaluated from highest priority to lowest, and the first matching rule wins. A matching rule can `allow`, `block`, or `route` the email to an active endpoint owned by the account. If action is omitted, it defaults to `allow`.\n\nFor an `ai_prompt` rule, provide a non-empty natural-language `prompt` describing when the rule should match.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "examples": [
                  {
                    "name": "Block suspicious support invoices",
                    "description": "Block invoice emails with attachments sent to support.",
                    "type": "explicit",
                    "priority": 100,
                    "config": {
                      "to": {
                        "operator": "OR",
                        "values": [
                          "support@example.com"
                        ]
                      },
                      "subject": {
                        "operator": "OR",
                        "values": [
                          "invoice",
                          "payment overdue"
                        ]
                      },
                      "hasAttachment": true
                    },
                    "action": {
                      "action": "block"
                    }
                  },
                  {
                    "name": "Route partner purchase orders",
                    "type": "explicit",
                    "priority": 50,
                    "config": {
                      "from": {
                        "operator": "OR",
                        "values": [
                          "*@partner.example"
                        ]
                      },
                      "hasWords": {
                        "operator": "AND",
                        "values": [
                          "purchase order",
                          "account number"
                        ]
                      }
                    },
                    "action": {
                      "action": "route",
                      "endpointId": "endpoint_123"
                    }
                  },
                  {
                    "name": "Block credential phishing",
                    "type": "ai_prompt",
                    "config": {
                      "mode": "simple",
                      "prompt": "Match messages attempting to steal passwords, MFA codes, or login credentials."
                    },
                    "action": {
                      "action": "block"
                    }
                  }
                ],
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "description": "A descriptive name for the rule.",
                    "type": "string"
                  },
                  "description": {
                    "description": "Optional explanation of what the rule handles.",
                    "type": "string"
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "explicit",
                      "ai_prompt"
                    ]
                  },
                  "config": {
                    "description": "Configuration matching the selected rule type. See the request examples for complete explicit and AI configurations.",
                    "oneOf": [
                      {
                        "title": "Explicit rule configuration",
                        "type": "object",
                        "properties": {
                          "mode": {
                            "type": "string",
                            "enum": [
                              "simple",
                              "advanced"
                            ]
                          },
                          "subject": {
                            "type": "object",
                            "required": [
                              "operator",
                              "values"
                            ],
                            "properties": {
                              "operator": {
                                "type": "string",
                                "enum": [
                                  "OR",
                                  "AND"
                                ],
                                "description": "OR matches any value; AND requires every value to match."
                              },
                              "values": {
                                "type": "array",
                                "minItems": 1,
                                "items": {
                                  "type": "string"
                                },
                                "description": "Case-insensitive substrings to match."
                              }
                            }
                          },
                          "from": {
                            "type": "object",
                            "required": [
                              "operator",
                              "values"
                            ],
                            "properties": {
                              "operator": {
                                "type": "string",
                                "enum": [
                                  "OR",
                                  "AND"
                                ],
                                "description": "OR matches any address; AND requires every pattern to match."
                              },
                              "values": {
                                "type": "array",
                                "minItems": 1,
                                "items": {
                                  "type": "string"
                                },
                                "description": "Exact email addresses or whole-domain patterns such as *@example.com."
                              }
                            }
                          },
                          "to": {
                            "type": "object",
                            "required": [
                              "operator",
                              "values"
                            ],
                            "properties": {
                              "operator": {
                                "type": "string",
                                "enum": [
                                  "OR",
                                  "AND"
                                ],
                                "description": "OR matches any address; AND requires every pattern to match."
                              },
                              "values": {
                                "type": "array",
                                "minItems": 1,
                                "items": {
                                  "type": "string"
                                },
                                "description": "Exact email addresses or whole-domain patterns such as *@example.com."
                              }
                            }
                          },
                          "hasAttachment": {
                            "type": "boolean",
                            "description": "Match emails based on whether they contain attachments."
                          },
                          "hasWords": {
                            "type": "object",
                            "required": [
                              "operator",
                              "values"
                            ],
                            "properties": {
                              "operator": {
                                "type": "string",
                                "enum": [
                                  "OR",
                                  "AND"
                                ],
                                "description": "OR matches any value; AND requires every value to match."
                              },
                              "values": {
                                "type": "array",
                                "minItems": 1,
                                "items": {
                                  "type": "string"
                                },
                                "description": "Case-insensitive substrings to match."
                              }
                            }
                          }
                        }
                      },
                      {
                        "title": "AI prompt rule configuration",
                        "type": "object",
                        "required": [
                          "prompt"
                        ],
                        "properties": {
                          "mode": {
                            "type": "string",
                            "enum": [
                              "simple",
                              "advanced"
                            ]
                          },
                          "prompt": {
                            "type": "string",
                            "minLength": 1,
                            "description": "Natural-language description of when the rule should match."
                          }
                        }
                      }
                    ]
                  },
                  "priority": {
                    "description": "Evaluation priority. Higher values run first; the first matching rule wins. Defaults to 0.",
                    "default": 0,
                    "type": "number"
                  },
                  "action": {
                    "description": "Action to take when the rule matches: allow, block, or route to an owned endpoint. Defaults to allow when omitted.",
                    "oneOf": [
                      {
                        "title": "Allow",
                        "type": "object",
                        "required": [
                          "action"
                        ],
                        "properties": {
                          "action": {
                            "const": "allow"
                          }
                        }
                      },
                      {
                        "title": "Block",
                        "type": "object",
                        "required": [
                          "action"
                        ],
                        "properties": {
                          "action": {
                            "const": "block"
                          }
                        }
                      },
                      {
                        "title": "Route",
                        "type": "object",
                        "required": [
                          "action",
                          "endpointId"
                        ],
                        "properties": {
                          "action": {
                            "const": "route"
                          },
                          "endpointId": {
                            "type": "string",
                            "description": "ID of an active endpoint owned by the account."
                          }
                        }
                      }
                    ]
                  }
                },
                "required": [
                  "name",
                  "type",
                  "config"
                ]
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "examples": [
                  {
                    "name": "Block suspicious support invoices",
                    "description": "Block invoice emails with attachments sent to support.",
                    "type": "explicit",
                    "priority": 100,
                    "config": {
                      "to": {
                        "operator": "OR",
                        "values": [
                          "support@example.com"
                        ]
                      },
                      "subject": {
                        "operator": "OR",
                        "values": [
                          "invoice",
                          "payment overdue"
                        ]
                      },
                      "hasAttachment": true
                    },
                    "action": {
                      "action": "block"
                    }
                  },
                  {
                    "name": "Route partner purchase orders",
                    "type": "explicit",
                    "priority": 50,
                    "config": {
                      "from": {
                        "operator": "OR",
                        "values": [
                          "*@partner.example"
                        ]
                      },
                      "hasWords": {
                        "operator": "AND",
                        "values": [
                          "purchase order",
                          "account number"
                        ]
                      }
                    },
                    "action": {
                      "action": "route",
                      "endpointId": "endpoint_123"
                    }
                  },
                  {
                    "name": "Block credential phishing",
                    "type": "ai_prompt",
                    "config": {
                      "mode": "simple",
                      "prompt": "Match messages attempting to steal passwords, MFA codes, or login credentials."
                    },
                    "action": {
                      "action": "block"
                    }
                  }
                ],
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "description": "A descriptive name for the rule.",
                    "type": "string"
                  },
                  "description": {
                    "description": "Optional explanation of what the rule handles.",
                    "type": "string"
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "explicit",
                      "ai_prompt"
                    ]
                  },
                  "config": {
                    "description": "Configuration matching the selected rule type. See the request examples for complete explicit and AI configurations.",
                    "oneOf": [
                      {
                        "title": "Explicit rule configuration",
                        "type": "object",
                        "properties": {
                          "mode": {
                            "type": "string",
                            "enum": [
                              "simple",
                              "advanced"
                            ]
                          },
                          "subject": {
                            "type": "object",
                            "required": [
                              "operator",
                              "values"
                            ],
                            "properties": {
                              "operator": {
                                "type": "string",
                                "enum": [
                                  "OR",
                                  "AND"
                                ],
                                "description": "OR matches any value; AND requires every value to match."
                              },
                              "values": {
                                "type": "array",
                                "minItems": 1,
                                "items": {
                                  "type": "string"
                                },
                                "description": "Case-insensitive substrings to match."
                              }
                            }
                          },
                          "from": {
                            "type": "object",
                            "required": [
                              "operator",
                              "values"
                            ],
                            "properties": {
                              "operator": {
                                "type": "string",
                                "enum": [
                                  "OR",
                                  "AND"
                                ],
                                "description": "OR matches any address; AND requires every pattern to match."
                              },
                              "values": {
                                "type": "array",
                                "minItems": 1,
                                "items": {
                                  "type": "string"
                                },
                                "description": "Exact email addresses or whole-domain patterns such as *@example.com."
                              }
                            }
                          },
                          "to": {
                            "type": "object",
                            "required": [
                              "operator",
                              "values"
                            ],
                            "properties": {
                              "operator": {
                                "type": "string",
                                "enum": [
                                  "OR",
                                  "AND"
                                ],
                                "description": "OR matches any address; AND requires every pattern to match."
                              },
                              "values": {
                                "type": "array",
                                "minItems": 1,
                                "items": {
                                  "type": "string"
                                },
                                "description": "Exact email addresses or whole-domain patterns such as *@example.com."
                              }
                            }
                          },
                          "hasAttachment": {
                            "type": "boolean",
                            "description": "Match emails based on whether they contain attachments."
                          },
                          "hasWords": {
                            "type": "object",
                            "required": [
                              "operator",
                              "values"
                            ],
                            "properties": {
                              "operator": {
                                "type": "string",
                                "enum": [
                                  "OR",
                                  "AND"
                                ],
                                "description": "OR matches any value; AND requires every value to match."
                              },
                              "values": {
                                "type": "array",
                                "minItems": 1,
                                "items": {
                                  "type": "string"
                                },
                                "description": "Case-insensitive substrings to match."
                              }
                            }
                          }
                        }
                      },
                      {
                        "title": "AI prompt rule configuration",
                        "type": "object",
                        "required": [
                          "prompt"
                        ],
                        "properties": {
                          "mode": {
                            "type": "string",
                            "enum": [
                              "simple",
                              "advanced"
                            ]
                          },
                          "prompt": {
                            "type": "string",
                            "minLength": 1,
                            "description": "Natural-language description of when the rule should match."
                          }
                        }
                      }
                    ]
                  },
                  "priority": {
                    "description": "Evaluation priority. Higher values run first; the first matching rule wins. Defaults to 0.",
                    "default": 0,
                    "type": "number"
                  },
                  "action": {
                    "description": "Action to take when the rule matches: allow, block, or route to an owned endpoint. Defaults to allow when omitted.",
                    "oneOf": [
                      {
                        "title": "Allow",
                        "type": "object",
                        "required": [
                          "action"
                        ],
                        "properties": {
                          "action": {
                            "const": "allow"
                          }
                        }
                      },
                      {
                        "title": "Block",
                        "type": "object",
                        "required": [
                          "action"
                        ],
                        "properties": {
                          "action": {
                            "const": "block"
                          }
                        }
                      },
                      {
                        "title": "Route",
                        "type": "object",
                        "required": [
                          "action",
                          "endpointId"
                        ],
                        "properties": {
                          "action": {
                            "const": "route"
                          },
                          "endpointId": {
                            "type": "string",
                            "description": "ID of an active endpoint owned by the account."
                          }
                        }
                      }
                    ]
                  }
                },
                "required": [
                  "name",
                  "type",
                  "config"
                ]
              }
            },
            "multipart/form-data": {
              "schema": {
                "examples": [
                  {
                    "name": "Block suspicious support invoices",
                    "description": "Block invoice emails with attachments sent to support.",
                    "type": "explicit",
                    "priority": 100,
                    "config": {
                      "to": {
                        "operator": "OR",
                        "values": [
                          "support@example.com"
                        ]
                      },
                      "subject": {
                        "operator": "OR",
                        "values": [
                          "invoice",
                          "payment overdue"
                        ]
                      },
                      "hasAttachment": true
                    },
                    "action": {
                      "action": "block"
                    }
                  },
                  {
                    "name": "Route partner purchase orders",
                    "type": "explicit",
                    "priority": 50,
                    "config": {
                      "from": {
                        "operator": "OR",
                        "values": [
                          "*@partner.example"
                        ]
                      },
                      "hasWords": {
                        "operator": "AND",
                        "values": [
                          "purchase order",
                          "account number"
                        ]
                      }
                    },
                    "action": {
                      "action": "route",
                      "endpointId": "endpoint_123"
                    }
                  },
                  {
                    "name": "Block credential phishing",
                    "type": "ai_prompt",
                    "config": {
                      "mode": "simple",
                      "prompt": "Match messages attempting to steal passwords, MFA codes, or login credentials."
                    },
                    "action": {
                      "action": "block"
                    }
                  }
                ],
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "description": "A descriptive name for the rule.",
                    "type": "string"
                  },
                  "description": {
                    "description": "Optional explanation of what the rule handles.",
                    "type": "string"
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "explicit",
                      "ai_prompt"
                    ]
                  },
                  "config": {
                    "description": "Configuration matching the selected rule type. See the request examples for complete explicit and AI configurations.",
                    "oneOf": [
                      {
                        "title": "Explicit rule configuration",
                        "type": "object",
                        "properties": {
                          "mode": {
                            "type": "string",
                            "enum": [
                              "simple",
                              "advanced"
                            ]
                          },
                          "subject": {
                            "type": "object",
                            "required": [
                              "operator",
                              "values"
                            ],
                            "properties": {
                              "operator": {
                                "type": "string",
                                "enum": [
                                  "OR",
                                  "AND"
                                ],
                                "description": "OR matches any value; AND requires every value to match."
                              },
                              "values": {
                                "type": "array",
                                "minItems": 1,
                                "items": {
                                  "type": "string"
                                },
                                "description": "Case-insensitive substrings to match."
                              }
                            }
                          },
                          "from": {
                            "type": "object",
                            "required": [
                              "operator",
                              "values"
                            ],
                            "properties": {
                              "operator": {
                                "type": "string",
                                "enum": [
                                  "OR",
                                  "AND"
                                ],
                                "description": "OR matches any address; AND requires every pattern to match."
                              },
                              "values": {
                                "type": "array",
                                "minItems": 1,
                                "items": {
                                  "type": "string"
                                },
                                "description": "Exact email addresses or whole-domain patterns such as *@example.com."
                              }
                            }
                          },
                          "to": {
                            "type": "object",
                            "required": [
                              "operator",
                              "values"
                            ],
                            "properties": {
                              "operator": {
                                "type": "string",
                                "enum": [
                                  "OR",
                                  "AND"
                                ],
                                "description": "OR matches any address; AND requires every pattern to match."
                              },
                              "values": {
                                "type": "array",
                                "minItems": 1,
                                "items": {
                                  "type": "string"
                                },
                                "description": "Exact email addresses or whole-domain patterns such as *@example.com."
                              }
                            }
                          },
                          "hasAttachment": {
                            "type": "boolean",
                            "description": "Match emails based on whether they contain attachments."
                          },
                          "hasWords": {
                            "type": "object",
                            "required": [
                              "operator",
                              "values"
                            ],
                            "properties": {
                              "operator": {
                                "type": "string",
                                "enum": [
                                  "OR",
                                  "AND"
                                ],
                                "description": "OR matches any value; AND requires every value to match."
                              },
                              "values": {
                                "type": "array",
                                "minItems": 1,
                                "items": {
                                  "type": "string"
                                },
                                "description": "Case-insensitive substrings to match."
                              }
                            }
                          }
                        }
                      },
                      {
                        "title": "AI prompt rule configuration",
                        "type": "object",
                        "required": [
                          "prompt"
                        ],
                        "properties": {
                          "mode": {
                            "type": "string",
                            "enum": [
                              "simple",
                              "advanced"
                            ]
                          },
                          "prompt": {
                            "type": "string",
                            "minLength": 1,
                            "description": "Natural-language description of when the rule should match."
                          }
                        }
                      }
                    ]
                  },
                  "priority": {
                    "description": "Evaluation priority. Higher values run first; the first matching rule wins. Defaults to 0.",
                    "default": 0,
                    "type": "number"
                  },
                  "action": {
                    "description": "Action to take when the rule matches: allow, block, or route to an owned endpoint. Defaults to allow when omitted.",
                    "oneOf": [
                      {
                        "title": "Allow",
                        "type": "object",
                        "required": [
                          "action"
                        ],
                        "properties": {
                          "action": {
                            "const": "allow"
                          }
                        }
                      },
                      {
                        "title": "Block",
                        "type": "object",
                        "required": [
                          "action"
                        ],
                        "properties": {
                          "action": {
                            "const": "block"
                          }
                        }
                      },
                      {
                        "title": "Route",
                        "type": "object",
                        "required": [
                          "action",
                          "endpointId"
                        ],
                        "properties": {
                          "action": {
                            "const": "route"
                          },
                          "endpointId": {
                            "type": "string",
                            "description": "ID of an active endpoint owned by the account."
                          }
                        }
                      }
                    ]
                  }
                },
                "required": [
                  "name",
                  "type",
                  "config"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The newly created active guard rule.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "The newly created active guard rule.",
                  "examples": [
                    {
                      "success": true,
                      "data": {
                        "id": "V1StGXR8_Z5jdHi6B-myT",
                        "userId": "user_123",
                        "name": "Block suspicious support invoices",
                        "description": "Block invoice emails with attachments sent to support.",
                        "type": "explicit",
                        "config": "{\"to\":{\"operator\":\"OR\",\"values\":[\"support@example.com\"]},\"subject\":{\"operator\":\"OR\",\"values\":[\"invoice\",\"payment overdue\"]},\"hasAttachment\":true}",
                        "isActive": true,
                        "priority": 100,
                        "lastTriggeredAt": null,
                        "triggerCount": 0,
                        "actions": "{\"action\":\"block\"}",
                        "createdAt": "2026-06-12T17:00:00.000Z",
                        "updatedAt": "2026-06-12T17:00:00.000Z"
                      }
                    }
                  ],
                  "type": "object",
                  "properties": {
                    "success": {
                      "const": true,
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "userId": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "description": {
                          "nullable": true,
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "type": {
                          "type": "string"
                        },
                        "config": {
                          "type": "string"
                        },
                        "isActive": {
                          "nullable": true,
                          "anyOf": [
                            {
                              "type": "boolean"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "priority": {
                          "nullable": true,
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "lastTriggeredAt": {
                          "nullable": true,
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "triggerCount": {
                          "nullable": true,
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "actions": {
                          "nullable": true,
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "createdAt": {
                          "nullable": true,
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "updatedAt": {
                          "nullable": true,
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      },
                      "required": [
                        "id",
                        "userId",
                        "name",
                        "description",
                        "type",
                        "config",
                        "isActive",
                        "priority",
                        "lastTriggeredAt",
                        "triggerCount",
                        "actions",
                        "createdAt",
                        "updatedAt"
                      ]
                    }
                  },
                  "required": [
                    "success",
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Response for status 400",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "postApiE2Guard"
      }
    },
    "/api/e2/guard/{id}": {
      "get": {
        "tags": [
          "Guard"
        ],
        "summary": "Get guard rule",
        "description": "Get a specific guard rule by ID.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "userId": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "description": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "type": {
                      "type": "string"
                    },
                    "config": {
                      "type": "string"
                    },
                    "isActive": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "boolean"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "priority": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "lastTriggeredAt": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "triggerCount": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "actions": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "updatedAt": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "userId",
                    "name",
                    "description",
                    "type",
                    "config",
                    "isActive",
                    "priority",
                    "lastTriggeredAt",
                    "triggerCount",
                    "actions",
                    "createdAt",
                    "updatedAt"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Response for status 404",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "getApiE2GuardById"
      },
      "put": {
        "tags": [
          "Guard"
        ],
        "summary": "Update guard rule",
        "description": "Update an existing guard rule.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "description": "Rule name",
                    "type": "string"
                  },
                  "description": {
                    "description": "Rule description",
                    "type": "string"
                  },
                  "config": {
                    "description": "Rule configuration (JSON)"
                  },
                  "isActive": {
                    "description": "Whether the rule is active",
                    "type": "boolean"
                  },
                  "priority": {
                    "description": "Rule priority",
                    "type": "number"
                  },
                  "action": {
                    "description": "Rule action configuration"
                  }
                }
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "description": "Rule name",
                    "type": "string"
                  },
                  "description": {
                    "description": "Rule description",
                    "type": "string"
                  },
                  "config": {
                    "description": "Rule configuration (JSON)"
                  },
                  "isActive": {
                    "description": "Whether the rule is active",
                    "type": "boolean"
                  },
                  "priority": {
                    "description": "Rule priority",
                    "type": "number"
                  },
                  "action": {
                    "description": "Rule action configuration"
                  }
                }
              }
            },
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "description": "Rule name",
                    "type": "string"
                  },
                  "description": {
                    "description": "Rule description",
                    "type": "string"
                  },
                  "config": {
                    "description": "Rule configuration (JSON)"
                  },
                  "isActive": {
                    "description": "Whether the rule is active",
                    "type": "boolean"
                  },
                  "priority": {
                    "description": "Rule priority",
                    "type": "number"
                  },
                  "action": {
                    "description": "Rule action configuration"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "userId": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "description": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "type": {
                      "type": "string"
                    },
                    "config": {
                      "type": "string"
                    },
                    "isActive": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "boolean"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "priority": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "lastTriggeredAt": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "triggerCount": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "actions": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "updatedAt": {
                      "nullable": true,
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "id",
                    "userId",
                    "name",
                    "description",
                    "type",
                    "config",
                    "isActive",
                    "priority",
                    "lastTriggeredAt",
                    "triggerCount",
                    "actions",
                    "createdAt",
                    "updatedAt"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Response for status 400",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Response for status 404",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "putApiE2GuardById"
      },
      "delete": {
        "tags": [
          "Guard"
        ],
        "summary": "Delete guard rule",
        "description": "Delete a guard rule by ID.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "success"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Response for status 404",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "deleteApiE2GuardById"
      }
    },
    "/api/e2/guard/{id}/check": {
      "post": {
        "tags": [
          "Guard"
        ],
        "summary": "Check if rule matches email",
        "description": "Test a guard rule against a specific email to see if it would match.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "structuredEmailId": {
                    "description": "ID of the email to test against the rule",
                    "type": "string"
                  }
                },
                "required": [
                  "structuredEmailId"
                ]
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "structuredEmailId": {
                    "description": "ID of the email to test against the rule",
                    "type": "string"
                  }
                },
                "required": [
                  "structuredEmailId"
                ]
              }
            },
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "structuredEmailId": {
                    "description": "ID of the email to test against the rule",
                    "type": "string"
                  }
                },
                "required": [
                  "structuredEmailId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "type": "object",
                      "properties": {
                        "matched": {
                          "type": "boolean"
                        },
                        "matchDetails": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "criteria": {
                                "type": "string"
                              },
                              "value": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "criteria",
                              "value"
                            ]
                          }
                        },
                        "reason": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "matched"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "matched": {
                          "const": false,
                          "type": "boolean"
                        },
                        "error": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "matched",
                        "error"
                      ]
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Response for status 400",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "postApiE2GuardByIdCheck"
      }
    },
    "/api/e2/guard/generate": {
      "post": {
        "tags": [
          "Guard"
        ],
        "summary": "Generate rule from natural language",
        "description": "Use AI to convert a natural language description into an explicit guard rule configuration.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "prompt": {
                    "minLength": 1,
                    "description": "Natural language description of the rule",
                    "type": "string"
                  }
                },
                "required": [
                  "prompt"
                ]
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "prompt": {
                    "minLength": 1,
                    "description": "Natural language description of the rule",
                    "type": "string"
                  }
                },
                "required": [
                  "prompt"
                ]
              }
            },
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "prompt": {
                    "minLength": 1,
                    "description": "Natural language description of the rule",
                    "type": "string"
                  }
                },
                "required": [
                  "prompt"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Response for status 200",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "type": "object",
                      "properties": {
                        "config": {
                          "type": "object",
                          "properties": {
                            "mode": {
                              "anyOf": [
                                {
                                  "const": "simple",
                                  "type": "string"
                                },
                                {
                                  "const": "advanced",
                                  "type": "string"
                                }
                              ]
                            },
                            "subject": {
                              "type": "object",
                              "properties": {
                                "operator": {
                                  "anyOf": [
                                    {
                                      "const": "OR",
                                      "type": "string"
                                    },
                                    {
                                      "const": "AND",
                                      "type": "string"
                                    }
                                  ]
                                },
                                "values": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                }
                              },
                              "required": [
                                "operator",
                                "values"
                              ]
                            },
                            "from": {
                              "type": "object",
                              "properties": {
                                "operator": {
                                  "anyOf": [
                                    {
                                      "const": "OR",
                                      "type": "string"
                                    },
                                    {
                                      "const": "AND",
                                      "type": "string"
                                    }
                                  ]
                                },
                                "values": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                }
                              },
                              "required": [
                                "operator",
                                "values"
                              ]
                            },
                            "to": {
                              "type": "object",
                              "properties": {
                                "operator": {
                                  "anyOf": [
                                    {
                                      "const": "OR",
                                      "type": "string"
                                    },
                                    {
                                      "const": "AND",
                                      "type": "string"
                                    }
                                  ]
                                },
                                "values": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                }
                              },
                              "required": [
                                "operator",
                                "values"
                              ]
                            },
                            "hasAttachment": {
                              "type": "boolean"
                            },
                            "hasWords": {
                              "type": "object",
                              "properties": {
                                "operator": {
                                  "anyOf": [
                                    {
                                      "const": "OR",
                                      "type": "string"
                                    },
                                    {
                                      "const": "AND",
                                      "type": "string"
                                    }
                                  ]
                                },
                                "values": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                }
                              },
                              "required": [
                                "operator",
                                "values"
                              ]
                            }
                          }
                        }
                      },
                      "required": [
                        "config"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "config": {
                          "type": "object",
                          "properties": {}
                        },
                        "error": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "config",
                        "error"
                      ]
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Response for status 400",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Response for status 401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Response for status 500",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "operationId": "postApiE2GuardGenerate"
      }
    }
  }
}