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

# Handle inbound webchat message

> Inbound webhook called by the embedded webchat widget when a visitor sends a message. Validates the configured webchatConfigId, upserts the visitor as a contact, persists the message + any attachments, and emits a socket event so connected agents can respond.



## OpenAPI

````yaml /api-reference/openapi.yaml post /api/webhook/webchat
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/webchat:
    post:
      tags:
        - Webhooks
      summary: Handle inbound webchat message
      description: >-
        Inbound webhook called by the embedded webchat widget when a visitor
        sends a message. Validates the configured webchatConfigId, upserts the
        visitor as a contact, persists the message + any attachments, and emits
        a socket event so connected agents can respond.
      operationId: post_webhook_webchat
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WebchatWebhookRequest'
      responses:
        '200':
          description: Message accepted (processed asynchronously)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebchatWebhookAckResponse'
        '400':
          description: Missing required fields
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookErrorResponse'
        '500':
          description: Webhook processing failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookErrorResponse'
components:
  schemas:
    WebchatWebhookRequest:
      type: object
      properties:
        webchatId:
          type: string
          description: Per-conversation widget session identifier generated client-side.
        webchatConfigId:
          type: string
          description: >-
            WebchatConfig `_id` that identifies which embedded widget sent the
            message.
        message:
          type: string
          description: Visitor message body.
        deviceId:
          type: string
          description: >-
            Stable per-browser device identifier used to deduplicate visitors
            across sessions.
        visitorName:
          type: string
          description: Optional visitor display name captured by the widget pre-chat form.
        visitorEmail:
          type: string
          description: Optional visitor email captured by the widget pre-chat form.
        visitorPhone:
          type: string
          description: Optional visitor phone number captured by the widget pre-chat form.
        metadata:
          type: object
          additionalProperties: true
          description: >-
            Free-form context the widget attaches (referrer, page URL, UTM
            params, etc.).
      required:
        - webchatId
        - webchatConfigId
        - message
      additionalProperties: true
      example:
        webchatId: wc_8f3d1b9c-2e7a-4f0b-9a4d-2c1e6e2f8c01
        webchatConfigId: 5f7b1c2e8a1d4e0012c3b4a5
        message: Hi, do you ship to Canada?
        deviceId: dev_4f9a-8c1b-2e3d-7a01
        visitorName: Alex Morgan
        visitorEmail: alex@example.com
        visitorPhone: '+14165550100'
        metadata:
          page: /pricing
          referrer: https://google.com
    WebchatWebhookAckResponse:
      type: object
      description: >-
        Ack returned to the embedded webchat widget after queuing an inbound
        message for async processing.
      properties:
        message:
          type: string
      required:
        - message
      additionalProperties: true
      example:
        message: Webchat webhook received
    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

````