> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes. # stream > Stream call audio to a WebSocket endpoint via REST. Start streaming audio from an active call to a WebSocket endpoint. This is commonly used for real-time speech processing, analytics, or archival. `control_id` is a caller-chosen identifier for this operation, unique per active operation of this kind on the call. The TypeScript SDK types it as optional, but the API requires it — a request that omits it is rejected. Keep it to stop the stream later. ## **Request** ### Schema (`Calling.CallStreamRequest`) ```yaml components: schemas: uuid: type: string format: uuid description: Universal Unique Identifier. title: uuid CallingCallStreamRequestCommand: type: string enum: - calling.stream description: >- The `calling.stream` command starts streaming call audio to a WebSocket endpoint. title: CallingCallStreamRequestCommand Calling.StreamTrack: type: string enum: - inbound_track - outbound_track - both_tracks description: The audio track to stream. title: Calling.StreamTrack CallingCallStreamRequestParamsCustomParameters: type: object properties: {} description: >- Arbitrary JSON object passed through to the WebSocket endpoint as connection metadata. title: CallingCallStreamRequestParamsCustomParameters Calling.StreamStatusUrlMethod: type: string enum: - GET - POST description: HTTP method used when invoking the `status_url` webhook. title: Calling.StreamStatusUrlMethod CallingCallStreamRequestParams: type: object properties: control_id: type: string description: >- Unique identifier for this stream operation, used to control it later. Must be unique per active stream on this call. url: type: string format: uri description: >- WebSocket URL to stream audio to. Must start with `wss://` (TLS is required; plain `ws://` is rejected). name: type: string description: Optional human-readable name to identify the stream at the endpoint. codec: type: string description: >- Audio codec to request. Freeform; endpoint-specific. Common values include `PCMU`, `PCMA`, `OPUS`. track: $ref: '#/components/schemas/Calling.StreamTrack' default: inbound_track description: The audio track to stream. authorization_bearer_token: type: string description: >- Bearer token included as `Authorization: Bearer ` when establishing the WebSocket connection. custom_parameters: $ref: '#/components/schemas/CallingCallStreamRequestParamsCustomParameters' description: >- Arbitrary JSON object passed through to the WebSocket endpoint as connection metadata. status_url: type: string format: uri description: HTTP or HTTPS URL that receives stream lifecycle webhooks. status_url_method: $ref: '#/components/schemas/Calling.StreamStatusUrlMethod' default: POST description: HTTP method used for the `status_url` webhook. required: - control_id - url description: An object of parameters that will be utilized by the active command. title: CallingCallStreamRequestParams Calling.CallStreamRequest: type: object properties: id: $ref: '#/components/schemas/uuid' description: The unique identifying ID of an existing call. command: $ref: '#/components/schemas/CallingCallStreamRequestCommand' description: >- The `calling.stream` command starts streaming call audio to a WebSocket endpoint. params: $ref: '#/components/schemas/CallingCallStreamRequestParams' description: An object of parameters that will be utilized by the active command. required: - id - command - params title: Calling.CallStreamRequest ``` ## **Response** ### Schema (`Calling.CallResponse`) ```yaml components: schemas: uuid: type: string format: uuid description: Universal Unique Identifier. title: uuid Calling.CallDirection: type: string enum: - inbound - outbound - outbound-api description: The direction of the call. title: Calling.CallDirection CallingCallLegSource: type: string enum: - realtime_api description: Source of this call. title: CallingCallLegSource Calling.ChargeDetails: type: object properties: description: type: string description: Description for this charge. charge: type: number format: double description: Charged amount. required: - description - charge description: One itemized charge applied to the call. title: Calling.ChargeDetails Calling.CallResponseStatus: type: string enum: - queued - initiated - created - ringing - answered - ending - ended - failed - canceled - completed description: The status of the call throughout its lifecycle. title: Calling.CallResponseStatus CallingCallLegType0: type: string enum: - relay_pstn_call title: CallingCallLegType0 CallingCallLegType1: type: string enum: - relay_sip_call title: CallingCallLegType1 CallingCallLegType2: type: string enum: - relay_webrtc_call title: CallingCallLegType2 CallingCallLegType: oneOf: - $ref: '#/components/schemas/CallingCallLegType0' - $ref: '#/components/schemas/CallingCallLegType1' - $ref: '#/components/schemas/CallingCallLegType2' description: Type of this call. title: CallingCallLegType Calling.CallLeg: type: object properties: id: $ref: '#/components/schemas/uuid' description: >- The unique identifier of the call on SignalWire. This can be used to update the call programmatically. from: type: string description: The origin number or address. to: type: string description: The destination number or address. direction: $ref: '#/components/schemas/Calling.CallDirection' description: The direction of the call. source: $ref: '#/components/schemas/CallingCallLegSource' description: Source of this call. url: type: - string - 'null' description: The URL associated with this call. charge: type: number format: double description: Total charge for this call. created_at: type: string format: date-time description: The date and time when the call was created. charge_details: type: array items: $ref: '#/components/schemas/Calling.ChargeDetails' description: Details on charges associated with this call. status: oneOf: - $ref: '#/components/schemas/Calling.CallResponseStatus' - type: 'null' description: The status of the call. duration: type: - integer - 'null' description: The duration of the call in seconds. duration_ms: type: - integer - 'null' description: The duration of the call in milliseconds. billing_ms: type: - integer - 'null' description: The billable duration of the call in milliseconds. type: $ref: '#/components/schemas/CallingCallLegType' description: Type of this call. parent_id: oneOf: - $ref: '#/components/schemas/uuid' - type: 'null' description: The parent call ID if this is a child call. required: - id - from - to - direction - source - url - charge - created_at - charge_details - status - duration - duration_ms - billing_ms - type - parent_id description: Returned when the call is a standard PSTN, SIP, or WebRTC call. title: Calling.CallLeg CallingFabricDeviceLegSource: type: string enum: - realtime_api description: Source of this call. title: CallingFabricDeviceLegSource CallingFabricDeviceLegType: type: string enum: - fabric_subscriber_device_leg description: Type of this call. title: CallingFabricDeviceLegType Calling.FabricDeviceLeg: type: object properties: id: $ref: '#/components/schemas/uuid' description: >- The unique identifier of the call on SignalWire. This can be used to update the call programmatically. from: type: string description: The origin number or address. to: type: string description: The destination number or address. direction: $ref: '#/components/schemas/Calling.CallDirection' description: The direction of the call. source: $ref: '#/components/schemas/CallingFabricDeviceLegSource' description: Source of this call. url: type: - string - 'null' description: The URL associated with this call. charge: type: number format: double description: Total charge for this call. created_at: type: string format: date-time description: The date and time when the call was created. charge_details: type: array items: $ref: '#/components/schemas/Calling.ChargeDetails' description: Details on charges associated with this call. status: description: >- The status of the call. Always null for Fabric subscriber device legs. type: $ref: '#/components/schemas/CallingFabricDeviceLegType' description: Type of this call. required: - id - from - to - direction - source - url - charge - created_at - charge_details - status - type description: >- Returned when the call is a Fabric subscriber device leg. The `status` field is always null for this type. title: Calling.FabricDeviceLeg Calling.CallResponse: oneOf: - $ref: '#/components/schemas/Calling.CallLeg' - $ref: '#/components/schemas/Calling.FabricDeviceLeg' title: Calling.CallResponse ``` ## **Example** ```typescript {9-12} import { RestClient } from "@signalwire/sdk"; const client = new RestClient({ project: "your-project-id", token: "your-api-token", host: "your-space.signalwire.com" }); const controlId = "audio-stream-1"; await client.calling.stream("call-id-xxx", "wss://example.com/audio-stream", { control_id: controlId, }); ``` > Stream call audio to a WebSocket endpoint via REST.