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

# Create a WebSocket voice session

> Get a short-lived connection for a device that speaks the Pipecat WebSocket protocol.

For a server integration, supply an `agent_id` owned by the API key or OAuth account. A [paired Eigi board](https://docs.eigi.ai/eigi-gadgets/device-api.md) can instead present its device token and use its own agent without supplying an ID. A key-bound board must also send a fresh DPoP proof.

```bash theme={null}
curl 'https://api.eigi.ai/v1/public/websocket' \
  -H "X-API-Key: $EIGI_API_KEY" -H 'Content-Type: application/json' \
  -d '{"agent_id":"YOUR_AGENT_ID","client_tools":[]}'
```

Connect a Pipecat WebSocket client to the exact `ws_url` returned, including its query string. Send the returned `token` as a Bearer credential during the WebSocket handshake. It is single-use. Use `expires_in` (seconds) to decide whether to request a fresh session. The socket exchanges protobuf frames for audio and RTVI messages.

## Offer tools the device can run

Omit `client_tools` to offer the agent’s enabled client tools. Send `[]` to offer none, or send up to 32 names or definitions. A device-declared definition uses a name, description, and a JSON Schema object for its parameters. A definition with the same name as an agent client tool overrides it for this session.

```json theme={null}
{
  "agent_id": "YOUR_AGENT_ID",
  "client_tools": [{
    "name": "show_caption",
    "description": "Display a short caption on this device.",
    "parameters": {
      "type": "object",
      "properties": {"text": {"type": "string"}},
      "required": ["text"]
    }
  }]
}
```

Check `client_tools`, `declared_client_tools`, and `unknown_client_tools` in the response to see which handlers were registered. Keep secrets out of `conversation_metadata`. It is limited to 4 KB and travels in the connection URL.


## OpenAPI

````yaml api-reference/openapi.json POST /v1/public/websocket
openapi: 3.0.0
info:
  title: eigi.ai API
  description: REST API for managing AI voice agents and conversations
  version: 1.0.0
  contact:
    email: buddy@eigi.ai
    url: https://eigi.ai
servers:
  - url: https://api.eigi.ai
    description: Production server
security:
  - ApiKeyAuth: []
  - OAuthAccessToken: []
paths:
  /v1/public/websocket:
    post:
      tags:
        - Voice sessions
      summary: Create a WebSocket voice session
      description: >-
        Get a short-lived connection for a device that speaks the Pipecat
        WebSocket protocol.
      operationId: websocketSession
      parameters:
        - name: DPoP
          in: header
          required: false
          description: Fresh proof required for a key-bound board.
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WebSocketSessionRequest'
            example:
              agent_id: YOUR_AGENT_ID
              client_tools: []
      responses:
        '200':
          description: Successful request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebSocketSession'
        '400':
          description: Invalid session configuration.
        '401':
          description: Missing or invalid credentials.
        '403':
          description: Access to the agent was denied.
        '404':
          description: Agent not found.
      security:
        - ApiKeyAuth: []
        - OAuthAccessToken: []
        - BoardToken: []
components:
  schemas:
    WebSocketSessionRequest:
      type: object
      properties:
        agent_id:
          type: string
          description: >-
            Required for API key and OAuth callers. A paired board may omit it
            to use its own agent.
        conversation_metadata:
          type: object
          additionalProperties: true
          description: Dynamic variables, up to 4 KB. Included in the connection URL.
        is_test_call:
          type: boolean
          default: false
        client_tools:
          type: array
          description: >-
            Omit to offer all enabled client tools, or send an empty array to
            offer none.
          items:
            oneOf:
              - type: string
              - type: object
                required:
                  - name
                  - description
                  - parameters
                properties:
                  name:
                    type: string
                  description:
                    type: string
                  parameters:
                    type: object
                    additionalProperties: true
          maxItems: 32
        scheduled_notification:
          type: object
          required:
            - run_id
            - job_id
            - result
            - idle_timeout_seconds
          properties:
            run_id:
              type: string
              maxLength: 96
              pattern: ^[A-Za-z0-9_-]+$
            job_id:
              type: string
              maxLength: 64
              pattern: ^[A-Za-z0-9_-]+$
            result:
              type: string
              minLength: 1
              maxLength: 512
            task:
              type: string
              minLength: 1
              maxLength: 512
            idle_timeout_seconds:
              type: integer
              minimum: 3
              maximum: 30
          additionalProperties: false
        board_notes:
          type: string
          description: >-
            Notes from a paired board, up to 2 KiB. Ignored for API key and
            OAuth calls.
    WebSocketSession:
      type: object
      required:
        - conversation_id
        - ws_url
        - token
        - expires_in
      properties:
        id:
          type: string
        details:
          type: string
        conversation_id:
          type: string
        ws_url:
          type: string
        token:
          type: string
          description: Single-use credential for the socket.
        expires_in:
          type: integer
          description: Token lifetime in seconds.
        client_tools:
          type: array
          items:
            type: string
        declared_client_tools:
          type: array
          items:
            type: string
        unknown_client_tools:
          type: array
          items:
            type: string
        scheduled_notification:
          type: object
          properties:
            job_id:
              type: string
            run_id:
              type: string
          nullable: true
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: Studio API key for server-side requests.
    OAuthAccessToken:
      type: http
      scheme: bearer
      description: OAuth access token issued to an authorized Eigi integration.
    BoardToken:
      type: http
      scheme: bearer
      description: >-
        Paired board credential. Key-bound boards must also send a fresh DPoP
        proof.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.