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

# Create webchat configuration

> Create a new webchat widget configuration. `allowedDomains` restricts the embed origins; `promptId` selects which Prompt the agent uses for AI responses on inbound visitor messages.



## OpenAPI

````yaml /api-reference/openapi.yaml post /api/webchats
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/webchats:
    post:
      tags:
        - Webchats
      summary: Create webchat configuration
      description: >-
        Create a new webchat widget configuration. `allowedDomains` restricts
        the embed origins; `promptId` selects which Prompt the agent uses for AI
        responses on inbound visitor messages.
      operationId: post_webchats
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateWebchatRequest'
      responses:
        '201':
          description: Webchat configuration created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebchatMutationResponse'
        '400':
          description: Missing required fields
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebchatErrorResponse'
        '500':
          description: Failed to create webchat configuration
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebchatErrorResponse'
      security:
        - bearerAuth: []
components:
  schemas:
    CreateWebchatRequest:
      type: object
      properties:
        name:
          type: string
          description: Display name for the webchat configuration in the admin UI.
        description:
          type: string
          description: Free-form notes describing this widget configuration.
        starterMessage:
          type: string
          description: Greeting bubble shown to the visitor before they send a message.
        backgroundColor:
          type: string
          description: Hex color for the widget chat panel background.
        primaryColor:
          type: string
          description: Hex color for the widget primary accent (header/buttons).
        secondaryColor:
          type: string
          description: Hex color for the widget secondary accent (outbound bubbles).
        icon:
          type: string
          description: Storage key or signed URL for the widget icon.
        headerTextColor:
          type: string
          description: Hex color for text inside the widget header.
        statusText:
          type: string
          description: >-
            Status line shown under the title (e.g. `We typically reply in
            minutes`).
        statusTextColor:
          type: string
          description: Hex color for the status text.
        timestampColor:
          type: string
          description: Hex color for message timestamps.
        csatBackgroundColor:
          type: string
          description: Hex color for the CSAT survey panel background.
        csatTextColor:
          type: string
          description: Hex color for CSAT survey text.
        csatThankYouMessage:
          type: string
          description: Message shown after the visitor submits a CSAT response.
        promptId:
          type: string
          description: AI prompt `_id` driving the agent for this widget.
        allowedDomains:
          type: array
          items:
            type: string
          description: >-
            Hostnames permitted to embed this widget. Empty array disables host
            check.
        pipelineId:
          type: string
          description: Pipeline `_id` new webchat contacts are placed into.
        pipelineStage:
          type: string
          description: Pipeline stage new webchat contacts are placed into.
        initialStage:
          type: string
          description: Pipeline stage new webchat contacts enter.
        isAutopilot:
          type: boolean
          description: When true, the AI replies autonomously without rep approval.
        isEnabled:
          type: boolean
          description: When true, the widget is active and accepts new sessions.
      required:
        - name
        - backgroundColor
        - primaryColor
        - secondaryColor
        - promptId
        - allowedDomains
        - initialStage
      additionalProperties: true
      example:
        name: Marketing site widget
        description: Bottom-right widget on the marketing site
        starterMessage: Hi! Looking for pricing?
        backgroundColor: '#FFFFFF'
        primaryColor: '#1F2937'
        secondaryColor: '#3B82F6'
        headerTextColor: '#FFFFFF'
        statusText: We typically reply within minutes
        statusTextColor: '#6B7280'
        timestampColor: '#9CA3AF'
        csatBackgroundColor: '#F3F4F6'
        csatTextColor: '#111827'
        csatThankYouMessage: Thanks for your feedback!
        promptId: 65b2a1c3d4e5f6a7b8c9d0e1
        allowedDomains:
          - https://example.com
        pipelineId: 66f0a0b0c0d0e0f0a0b0c0d0
        pipelineStage: 67f0a0b0c0d0e0f0a0b0c0d0
        initialStage: new
        isAutopilot: true
        isEnabled: true
    WebchatMutationResponse:
      type: object
      description: Response from `POST /api/webchats` and `PUT /api/webchats/{id}`.
      properties:
        message:
          type: string
        data:
          $ref: '#/components/schemas/WebchatDto'
      required:
        - data
      additionalProperties: true
      example:
        message: Webchat configuration created
        data:
          _id: 67d3a0b0c0d0e0f0a0b0c0d0
          name: Marketing site widget
          isEnabled: true
    WebchatErrorResponse:
      type: object
      description: Error envelope returned by webchat endpoints.
      properties:
        error:
          type: string
        details:
          type: string
      required:
        - error
      additionalProperties: true
      example:
        error: Webchat configuration not found
        details: NOT_FOUND
    WebchatDto:
      type: object
      description: >-
        Stored webchat configuration document. The `icon` field, when present,
        is a freshly-signed URL pointing at the R2-hosted asset (the database
        stores the storage key).
      properties:
        _id:
          type: string
        organizationId:
          type: string
        userId:
          type: string
          description: >-
            Contact owner. Inbound contacts created from this webchat are routed
            to this user.
        createdBy:
          type: string
        name:
          type: string
        description:
          type: string
        starterMessage:
          type: string
        backgroundColor:
          type: string
        primaryColor:
          type: string
        secondaryColor:
          type: string
        icon:
          type: string
          nullable: true
          description: Signed R2 URL for the icon image. `null` when no icon is configured.
        headerTextColor:
          type: string
        statusText:
          type: string
        statusTextColor:
          type: string
        timestampColor:
          type: string
        csatBackgroundColor:
          type: string
        csatTextColor:
          type: string
        csatThankYouMessage:
          type: string
        promptId:
          type: string
        allowedDomains:
          type: array
          items:
            type: string
        pipelineId:
          type: string
          nullable: true
        pipelineStage:
          type: string
          nullable: true
        initialStage:
          type: string
        isAutopilot:
          type: boolean
        isEnabled:
          type: boolean
        position:
          type: string
        offsetX:
          type: number
        offsetY:
          type: number
        zIndex:
          type: number
        initialState:
          type: string
        autoOpenDelay:
          type: number
        autoOpenOnScroll:
          type: number
        mobileBreakpoint:
          type: number
        allowedPages:
          type: array
          items:
            type: string
        headless:
          type: boolean
        pageContext:
          type: boolean
        pageContextPrompt:
          type: string
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
      additionalProperties: true
      example:
        _id: 67d3a0b0c0d0e0f0a0b0c0d0
        organizationId: 65a0e0e0e0e0e0e0e0e0e0e0
        userId: 65b1f0a2c3d4e5f6a7b8c9d0
        createdBy: 65b1f0a2c3d4e5f6a7b8c9d0
        name: Marketing site widget
        description: Bottom-right widget on the marketing site
        starterMessage: Hi! Looking for pricing?
        backgroundColor: '#FFFFFF'
        primaryColor: '#1F2937'
        secondaryColor: '#3B82F6'
        icon: https://r2.example.com/orgs/65a0.../webchat/icon.png?token=...
        promptId: 65b2a1c3d4e5f6a7b8c9d0e1
        allowedDomains:
          - https://example.com
        pipelineId: 66f0a0b0c0d0e0f0a0b0c0d0
        initialStage: new
        isAutopilot: true
        isEnabled: true
        position: bottom-right
        offsetX: 24
        offsetY: 24
        zIndex: 9999
        createdAt: '2026-03-12T10:00:00.000Z'
        updatedAt: '2026-05-18T14:00:00.000Z'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````