Stop an Audio Stream

This method lets you stop an active audio stream on a call.

Stopping an audio stream terminates the WebSocket connection and stops transmitting audio data. You can either stop a specific stream by providing its stream_id, or stop all active streams for a call.

Note: Stopping a stream does not affect the call itself. The call will continue and subsequent XML elements (if any) will execute. If you configured a status_callback_url, a StopStream event will be sent.

Stop a Specific Stream

DELETEhttps://api.vobiz.ai/api/v1/Account/{auth_id}/Call/{call_uuid}/Stream/{stream_uuid}/

Authentication: Include X-Auth-ID and X-Auth-Token headers.

Success Response (200 OK):

JSON
{
  "message": "Stream stopped successfully",
  "stream_id": "stream-id-aabbcc-ddeeff"
}

Error Response (404 Not Found):

JSON
{
  "api_id": "aabbccdd-1234-5678-90ab-cdef12345678",
  "error": "No active stream found"
}

Stop All Streams

DELETEhttps://api.vobiz.ai/api/v1/Account/{auth_id}/Call/{call_uuid}/Stream/

Omit the stream_uuid from the path to stop all active streams for the call.

Success Response (200 OK):

JSON
{
  "message": "All streams stopped successfully",
  "streams_stopped": 2
}

Error Response (404 Not Found):

JSON
{
  "api_id": "aabbccdd-1234-5678-90ab-cdef12345678",
  "error": "No active stream found"
}

Examples

Stop a Specific Stream

cURL

cURL Request
curl -X DELETE https://api.vobiz.ai/api/v1/Account/MA_AABBCC/Call/call-uuid-xxxx-yyyy/Stream/stream-id-aabbcc-ddeeff/ \
  -H "X-Auth-ID: YOUR_AUTH_ID" \
  -H "X-Auth-Token: YOUR_AUTH_TOKEN"

Node.js

Node.js
const axios = require('axios');

const authId = 'MA_AABBCC';
const callUuid = 'call-uuid-xxxx-yyyy';
const streamId = 'stream-id-aabbcc-ddeeff';

axios.delete(`https://api.vobiz.ai/api/v1/Account/${authId}/Call/${callUuid}/Stream/${streamId}/`, {
  headers: {
    'X-Auth-ID': 'YOUR_AUTH_ID',
    'X-Auth-Token': 'YOUR_AUTH_TOKEN'
  }
})
.then(response => {
  console.log('Stream stopped:', response.data);
})
.catch(error => {
  if (error.response && error.response.status === 404) {
    console.log('No active stream found');
  } else {
    console.error('Error stopping stream:', error.response.data);
  }
});

Python

Python
import requests

auth_id = 'MA_AABBCC'
call_uuid = 'call-uuid-xxxx-yyyy'
stream_id = 'stream-id-aabbcc-ddeeff'

url = f'https://api.vobiz.ai/api/v1/Account/{auth_id}/Call/{call_uuid}/Stream/{stream_id}/'

headers = {
    'X-Auth-ID': 'YOUR_AUTH_ID',
    'X-Auth-Token': 'YOUR_AUTH_TOKEN'
}

response = requests.delete(url, headers=headers)

if response.status_code == 200:
    print("Stream stopped successfully")
    print(response.json())
elif response.status_code == 404:
    print("No active stream found")
else:
    print(f"Error: {response.status_code}")

Stop All Streams

cURL

cURL Request
curl -X DELETE https://api.vobiz.ai/api/v1/Account/MA_AABBCC/Call/call-uuid-xxxx-yyyy/Stream/ \
  -H "X-Auth-ID: YOUR_AUTH_ID" \
  -H "X-Auth-Token: YOUR_AUTH_TOKEN"

Node.js

Node.js
const axios = require('axios');

const authId = 'MA_AABBCC';
const callUuid = 'call-uuid-xxxx-yyyy';

axios.delete(`https://api.vobiz.ai/api/v1/Account/${authId}/Call/${callUuid}/Stream/`, {
  headers: {
    'X-Auth-ID': 'YOUR_AUTH_ID',
    'X-Auth-Token': 'YOUR_AUTH_TOKEN'
  }
})
.then(response => {
  console.log('All streams stopped:', response.data);
  console.log(`Stopped ${response.data.streams_stopped} streams`);
})
.catch(error => {
  console.error('Error stopping streams:', error.response.data);
});

Best Practices:

  • • Stop streams when they're no longer needed to avoid unnecessary costs
  • • Handle 404 errors gracefully (stream may have already ended)
  • • Use status callbacks to confirm stream termination
  • • Clean up WebSocket connections on the client side when streams stop