Stream status callbacks
If a <Stream> has a statusCallback URL, SIPRTC sends an HTTP request to it when the stream starts, when it stops, and when it fails. Without statusCallback, no stream callbacks are sent.
<Start> <Stream url="wss://stream.example.com/calls?token=s3cr3t" name="transcriber" statusCallback="https://example.com/stream-status?key=k3y" statusCallbackMethod="POST"/></Start>Request
Section titled “Request”POST(the default): the parameters are sent as a JSON object in the body, withContent-Type: application/json.GET(statusCallbackMethod="GET"): the parameters are sent in the query string.
All values are strings. Parameters with no value are left out, so your handler should not expect every parameter on every request.
If the URL contains credentials (https://user:password@example.com/cb), SIPRTC sends them as HTTP basic authentication. Callbacks are not signed, so use HTTPS and put a secret in the URL.
Reply with any 2xx status. The response body is ignored.
Events
Section titled “Events”The StreamEvent parameter says what happened.
StreamEvent |
When |
|---|---|
stream-started |
The WebSocket connection to your server was opened. SIPRTC sends connected and start at the same time. |
stream-stopped |
The stream ended: the call hung up, TinyML ran <Stop><Stream/></Stop>, your server closed the connection, or the connection failed. |
stream-error |
SIPRTC could not connect to your server, for example because of a DNS failure, a refused connection, a TLS error or a handshake that didn’t return HTTP 101. A stream-stopped follows. |
stream-json |
Your server sent a text message that SIPRTC passes on (see Other messages). The message is in StreamJson. |
- stream-startedconnected
- stream-jsonany text your server sends, 0 or more
- stream-stoppedthe stream ended
- stream-errorcould not connect
- stream-stopped
A stream that can’t start at all, for example because its URL is invalid or the call leg is already streaming, sends no callbacks. See When a stream can’t start.
Parameters
Section titled “Parameters”| Parameter | Description |
|---|---|
StreamEvent |
stream-started, stream-stopped, stream-error or stream-json. |
StreamSid |
The stream’s ID: the same value as stream_sid in the WebSocket messages. |
StreamName |
The name attribute of the <Stream>, if it had one. |
StreamError |
stream-error only. A JSON string describing the failure, for example {"status":"error","message":{"error":"HS: ws upgrade response not 101"}}. Treat the error text as a message for people; its wording can change. |
StreamJson |
stream-json only. The text message your server sent, unchanged. |
AccountSid |
Your account. |
CallSid |
The call being streamed. |
ParentCallSid |
The call that created this one, when this call leg was created by another call (for example by <Dial>). |
From |
The calling party. |
To |
The called party. |
Caller |
The caller ID. |
Called |
The number or address that was dialled. |
Direction |
The direction of this call leg. |
Timestamp |
When the event happened, in RFC 1123 format in GMT, for example Thu, 26 Nov 2026 10:15:02 GMT. |
Other call parameters can appear as well. Ignore any you don’t use.
Example
Section titled “Example”{ "StreamEvent": "stream-started", "StreamSid": "8b6f0d2a-3c4e-4f1a-9b7d-2e5c6a1f0b3d", "StreamName": "transcriber", "AccountSid": "AC0000000000000000000", "CallSid": "4f9a2c3e-1b7d-4e8a-9c6f-0d2e5b7a1c94", "From": "+15550100987", "To": "+15550100123", "Caller": "+15550100987", "Called": "+15550100123", "Direction": "inbound", "Timestamp": "Thu, 26 Nov 2026 10:15:02 GMT"}Delivery
Section titled “Delivery”- Timeout: SIPRTC waits up to 10 seconds for your reply.
- Retries: if your endpoint can’t be reached, times out, or answers
408,429or5xx, SIPRTC retries the callback a few times with increasing delays (from seconds up to several minutes). Any other4xxis not retried. - Order is not guaranteed. Callbacks are sent independently, and retries can arrive late. Use
Timestamp, and treatstream-stoppedas final for aStreamSid. - Duplicates are possible. In particular, when your server closes the connection or the connection fails, you can receive
stream-stoppedtwice for the same stream. Make your handler idempotent, keyed onStreamSidandStreamEvent.