Wavix call media streaming is exclusively available for the Flex Pro account level.
Streaming types
Unidirectional streaming
Your application receives call audio but can’t send audio back to Wavix. You can stream:- Inbound audio (to Wavix)
- Outbound audio (from Wavix)
- Both channels
Bidirectional streaming
Your application can both receive and send audio over the same WebSocket connection. Wavix plays the audio you send directly into the call, which is useful for real-time AI conversations.With bidirectional media streaming, your application can only receive the inbound audio stream.
Prerequisites
Create a Wavix account
- Sign up for a Wavix account using your business email address.
- Confirm your email address and phone number during the sign-up process.
- Wait for your account to be approved by the Wavix team.
- After approval, choose either the Wavix Flex or Flex Pro account level.
Get your API key
Wavix uses API keys to authenticate requests. To find API keys associated with your account:- Sign in to your Wavix account.
- Go to Administration → API Keys.
- Copy the API key you want to use, or create a new one by clicking Create new.
Call media streaming flow
To stream raw call audio, follow these steps:- Subscribe to call events.
- Initiate or answer a call programmatically.
- Start the call media streaming.
- Stop the call media streaming.
1. Subscribe to call events
To receive all call-related events, Wavix recommends subscribing to both inbound and outbound call events. To subscribe to outbound call events, include your webhook URL in thestatus_callback
parameter of the Initiate outbound call request. To receive inbound call events, assign a call status callback URL to your phone number using the Wavix Phone numbers API or GUI.
2. Initiate or answer a call programmatically
To start an outbound call, use the following methodInitiate an outbound call
your_api_key
: Your Wavix API key.from
: Caller ID the will be used. Must be an active or verified number in your Wavix account.to
: Destination phone number. The number must be present in international E.164 format.status_callback
: A webhook URL to post call events to.
HTTP 200 OK
and a unique call identifier.
To answer an inbound call, use the following method
Answer an inbound call
your_api_key
: Your Wavix API key.call_id
: Unique identifier of the call which you received on your webhook assigned to a phone number.
stream_channel
: Indicates what call channel should be streamed. Can beinbound
,outbound
, orboth
stream_type
: Can be ‘oneway’ for unidirectional or ‘twoway’ for bidirectional call media streaming.stream_url
: WebSocket URL to which the inbound call media will be streamed (must start withws
orwss
).
HTTP 200 OK
and a success indicator. Streaming starts right away.
3. Start call media streaming
Wait until the call is answered before starting media streaming. To start the streaming, use the following methodStart call streaming
your_api_key
: Your Wavix API key.stream_channel
: Indicates what call channel should be streamed. Can beinbound
,outbound
, orboth
stream_type
: Can be ‘oneway’ for unidirectional or ‘twoway’ for bidirectional call media streaming.stream_url
: WebSocket URL to which the inbound call media will be streamed (must start withws
orwss
).
With bidirectional media streaming, your application can only receive the inbound audio stream.
HTTP 200 OK
. The response will contain a unique stream identifier.
You can only have a single bidirectional and up to 5 unidirectional streams for a single call.
4. Stop call media streaming
Call media streaming is automatically stopped when the call is completed. To stop it programmatically use the following methodStop call streaming
your_api_key
: Your Wavix API key.call_id
: Unique identifier of the call.stream_id
: Unique identifier of the stream.
HTTP 200 OK
and a success indicator.
Call media streaming events
While streaming a call, Wavix sends messages to your WebSocket server. For bidirectional streaming, your server can also send messages back to Wavix.WebSocket messages from Wavix
Wavix sends the following message to your WebSocket server while streaming a call.connected
Sent once the connection is established.
start
Sent before media streaming begins. Contains stream metadata.
media
Contains audio chunks streamed to your WebSocket server.
stop
Sent when streaming is stopped or the call ends.
mark
Acknowledges that the previous media message finished playing. Only used in bidirectional call streaming.
WebSocket messages to Wavix
When using bidirectional streaming, your server can send these messages to Wavix to play audio back into the call and control the stream flow.media
Send audio chunks from your server to Wavix.
mark
You can send the mark
message after sending media
to request notification when the audio chunk has been played. Wavix responds with the mark
message with a matching name when the audio ends (or if there is no audio buffered).
clear
You can send the clear
message to interrupt previously sent audio and empty all buffered audio. This causes any queued mark
message to be sent back to your WebSocket server.