> 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. [streamaction]: /docs/server-sdks/reference/typescript/relay/actions [calling-call-stream]: /docs/server-sdks/reference/typescript/relay/call#events [call-events]: /docs/server-sdks/reference/typescript/relay/call#events Start streaming call audio to a WebSocket endpoint. Returns a [`StreamAction`][streamaction] that you can use to stop the stream or wait for it to finish. > **Info** > > This method emits [`calling.call.stream`][calling-call-stream] events. See [Call Events][call-events] for payload details. ## **Parameters** **`url`** `string` — required WebSocket URL to stream audio to (e.g., `"wss://example.com/stream"`). --- **`name`** `string | undefined` A name for this stream, useful for identifying multiple concurrent streams. --- **`codec`** `string | undefined` Audio codec for the stream. * `"PCMU"` -- G.711 mu-law (default for North America) * `"PCMA"` -- G.711 A-law (default for international) * `"OPUS"` -- Opus codec (higher quality, variable bitrate) --- **`track`** `string | undefined` Which audio track to stream. * `"inbound"` -- audio received from the caller * `"outbound"` -- audio sent to the caller * `"both"` -- audio in both directions --- **`statusUrl`** `string | undefined` URL to receive stream status webhooks. --- **`statusUrlMethod`** `string | undefined` HTTP method for status webhooks. * `"GET"` -- send status updates via GET request * `"POST"` -- send status updates via POST request --- **`authorizationBearerToken`** `string | undefined` Bearer token for authenticating with the WebSocket server. --- **`customParameters`** `Record | undefined` Custom key-value pairs sent with the stream start message. --- **`controlId`** `string | undefined` Custom control ID. Auto-generated if not provided. --- **`onCompleted`** `(event: RelayEvent) => void | Promise` Callback invoked when the stream ends. --- ## **Returns** `Promise<`[`StreamAction`][streamaction]`>` -- An action handle with `stop()` and `wait()` methods. ## **Example** ```typescript {13} import { RelayClient } from '@signalwire/sdk'; const client = new RelayClient({ project: process.env.SIGNALWIRE_PROJECT_ID!, token: process.env.SIGNALWIRE_API_TOKEN!, contexts: ['default'] }); client.onCall(async (call) => { await call.answer(); // Stream audio to an external service for real-time processing const action = await call.stream( 'wss://example.com/audio-stream', { track: 'inbound', codec: 'PCMU', customParameters: { session_id: 'abc123' } } ); // The stream runs until stopped or the call ends await call.waitForEnded(); }); await client.run(); ``` > Stream call audio to a WebSocket endpoint.