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

# WebSocket endpoint for web calls

> Establishes a WebSocket connection for real-time web-based calls. This is not a traditional HTTP endpoint - it upgrades to WebSocket protocol.

## Connection Types

**Chat** (`chat`):

* Text-based conversations without voice
* No WebRTC required
* Lower bandwidth usage
* Use cases: customer support chat, FAQ bots

**Web Call** (`webCall`):

* Browser-based voice calls using WebRTC
* Real-time audio streaming
* Requires HTTPS and microphone access
* Use cases: voice customer support, interactive demos

**Phone Call** (`onPhone`):

* Traditional phone calls via SIP
* External phone number required
* Works with landlines/mobile devices
* Use cases: outbound campaigns, call centers

## Message Format

All messages use JSON structure:

```json
{
  "type": "message_type",
  "timestamp": "2024-01-01T00:00:00.000Z",
  "data": {},
  "content": {}
}
```

## Client → Server Messages

* **initialize**: Start new conversation with call type
* **incomingChatMessage**: Send text message
* **sdpAnswer**: Respond to WebRTC SDP offer
* **websocketToolResponse**: Return tool execution result
* **terminate**: End conversation

## Server → Client Messages

* **event**: System events (connection, opened, closed)
* **text**: Text messages from agent or user
* **sdpInvite**: WebRTC SDP offer for voice calls
* **toolCall**: Agent requesting tool execution
* **conversationResult**: Final conversation summary
* **error**: Error messages

## Connection Flow

1. **Establish connection** to WebSocket endpoint
2. **Send initialize** message with call type and configuration
3. **Receive connection event** when agent is ready
4. **Exchange messages** bidirectionally
5. **Send terminate** to end session gracefully


## OpenAPI

````yaml https://blackbox.dasha.ai/swagger/v1/swagger.json get /api/v1/ws/webCall
openapi: 3.0.4
info:
  title: Dasha BlackBox Agent API
  description: API for managing AI agents and calls
  contact:
    name: DashaAI Team
    email: support@dasha.ai
  version: v1
servers:
  - url: https://blackbox.dasha.ai
    description: Dasha BlackBox Agent API
security:
  - ApiKey: []
  - OAuth: []
tags:
  - name: ActivityLogs
  - name: Agents
  - name: AgentTestCases
  - name: CallResults
  - name: Calls
  - name: Chats
  - name: Copilot
  - name: CustomerData
  - name: Mcp
  - name: Media
  - name: Misc
  - name: PronunciationDictionaries
  - name: Providers
  - name: SipAliases
  - name: SipCredentials
  - name: SipPhoneNumbers
  - name: TextChat
  - name: TwilioProvider
  - name: Voice
  - name: WebhookTest
  - name: WebIntegrations
  - name: WebSocket
    description: WebSocket endpoints for real-time communication
paths:
  /api/v1/ws/webCall:
    get:
      tags:
        - WebSocket
      summary: WebSocket endpoint for web calls
      description: >-
        Establishes a WebSocket connection for real-time web-based calls. This
        is not a traditional HTTP endpoint - it upgrades to WebSocket protocol.
      parameters:
        - name: token
          in: query
          description: Web integration token for authentication
          required: true
          schema:
            type: string
        - name: authorization
          in: query
          description: >-
            Bearer token for user authentication (alternative to Authorization
            header)
          schema:
            type: string
      responses:
        '101':
          description: Switching Protocols - WebSocket connection established
        '400':
          description: Bad Request - Not a WebSocket request or missing parameters
        '401':
          description: Unauthorized - Invalid authentication credentials
        '403':
          description: Forbidden - Invalid web integration token
        '500':
          description: Internal Server Error
components:
  securitySchemes:
    ApiKey:
      type: http
      description: API Key Authentication (Bearer {key})
      scheme: Bearer
    OAuth:
      type: oauth2
      flows:
        implicit:
          authorizationUrl: https://auth.dasha.ai/connect/authorize
          scopes:
            platform_api: Platform API

````