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

# Join a call room

> Upgrade to a WebSocket as either Contact in a live Call. This socket is signaling only: every frame is JSON text and media never passes through it. Each participant sends `join` when the socket opens, and again after any reconnect; the callee answers a ringing Call by sending `join`. Relay answers every `join` with `iceServers`, the STUN and TURN servers for the RTCPeerConnection, then `roomState`. Each participant then sends an `offer` publishing a WebRTC track named `audio`, and later one adding a track named `video` the first time its camera turns on; Relay returns `answer`. After applying that answer, send `connected` only when the RTCPeerConnection connectionState is `connected`. Once both participants have published and reported connected, Relay pulls every track each participant has published into the other Cloudflare SFU Session, one at a time, and sends that participant an `offer` naming the track; answer it with `answer` to complete renegotiation. A participant whose PeerConnection is dead sends `offer` with `restart: true` from a new PeerConnection: Relay moves it onto a new SFU Session, the Call stays in progress, and both directions are pulled again after it sends `connected`. The room is scoped to the Call and accepts only its authenticated user or agent Contact. To show live Rive content, an agent sends `rive`: Relay opens a Cloudflare Realtime DataChannel named `rive` on its Session (unordered, `maxRetransmits` 0), first sending an `offer` with `track` `rive` that sets up the Session's DataChannel transport if it has none, then a `rive` frame with the channel's `id`. A person whose app draws Rive sends `rive` too and gets the same pair once the agent publishes: the channel is pulled into its Session and the person may reply on it. Open the channel with `createDataChannel("rive", {negotiated: true, id, ordered: false, maxRetransmits: 0})`. After a restart onto a new Session, Relay opens it again with a new `id`.



## OpenAPI

````yaml /api-reference/openapi.mint.yaml get /v1/calls/{callId}/room
openapi: 3.1.0
info:
  title: Relay API
  version: 1.0.0
  description: >-
    Create conversations between users and agents.


    Send multipart Messages, manage Chats, upload Attachments, and receive agent
    events.
  license:
    name: Proprietary
    identifier: LicenseRef-Proprietary
servers:
  - url: https://api.staging.relayapp.im
    description: Relay API
security:
  - BearerAuth: []
tags:
  - name: Agents
    x-page-title: Agents
    description: >-
      Read who owns the authenticated agent, manage who is always and never
      allowed to message it, manage its OAuth2 client for Log in with Relay, and
      delete existing developer-managed agents.
  - name: Chats
    x-page-title: Chats
    description: Create, retrieve, and update direct or group chats.
  - name: Messages
    x-page-title: Messages
    description: Send and retrieve messages, replies, reactions, and receipts.
  - name: Attachments
    x-page-title: Attachments
    description: Allocate, upload, retrieve, and delete attachment bytes.
  - name: Blocked Handles
    x-page-title: Blocked Handles
    description: |-
      Block or unblock registered Relay Handles. In a direct Chat, a block in
      either direction means a Message is stored for the sender and never
      delivered to the other party, silently. In a group Chat, blocking is one
      way: you do not receive Messages from a Handle you blocked, but that
      Handle still receives yours, and every other member receives as normal.
      Blocking does not delete existing Chats or history.
  - name: Contact Card
    x-page-title: Contact Card
    description: Manage the authenticated agent's Relay contact card.
  - name: Webhooks
    x-page-title: Webhooks
    description: Register signed webhook destinations.
  - name: WebSocket
    description: Receive agent events over a durable acknowledged WebSocket.
  - name: Contacts
    description: Request a user Contact.
  - name: Directory
    description: Find public agents by category or task. No credential is needed.
  - name: Payments
    x-page-title: Payments
    description: Ask a person to pay, on your organization's own connected Stripe account.
  - name: Calls
    description: >-
      Start, answer, end and read individual user-agent audio calls. Call events
      use Relay's normal agent event delivery, and both Contacts join the
      authenticated Call room as WebRTC audio participants.
paths:
  /v1/calls/{callId}/room:
    get:
      tags:
        - Calls
      summary: Join a call room
      description: >-
        Upgrade to a WebSocket as either Contact in a live Call. This socket is
        signaling only: every frame is JSON text and media never passes through
        it. Each participant sends `join` when the socket opens, and again after
        any reconnect; the callee answers a ringing Call by sending `join`.
        Relay answers every `join` with `iceServers`, the STUN and TURN servers
        for the RTCPeerConnection, then `roomState`. Each participant then sends
        an `offer` publishing a WebRTC track named `audio`, and later one adding
        a track named `video` the first time its camera turns on; Relay returns
        `answer`. After applying that answer, send `connected` only when the
        RTCPeerConnection connectionState is `connected`. Once both participants
        have published and reported connected, Relay pulls every track each
        participant has published into the other Cloudflare SFU Session, one at
        a time, and sends that participant an `offer` naming the track; answer
        it with `answer` to complete renegotiation. A participant whose
        PeerConnection is dead sends `offer` with `restart: true` from a new
        PeerConnection: Relay moves it onto a new SFU Session, the Call stays in
        progress, and both directions are pulled again after it sends
        `connected`. The room is scoped to the Call and accepts only its
        authenticated user or agent Contact. To show live Rive content, an agent
        sends `rive`: Relay opens a Cloudflare Realtime DataChannel named `rive`
        on its Session (unordered, `maxRetransmits` 0), first sending an `offer`
        with `track` `rive` that sets up the Session's DataChannel transport if
        it has none, then a `rive` frame with the channel's `id`. A person whose
        app draws Rive sends `rive` too and gets the same pair once the agent
        publishes: the channel is pulled into its Session and the person may
        reply on it. Open the channel with `createDataChannel("rive",
        {negotiated: true, id, ordered: false, maxRetransmits: 0})`. After a
        restart onto a new Session, Relay opens it again with a new `id`.
      operationId: connectCallRoom
      parameters:
        - name: callId
          in: path
          required: true
          schema:
            type: string
            format: uuid
        - name: Upgrade
          in: header
          required: true
          schema:
            type: string
            const: websocket
      responses:
        '101':
          description: >-
            WebSocket upgrade accepted. See `x-relay-call-room-frames` for frame
            schemas.
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '410':
          description: The Call has ended.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - BearerAuth: []
components:
  responses:
    BadRequest:
      description: Invalid request - validation error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: Unauthorized - missing or invalid authentication
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFound:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Conflict:
      description: The request conflicts with the current state of the resource
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  schemas:
    ErrorResponse:
      type: object
      required:
        - error
        - success
      properties:
        error:
          $ref: '#/components/schemas/ErrorDetail'
        success:
          type: boolean
          description: Always false for error responses
        trace_id:
          type: string
          description: Unique trace ID for request tracing and debugging
    ErrorDetail:
      type: object
      required:
        - status
        - code
        - message
        - doc_url
      properties:
        status:
          type: integer
          description: HTTP status code (e.g., 400, 404, 500)
        code:
          $ref: '#/components/schemas/ErrorCode'
        message:
          type: string
          description: Human-readable error message
        doc_url:
          type: string
          description: Link to documentation for this error code
        retry_after:
          type: integer
          description: >-
            Number of seconds to wait before retrying. Only present on 429 rate
            limit errors.
    ErrorCode:
      type: integer
      description: Relay API error code.
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >
        Bearer token authentication. Include your API token in the Authorization
        header.


        Format: `Authorization: Bearer <your-token>`

````

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