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

# Handler

> WebSocket endpoint for Twilio Media Streams. Use a short-lived stream token during setup, or tenant bearer authentication for compatible internal clients.

WebSocket endpoint for Twilio Media Streams. Use a short-lived stream token during setup, or tenant bearer authentication for compatible internal clients.

### Response

No response body — WebSocket upgrade (`101`). WebSocket upgrade speaking the Twilio Media Streams protocol (bidirectional JSON frames carrying base64 audio, `start`/`media`/`mark`/`stop` events). Twilio connects here from the TwiML that /incoming-call-sip and /outbound-call-sip return; browser web calls speak the same protocol. There is no JSON response body over plain HTTP.

### Status codes

| Code  | Meaning                                                                                                                                                                                                                                                                                                                                     |
| ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `101` | WebSocket upgrade speaking the Twilio Media Streams protocol (bidirectional JSON frames carrying base64 audio, `start`/`media`/`mark`/`stop` events). Twilio connects here from the TwiML that /incoming-call-sip and /outbound-call-sip return; browser web calls speak the same protocol. There is no JSON response body over plain HTTP. |
| `400` | Missing WebSocket upgrade headers                                                                                                                                                                                                                                                                                                           |
| `401` | Unauthorized                                                                                                                                                                                                                                                                                                                                |
| `429` | Too many pending bootstrap sessions                                                                                                                                                                                                                                                                                                         |

<RequestExample>
  ```bash cURL theme={null}
  curl --request GET \
    --url 'https://api.voice.stateset.com/media-stream' \
    --header "Authorization: Bearer $STATESET_VOICE_API_KEY"
  ```
</RequestExample>
