> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tetherai.ca/llms.txt
> Use this file to discover all available pages before exploring further.

# Inbox Drop ingress — inbound email payload from provider adapter

> Inbox Drop ingress that receives a parsed inbound email payload from a provider-specific adapter (today: the `sendgrid-inbound` service). The api evaluates which workflows' `InboxDropTrigger` nodes match the email's `subject`/`from` filters and enqueues one BullMQ job per match. **Auth is the shared `INTERNAL_SERVICE_TOKEN` via the `X-Internal-Token` header — NOT user auth.** Adapter services hold this token; external callers must not hit this endpoint directly. Returns 202 with `matchedCount` so the caller can decide whether to fall back to a non-workflow path when no workflow matched.



## OpenAPI

````yaml /api-reference/openapi.yaml post /api/webhook/inbox-drop
openapi: 3.0.3
info:
  title: Tether Relay and Tether API
  version: 1.0.0
  description: >-
    Route-derived OpenAPI contract generated from tether-relay backend sources.
    Regenerate with scripts/sync-openapi-from-backend.mjs.
servers:
  - url: https://your-instance.example.com
    description: Production
  - url: http://localhost:2212
    description: Local API service
security: []
tags:
  - name: AI
  - name: Applications
  - name: Approval
  - name: Auth
  - name: Automations
  - name: Calls
  - name: Campaigns
  - name: Contact Analytics
  - name: Contact Metrics
  - name: Contact Notes
  - name: Contacts
  - name: Conversation Monitor
  - name: Conversations
  - name: Departments
  - name: Email
  - name: Escalation Dashboard
  - name: Event Logs
  - name: Google Sheets
  - name: Marketplace
  - name: Messages
  - name: Notification Sounds
  - name: Notifications
  - name: Org Snapshots
  - name: Organizations
  - name: Outreach
  - name: Outreach Metrics
  - name: Outreach Sources
  - name: Pipelines
  - name: Processes
  - name: Prompts
  - name: Reminders
  - name: Sms
  - name: Templates
  - name: Traces
  - name: Training
  - name: Upload
  - name: User Snapshots
  - name: Users
  - name: Vertical
  - name: Webchats
  - name: Webhook
paths:
  /api/webhook/inbox-drop:
    post:
      tags:
        - Webhooks
      summary: Inbox Drop ingress — inbound email payload from provider adapter
      description: >-
        Inbox Drop ingress that receives a parsed inbound email payload from a
        provider-specific adapter (today: the `sendgrid-inbound` service). The
        api evaluates which workflows' `InboxDropTrigger` nodes match the
        email's `subject`/`from` filters and enqueues one BullMQ job per match.
        **Auth is the shared `INTERNAL_SERVICE_TOKEN` via the `X-Internal-Token`
        header — NOT user auth.** Adapter services hold this token; external
        callers must not hit this endpoint directly. Returns 202 with
        `matchedCount` so the caller can decide whether to fall back to a
        non-workflow path when no workflow matched.
      operationId: post_webhook_inbox_drop
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/InboxDropRequest'
      responses:
        '202':
          description: Inbound email accepted and matching workflows enqueued
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InboxDropResponse'
        '400':
          description: Missing organizationId/emailData, or invalid email fields
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InboxDropValidationErrorResponse'
        '401':
          description: INTERNAL_SERVICE_TOKEN not configured server-side
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookErrorResponse'
        '403':
          description: Internal service token mismatch
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookErrorResponse'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookErrorResponse'
components:
  schemas:
    InboxDropRequest:
      type: object
      description: >-
        Internal-service request body sent by inbound-email adapters (SendGrid,
        etc.) to fan out to matching workflows.
      properties:
        organizationId:
          type: string
        userId:
          type: string
          description: Optional. Falls back to the workflow's owning user when missing.
        emailData:
          $ref: '#/components/schemas/InboxDropEmailData'
        metadata:
          type: object
          properties:
            receivedAt:
              type: string
              format: date-time
            source:
              type: string
              description: Defaults to "inbox_drop" if omitted.
            leadManagementId:
              type: string
          additionalProperties: true
      required:
        - organizationId
        - emailData
      additionalProperties: true
      example:
        organizationId: 64a1b2c3d4e5f60012345678
        userId: 64a1b2c3d4e5f60012345679
        emailData:
          from: alex.nguyen@example.com
          to:
            - inbound+org-64a1b@inbound.tetherai.ca
          subject: Maple Court availability
          body: Hi — could you confirm the corner unit is still listed?
        metadata:
          receivedAt: '2026-05-20T15:04:01.135Z'
          source: sendgrid_inbound
    InboxDropResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - true
        matchedCount:
          type: integer
          description: >-
            Number of workflows whose InboxDropTrigger matched this email. 0 =
            no match; the adapter may fall back to a non-workflow handler.
      required:
        - success
        - matchedCount
      additionalProperties: true
      example:
        success: true
        matchedCount: 1
    InboxDropValidationErrorResponse:
      type: object
      description: >-
        Validation error envelope returned when `emailData` fails the
        from/to/subject checks.
      properties:
        success:
          type: boolean
          enum:
            - false
        message:
          type: string
        errors:
          type: array
          items:
            type: string
          description: >-
            Per-field error strings (only populated when individual email fields
            failed validation).
      required:
        - success
        - message
      additionalProperties: true
      example:
        success: false
        message: Invalid email data
        errors:
          - emailData.from is required
          - emailData.subject is required
    WebhookErrorResponse:
      type: object
      description: >-
        Error envelope used across provider webhook routes. Most failures only
        carry `error`; a few (ElevenLabs tool errors, ingress validation) add
        `success:false`, `message`, or a `code`. Many of these endpoints respond
        200 with `success:false` for recoverable cases (especially the
        ElevenLabs server tools) — only hard failures use 4xx/5xx.
      properties:
        error:
          type: string
        message:
          type: string
        success:
          type: boolean
          enum:
            - false
        code:
          type: string
        details:
          description: Optional diagnostic detail (stack snippet, validation issues, etc.).
      additionalProperties: true
      example:
        error: Webhook processing failed
    InboxDropEmailData:
      type: object
      description: >-
        Parsed inbound email payload produced by a provider adapter (e.g.
        SendGrid Inbound Parse).
      properties:
        from:
          type: string
        to:
          description: >-
            Recipient(s). Single string is normalized to a one-element array
            server-side.
          oneOf:
            - type: string
            - type: array
              items:
                type: string
        subject:
          type: string
        body:
          type: string
          description: Plain text body.
        bodyHtml:
          type: string
        headers:
          type: object
          additionalProperties: true
        attachments:
          type: array
          items:
            type: object
            properties:
              filename:
                type: string
              url:
                type: string
                format: uri
            required:
              - filename
            additionalProperties: true
      required:
        - from
        - to
        - subject
      additionalProperties: true
      example:
        from: alex.nguyen@example.com
        to: inbound+org-64a1b@inbound.tetherai.ca
        subject: Maple Court availability
        body: Hi — could you confirm the corner unit is still listed for next month?
        bodyHtml: >-
          <p>Hi — could you confirm the corner unit is still listed for next
          month?</p>
        headers:
          Message-ID: <abc123@mail.example.com>
        attachments: []

````