Skip to content

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>
  • POST (the default): the parameters are sent as a JSON object in the body, with Content-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.

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.
  1. stream-startedconnected
  2. stream-jsonany text your server sends, 0 or more
  3. stream-stoppedthe stream ended
  1. stream-errorcould not connect
  2. stream-stopped
StreamEvent values for one stream

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.

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.

{
"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"
}
  • Timeout: SIPRTC waits up to 10 seconds for your reply.
  • Retries: if your endpoint can’t be reached, times out, or answers 408, 429 or 5xx, SIPRTC retries the callback a few times with increasing delays (from seconds up to several minutes). Any other 4xx is not retried.
  • Order is not guaranteed. Callbacks are sent independently, and retries can arrive late. Use Timestamp, and treat stream-stopped as final for a StreamSid.
  • Duplicates are possible. In particular, when your server closes the connection or the connection fails, you can receive stream-stopped twice for the same stream. Make your handler idempotent, keyed on StreamSid and StreamEvent.