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

# Generate session token

> Get credentials to start a voice or chat session with an agent. Specify `agent_id` and optionally the agent version, transport (`websocket` or `webrtc`), opening message, prompt, chat access, and custom variables.



## OpenAPI

````yaml post /v1/session-token
openapi: 3.0.3
info:
  title: Vatel AI REST API
  description: >-
    Programmatic access for agents, telephony, and session tokens. Send
    `Authorization: Bearer <organization API key>` on all requests unless noted.
    Most error responses return JSON with an `error` string message.
  version: 0.2.4
servers:
  - url: https://api.vatel.ai
    description: Production
security:
  - bearerAuth: []
tags:
  - name: organization
    description: Organization tied to your API key
  - name: llms
    description: LLM model identifiers
  - name: voices
    description: TTS voice catalog
  - name: agents
    description: Agents, outbound dial, agent versions
  - name: twilio
    description: Imported Twilio phone numbers
  - name: sip-trunks
    description: SIP trunk configuration
  - name: session
    description: Session tokens and voice WebSocket connections.
  - name: calls
    description: Call history, recordings, and live eavesdrop for your organization
  - name: eavesdrop
    description: Listen to live calls and send supervisor commands over WebSocket.
paths:
  /v1/session-token:
    post:
      tags:
        - session
      summary: Generate session token
      description: >-
        Get credentials to start a voice or chat session with an agent. Specify
        `agent_id` and optionally the agent version, transport (`websocket` or
        `webrtc`), opening message, prompt, chat access, and custom variables.
      operationId: generateSessionToken
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GenerateSessionTokenRequest'
      responses:
        '200':
          description: Session credentials.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SessionTokenResponse'
        '400':
          description: >-
            Invalid JSON, disallowed extra properties, missing or invalid
            `agent_id`, invalid `version_id`, or invalid `transport`.
        '401':
          description: Unauthorized
        '403':
          description: Agent belongs to another organization
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Agent not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          description: >-
            `webrtc` was requested but WebRTC media credentials or endpoint are
            not configured on the server.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    GenerateSessionTokenRequest:
      type: object
      additionalProperties: false
      required:
        - agent_id
      properties:
        agent_id:
          type: string
          format: uuid
          description: UUID of the agent that will run this voice session.
        version_id:
          type: string
          format: uuid
          description: >-
            Agent version to use. If omitted, the active published version is
            used.
        chat_id:
          type: string
          format: uuid
          description: Existing chat to continue in this session.
        transport:
          type: string
          enum:
            - websocket
            - webrtc
          description: >-
            `websocket` for voice over the platform WebSocket API (default).
            `webrtc` for WebRTC; the response includes room connection details.
        first_message:
          type: string
          description: Opening line the agent uses for this session.
        prompt:
          type: string
          description: System instructions for the agent for this session.
        chat:
          type: boolean
          description: Also allow access to the chat API for this session.
        variables:
          type: array
          description: Custom key-value data available to the agent in this session.
          items:
            $ref: '#/components/schemas/SessionTokenVariable'
    SessionTokenResponse:
      type: object
      description: Connection credentials for the session.
      required:
        - token
      properties:
        token:
          type: string
          description: >-
            Credential for voice WebSocket, WebRTC setup, or chat API as
            applicable.
        room:
          type: string
          description: Room name for WebRTC. Returned when transport is `webrtc`.
        identity:
          type: string
          description: Your participant id for WebRTC. Returned when transport is `webrtc`.
        url:
          type: string
          description: Media server URL for WebRTC. Returned when transport is `webrtc`.
        webrtc_token:
          type: string
          description: >-
            Credential to join the WebRTC media room. Returned when transport is
            `webrtc`.
    ErrorResponse:
      type: object
      description: Standard error body for most non-2xx JSON responses on this API.
      required:
        - error
      properties:
        error:
          type: string
          description: Human-readable message; may include validation detail.
    SessionTokenVariable:
      type: object
      additionalProperties: false
      required:
        - key
        - value
      properties:
        key:
          type: string
          description: Variable name.
        value:
          description: Variable value (string, boolean, or number).
          oneOf:
            - type: string
            - type: boolean
            - type: number
        dataType:
          type: string
          enum:
            - string
            - number
            - boolean
          readOnly: true
          description: >-
            Value type (`string`, `number`, or `boolean`). Returned in
            responses; omit when sending variables.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: 'Send your organization API key as `Authorization: Bearer <key>`.'

````