openapi: 3.1.0
servers:
  - url: https://inbound.new
    description: Production API server
info:
  title: Inbound Email API
  description: >+

    # Inbound API


    The Inbound API allows you to manage email infrastructure programmatically -
    domains, email addresses, webhooks, and more.


    ## Authentication


    All API requests require a Bearer token in the Authorization header:


    ```bash

    curl -H "Authorization: Bearer YOUR_API_KEY" \
      https://inbound.new/api/e2/domains
    ```


    ## Base URL


    ```

    https://inbound.new/api/e2

    ```


    ## Quick Start


    1. **Create a domain** - Register your domain with Inbound

    2. **Configure DNS** - Add the provided DNS records to your domain

    3. **Create an email address** - Set up addresses to receive emails

    4. **Create an endpoint** - Configure where emails are delivered (webhook,
    forwarding, etc.)

  version: 2.0.0
webhooks:
  emailReceived:
    post:
      summary: Email Received
      description: >

        When emails arrive at your configured addresses, Inbound sends a webhook
        to your endpoint with the complete email data.


        ## Webhook Payload Structure


        We provide a fully typed webhook payload for you to use in your
        endpoints:


        ```typescript

        import type { InboundWebhookPayload } from 'inboundemail'

        ```


        ### Example Payload


        ```typescript

        const payload: InboundWebhookPayload = {
          event: 'email.received',
          timestamp: '2024-01-15T10:30:00Z',
          email: {
            id: 'inbnd_abc123def456ghi',
            messageId: '<unique-id@sender.com>',
            from: {
              text: 'John Doe <john@sender.com>',
              addresses: [{
                name: 'John Doe',
                address: 'john@sender.com'
              }]
            },
            to: {
              text: 'support@yourdomain.com',
              addresses: [{
                name: null,
                address: 'support@yourdomain.com'
              }]
            },
            recipient: 'support@yourdomain.com',
            subject: 'Help with my order',
            receivedAt: '2024-01-15T10:30:00Z',
            parsedData: {
              messageId: '<unique-id@sender.com>',
              date: new Date('2024-01-15T10:30:00Z'),
              subject: 'Help with my order',
              from: { /* ... */ },
              to: { /* ... */ },
              cc: null,
              bcc: null,
              replyTo: null,
              textBody: 'Hello, I need help with my recent order...',
              htmlBody: '<p>Hello, I need help with my recent order...</p>',
              attachments: [
                {
                  filename: 'order-receipt.pdf',
                  contentType: 'application/pdf',
                  size: 45678,
                  contentId: '<att_abc123>',
                  contentDisposition: 'attachment',
                  downloadUrl: 'https://inbound.new/api/e2/attachments/inbnd_abc123/order-receipt.pdf'
                }
              ]
            }
          },
          endpoint: {
            id: 'endp_xyz789',
            name: 'Support Webhook',
            type: 'webhook'
          }
        }

        ```


        ## Webhook Security


        Always verify webhook requests before processing them to prevent
        unauthorized access.


        ### Verification Headers


        Every webhook request includes security headers:


        | Header | Description |

        |--------|-------------|

        | `X-Webhook-Verification-Token` | Unique verification token for your
        endpoint |

        | `X-Endpoint-ID` | ID of the endpoint that triggered this webhook |

        | `X-Webhook-Event` | Event type (e.g., `email.received`) |

        | `X-Webhook-Timestamp` | ISO 8601 timestamp of when the webhook was
        sent |


        ### Verifying with the SDK


        ```typescript

        import { Inbound, verifyWebhookFromHeaders } from 'inboundemail'


        const inbound = new Inbound(process.env.INBOUND_API_KEY!)


        export async function POST(request: Request) {
          // Verify webhook authenticity before processing
          const isValid = await verifyWebhookFromHeaders(request.headers, inbound)
          
          if (!isValid) {
            return new Response('Unauthorized', { status: 401 })
          }
          
          // Process the verified webhook payload
          const payload: InboundWebhookPayload = await request.json()
          const { email } = payload
          
          console.log('Received verified email:', email.subject)
          
          return new Response('OK', { status: 200 })
        }

        ```


        ## Downloading Attachments


        Each attachment includes a `downloadUrl` for direct file access:


        ```typescript

        // Download attachments from webhook payload

        for (const attachment of email.parsedData.attachments) {
          const response = await fetch(attachment.downloadUrl, {
            headers: {
              'Authorization': `Bearer ${process.env.INBOUND_API_KEY}`
            }
          })
          
          if (response.ok) {
            const fileBuffer = await response.arrayBuffer()
            // Process the file...
          }
        }

        ```


        > **Note:** Authentication via API key in the Authorization header is
        required to download attachments.
      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'
                        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
                        - 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
                required:
                  - data
                  - pagination
      operationId: getApiE2Domains
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Inbound from 'inboundemail';

            const client = new Inbound({
              apiKey: process.env['INBOUND_API_KEY'], // This is the default and can be omitted
            });

            const domains = await client.domains.list();

            console.log(domains.data);
    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
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Inbound from 'inboundemail';

            const client = new Inbound({
              apiKey: process.env['INBOUND_API_KEY'], // This is the default and can be omitted
            });

            const domain = await client.domains.create({ domain: 'x' });

            console.log(domain.id);
  /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'
                  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'
                required:
                  - id
                  - domain
                  - status
                  - canReceiveEmails
                  - hasMxRecords
                  - domainProvider
                  - providerConfidence
                  - lastDnsCheck
                  - lastSesCheck
                  - isCatchAllEnabled
                  - catchAllEndpointId
                  - 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
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Inbound from 'inboundemail';

            const client = new Inbound({
              apiKey: process.env['INBOUND_API_KEY'], // This is the default and can be omitted
            });

            const domain = await client.domains.retrieve('id');

            console.log(domain.id);
    patch:
      tags:
        - Domains
      summary: Update domain catch-all settings
      description: >-
        Update catch-all email settings for a domain. Catch-all receives emails
        sent to any address on your domain. 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'
              required:
                - isCatchAllEnabled
          application/x-www-form-urlencoded:
            schema:
              type: object
              properties:
                isCatchAllEnabled:
                  type: boolean
                catchAllEndpointId:
                  nullable: true
                  anyOf:
                    - type: string
                    - type: 'null'
              required:
                - isCatchAllEnabled
          multipart/form-data:
            schema:
              type: object
              properties:
                isCatchAllEnabled:
                  type: boolean
                catchAllEndpointId:
                  nullable: true
                  anyOf:
                    - type: string
                    - type: 'null'
              required:
                - isCatchAllEnabled
      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'
                  updatedAt:
                    format: date-time
                    type: string
                required:
                  - id
                  - domain
                  - status
                  - isCatchAllEnabled
                  - catchAllEndpointId
                  - 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: patchApiE2DomainsById
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import Inbound from 'inboundemail';


            const client = new Inbound({
              apiKey: process.env['INBOUND_API_KEY'], // This is the default and can be omitted
            });


            const domain = await client.domains.update('id', {
            isCatchAllEnabled: true });


            console.log(domain.id);
    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
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Inbound from 'inboundemail';

            const client = new Inbound({
              apiKey: process.env['INBOUND_API_KEY'], // This is the default and can be omitted
            });

            const domain = await client.domains.delete('id');

            console.log(domain.deletedResources);
  /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
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Inbound from 'inboundemail';

            const client = new Inbound({
              apiKey: process.env['INBOUND_API_KEY'], // This is the default and can be omitted
            });

            const endpoints = await client.endpoints.list();

            console.log(endpoints.data);
    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
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Inbound from 'inboundemail';

            const client = new Inbound({
              apiKey: process.env['INBOUND_API_KEY'], // This is the default and can be omitted
            });

            const endpoint = await client.endpoints.create({
              config: { url: 'url' },
              name: 'x',
              type: 'webhook',
            });

            console.log(endpoint.id);
  /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
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Inbound from 'inboundemail';

            const client = new Inbound({
              apiKey: process.env['INBOUND_API_KEY'], // This is the default and can be omitted
            });

            const endpoint = await client.endpoints.retrieve('id');

            console.log(endpoint.id);
    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
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Inbound from 'inboundemail';

            const client = new Inbound({
              apiKey: process.env['INBOUND_API_KEY'], // This is the default and can be omitted
            });

            const endpoint = await client.endpoints.update('id');

            console.log(endpoint.id);
    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
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Inbound from 'inboundemail';

            const client = new Inbound({
              apiKey: process.env['INBOUND_API_KEY'], // This is the default and can be omitted
            });

            const endpoint = await client.endpoints.delete('id');

            console.log(endpoint.cleanup);
  /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
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Inbound from 'inboundemail';

            const client = new Inbound({
              apiKey: process.env['INBOUND_API_KEY'], // This is the default and can be omitted
            });

            const response = await client.endpoints.test('id');

            console.log(response.message);
  /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
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Inbound from 'inboundemail';

            const client = new Inbound({
              apiKey: process.env['INBOUND_API_KEY'], // This is the default and can be omitted
            });

            const emailAddresses = await client.emailAddresses.list();

            console.log(emailAddresses.data);
    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
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import Inbound from 'inboundemail';


            const client = new Inbound({
              apiKey: process.env['INBOUND_API_KEY'], // This is the default and can be omitted
            });


            const emailAddress = await client.emailAddresses.create({ address:
            'x', domainId: 'x' });


            console.log(emailAddress.id);
  /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
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Inbound from 'inboundemail';

            const client = new Inbound({
              apiKey: process.env['INBOUND_API_KEY'], // This is the default and can be omitted
            });

            const emailAddress = await client.emailAddresses.retrieve('id');

            console.log(emailAddress.id);
    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
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Inbound from 'inboundemail';

            const client = new Inbound({
              apiKey: process.env['INBOUND_API_KEY'], // This is the default and can be omitted
            });

            const emailAddress = await client.emailAddresses.update('id');

            console.log(emailAddress.id);
    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
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Inbound from 'inboundemail';

            const client = new Inbound({
              apiKey: process.env['INBOUND_API_KEY'], // This is the default and can be omitted
            });

            const emailAddress = await client.emailAddresses.delete('id');

            console.log(emailAddress.cleanup);
  /api/e2/attachments/{id}/{filename}:
    get:
      tags:
        - Attachments
      summary: Download email attachment
      description: >-
        Download an email attachment by email ID and filename. Returns the
        binary file content with appropriate Content-Type and
        Content-Disposition headers.
      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
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Inbound from 'inboundemail';

            const client = new Inbound({
              apiKey: process.env['INBOUND_API_KEY'], // This is the default and can be omitted
            });

            await client.attachments.retrieve('filename', { id: 'id' });
  /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:
                        type: string
                      content:
                        type: string
                      content_type:
                        type: string
                      path:
                        type: string
                    required:
                      - filename
                      - content
                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:
                        type: string
                      content:
                        type: string
                      content_type:
                        type: string
                      path:
                        type: string
                    required:
                      - filename
                      - content
                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:
                        type: string
                      content:
                        type: string
                      content_type:
                        type: string
                      path:
                        type: string
                    required:
                      - filename
                      - content
                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
        '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
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Inbound from 'inboundemail';

            const client = new Inbound({
              apiKey: process.env['INBOUND_API_KEY'], // This is the default and can be omitted
            });

            const response = await client.emails.send({
              from: 'from',
              subject: 'subject',
              to: 'string',
            });

            console.log(response.id);
    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
              - 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
                        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
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Inbound from 'inboundemail';

            const client = new Inbound({
              apiKey: process.env['INBOUND_API_KEY'], // This is the default and can be omitted
            });

            const emails = await client.emails.list();

            console.log(emails.data);
  /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
                  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
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Inbound from 'inboundemail';

            const client = new Inbound({
              apiKey: process.env['INBOUND_API_KEY'], // This is the default and can be omitted
            });

            const email = await client.emails.retrieve('id');

            console.log(email.id);
    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
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Inbound from 'inboundemail';

            const client = new Inbound({
              apiKey: process.env['INBOUND_API_KEY'], // This is the default and can be omitted
            });

            const email = await client.emails.delete('id');

            console.log(email.id);
  /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:
                        type: string
                      content:
                        type: string
                      content_type:
                        type: string
                      path:
                        type: string
                    required:
                      - filename
                      - content
                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:
                        type: string
                      content:
                        type: string
                      content_type:
                        type: string
                      path:
                        type: string
                    required:
                      - filename
                      - content
                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:
                        type: string
                      content:
                        type: string
                      content_type:
                        type: string
                      path:
                        type: string
                    required:
                      - filename
                      - content
                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
        '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
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Inbound from 'inboundemail';

            const client = new Inbound({
              apiKey: process.env['INBOUND_API_KEY'], // This is the default and can be omitted
            });

            const response = await client.emails.reply('id', { from: 'from' });

            console.log(response.id);
  /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
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Inbound from 'inboundemail';

            const client = new Inbound({
              apiKey: process.env['INBOUND_API_KEY'], // This is the default and can be omitted
            });

            const response = await client.emails.retry('id');

            console.log(response.delivery_id);
  /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.


        **What is a Thread?**

        A 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.


        **Use with /mail/threads/:id:**

        Use 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
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Inbound from 'inboundemail';

            const client = new Inbound({
              apiKey: process.env['INBOUND_API_KEY'], // This is the default and can be omitted
            });

            const mail = await client.mail.list();

            console.log(mail.filters);
  /api/e2/mail/threads/{id}:
    get:
      tags:
        - Inbox
      summary: Get thread by ID
      description: |
        Retrieve a complete email thread (conversation) with all messages.

        **What You Get:**
        - Thread metadata (subject, participants, timestamps)
        - All messages in the thread (both inbound and outbound)
        - Messages sorted chronologically by thread position

        **Message Types:**
        - `inbound` - Emails you received
        - `outbound` - Emails you sent (includes delivery status)
      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
                        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
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Inbound from 'inboundemail';

            const client = new Inbound({
              apiKey: process.env['INBOUND_API_KEY'], // This is the default and can be omitted
            });

            const mail = await client.mail.retrieve('id');

            console.log(mail.messages);
  /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 a new email filtering guard rule.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  minLength: 1
                  description: Rule name
                  type: string
                description:
                  description: Rule description
                  type: string
                type:
                  type: string
                  enum:
                    - explicit
                    - ai_prompt
                config:
                  description: Rule configuration (JSON)
                priority:
                  description: Rule priority (higher = evaluated first)
                  type: number
                action:
                  description: Rule action configuration
              required:
                - name
                - type
                - config
          application/x-www-form-urlencoded:
            schema:
              type: object
              properties:
                name:
                  minLength: 1
                  description: Rule name
                  type: string
                description:
                  description: Rule description
                  type: string
                type:
                  type: string
                  enum:
                    - explicit
                    - ai_prompt
                config:
                  description: Rule configuration (JSON)
                priority:
                  description: Rule priority (higher = evaluated first)
                  type: number
                action:
                  description: Rule action configuration
              required:
                - name
                - type
                - config
          multipart/form-data:
            schema:
              type: object
              properties:
                name:
                  minLength: 1
                  description: Rule name
                  type: string
                description:
                  description: Rule description
                  type: string
                type:
                  type: string
                  enum:
                    - explicit
                    - ai_prompt
                config:
                  description: Rule configuration (JSON)
                priority:
                  description: Rule priority (higher = evaluated first)
                  type: number
                action:
                  description: Rule action configuration
              required:
                - name
                - type
                - config
      responses:
        '201':
          description: Response for status 201
          content:
            application/json:
              schema:
                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
                          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
