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

# Discover SDK WebSocket connection

> Returns the current SDK WebSocket connection state for a simulation.
A READY response includes a short-lived, one-use token and a WSS URL.
Poll until READY or a terminal status. The token is never returned after
a successful connection, and responses must not be cached.




## OpenAPI

````yaml /api-reference/v1/simulations-v1.yaml get /simulations/{simulation_id}/connect
openapi: 3.0.3
info:
  title: Coval Simulated Conversations API
  version: 1.0.0
  description: |

    Launch and manage voice simulations for AI agent testing.
  contact:
    name: Coval API Support
    email: support@coval.dev
    url: https://docs.coval.ai
  license:
    name: Proprietary
    url: https://coval.dev/terms
servers:
  - url: https://api.coval.dev/v1
    description: Production API
security:
  - ApiKeyAuth: []
tags:
  - name: Simulated Conversations
    description: Launch and manage individual simulation executions
  - name: Metric Outputs
    description: Retrieve metric computation results for simulations
paths:
  /simulations/{simulation_id}/connect:
    get:
      tags:
        - Simulated Conversations
      summary: Discover SDK WebSocket connection
      description: |
        Returns the current SDK WebSocket connection state for a simulation.
        A READY response includes a short-lived, one-use token and a WSS URL.
        Poll until READY or a terminal status. The token is never returned after
        a successful connection, and responses must not be cached.
      operationId: getSimulationConnect
      parameters:
        - name: simulation_id
          in: path
          required: true
          schema:
            type: string
          description: The simulation execution ID.
      responses:
        '200':
          description: Current connection state. Cache-Control is no-store.
          headers:
            Cache-Control:
              schema:
                type: string
                enum:
                  - no-store
          content:
            application/json:
              schema:
                type: object
                required:
                  - status
                  - simulation_id
                properties:
                  status:
                    type: string
                    enum:
                      - PENDING
                      - READY
                      - CONNECTED
                      - CLOSED
                      - FAILED
                      - CANCELLED
                      - EXPIRED
                  simulation_id:
                    type: string
                  attempt_id:
                    type: string
                    nullable: true
                    description: Null until an attempt starts.
                  wss_url:
                    type: string
                    nullable: true
                    description: Null except when status is READY.
                  token:
                    type: string
                    nullable: true
                    description: Null except when status is READY.
                  expires_at:
                    type: integer
                    nullable: true
                    description: Unix epoch seconds; null except when status is READY.
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: Connection state changed while a token was issued; retry discovery.
        '500':
          $ref: '#/components/responses/InternalError'
      security:
        - ApiKeyAuth: []
components:
  responses:
    Unauthorized:
      description: Missing or invalid API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: UNAUTHENTICATED
              message: Missing API Key
              details:
                - field: X-API-Key
                  description: X-API-Key header is required
    Forbidden:
      description: Insufficient permissions
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: PERMISSION_DENIED
              message: Insufficient permissions
              details:
                - field: permissions
                  description: API key does not include required scope
    NotFound:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: NOT_FOUND
              message: Agent not found
              details:
                - field: agent_id
                  description: Agent 'gk3jK9mPq2xRt5vW8yZaBc' does not exist
    InternalError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: INTERNAL
              message: Internal server error
              details:
                - description: An unexpected error occurred. Please contact support.
  schemas:
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          $ref: '#/components/schemas/ErrorInfo'
    ErrorInfo:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          enum:
            - INVALID_ARGUMENT
            - UNAUTHENTICATED
            - PERMISSION_DENIED
            - NOT_FOUND
            - FAILED_PRECONDITION
            - RESOURCE_EXHAUSTED
            - INTERNAL
          description: Machine-readable error code
          example: INVALID_ARGUMENT
        message:
          type: string
          description: Human-readable error message
          example: Request validation failed
        details:
          type: array
          items:
            $ref: '#/components/schemas/ErrorDetail'
          description: Detailed information about specific error fields
    ErrorDetail:
      type: object
      required:
        - description
      properties:
        field:
          type: string
          description: The field that caused the error (if applicable)
          example: agent_id
        description:
          type: string
          description: Human-readable description of the error
          example: Agent not found or not accessible by your organization
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: |
        API key for authentication.

````

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