Start streaming media from a call.
Starts streaming media from a call to a specific WebSocket address.
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const response = await client.texml.accounts.calls.streamsJson('call_sid', {
account_sid: 'account_sid',
});
console.log(response.account_sid);import os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
response = client.texml.accounts.calls.streams_json(
call_sid="call_sid",
account_sid="account_sid",
)
print(response.account_sid)
package main
import (
"context"
"fmt"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
response, err := client.Texml.Accounts.Calls.StreamsJson(
context.TODO(),
"call_sid",
telnyx.TexmlAccountCallStreamsJsonParams{
AccountSid: "account_sid",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.AccountSid)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.texml.accounts.calls.CallStreamsJsonParams;
import com.telnyx.sdk.models.texml.accounts.calls.CallStreamsJsonResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
CallStreamsJsonParams params = CallStreamsJsonParams.builder()
.accountSid("account_sid")
.callSid("call_sid")
.build();
CallStreamsJsonResponse response = client.texml().accounts().calls().streamsJson(params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
response = telnyx.texml.accounts.calls.streams_json("call_sid", account_sid: "account_sid")
puts(response)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Telnyx\Client;
use Telnyx\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API Key');
try {
$response = $client->texml->accounts->calls->streamsJson(
'call_sid',
accountSid: 'account_sid',
bidirectionalCodec: 'G722',
bidirectionalMode: 'rtp',
name: 'My stream',
statusCallback: 'http://webhook.com/callback',
statusCallbackMethod: 'GET',
track: 'both_tracks',
url: 'wss://www.example.com/websocket',
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx texml:accounts:calls streams-json \
--api-key 'My API Key' \
--account-sid account_sid \
--call-sid call_sidcurl --request POST \
--url https://api.telnyx.com/v2/texml/Accounts/{account_sid}/Calls/{call_sid}/Streams.json \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data StatusCallback=http://webhook.com/callback \
--data StatusCallbackMethod=GET \
--data Track=both_tracks \
--data 'Name=My stream' \
--data BidirectionalMode=rtp \
--data BidirectionalCodec=G722 \
--data Url=wss://www.example.com/websocket{
"account_sid": "61bf923e-5e4d-4595-a110-56190ea18a1b",
"call_sid": "v3:KBnLO0ZK3DhKM5s7bE9VluaSmKsOchKht_fUYvxcp8ysbmzCCtpkmA",
"sid": "e9cea0be-7dbd-4b98-98b1-c0089d9d43b0",
"name": "My stream",
"status": "in-progress",
"date_updated": "2023-08-11T19:12:11Z",
"uri": "/v2/texml/Accounts/61bf923e-5e4d-4595-a110-56190ea18a1b/Calls/v3:KBnLO0ZK3DhKM5s7bE9VluaSmKsOchKht_fUYvxcp8ysbmzCCtpkmA/Streams/b08f0fa1-a32c-4218-b3b5-9cf78941ccac.json"
}{
"errors": [
{
"detail": "Resource not found"
}
]
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
The id of the account the resource belongs to.
The CallSid that identifies the call to update.
Body
Start streaming media from a call
Url where status callbacks will be sent.
"http://webhook.com/callback"
HTTP method used to send status callbacks.
GET, POST "GET"
Tracks to be included in the stream
inbound_track, outbound_track, both_tracks "both_tracks"
The user specified name of Stream.
"My stream"
Configures method of bidirectional streaming (mp3, rtp).
mp3, rtp "rtp"
Indicates codec for bidirectional streaming RTP payloads. Used only with stream_bidirectional_mode=rtp. Case sensitive.
PCMU, PCMA, G722 "G722"
The destination WebSocket address where the stream is going to be delivered.
"wss://www.example.com/websocket"
Response
Successful call streaming create response
"61bf923e-5e4d-4595-a110-56190ea18a1b"
"v3:KBnLO0ZK3DhKM5s7bE9VluaSmKsOchKht_fUYvxcp8ysbmzCCtpkmA"
Identifier of a resource.
"e9cea0be-7dbd-4b98-98b1-c0089d9d43b0"
The user specified name of Stream.
"My stream"
The status of the streaming.
in-progress "in-progress"
"2023-08-11T19:12:11Z"
The relative URI for this streaming resource.
"/v2/texml/Accounts/61bf923e-5e4d-4595-a110-56190ea18a1b/Calls/v3:KBnLO0ZK3DhKM5s7bE9VluaSmKsOchKht_fUYvxcp8ysbmzCCtpkmA/Streams/b08f0fa1-a32c-4218-b3b5-9cf78941ccac.json"
Was this page helpful?
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const response = await client.texml.accounts.calls.streamsJson('call_sid', {
account_sid: 'account_sid',
});
console.log(response.account_sid);import os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
response = client.texml.accounts.calls.streams_json(
call_sid="call_sid",
account_sid="account_sid",
)
print(response.account_sid)
package main
import (
"context"
"fmt"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
response, err := client.Texml.Accounts.Calls.StreamsJson(
context.TODO(),
"call_sid",
telnyx.TexmlAccountCallStreamsJsonParams{
AccountSid: "account_sid",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.AccountSid)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.texml.accounts.calls.CallStreamsJsonParams;
import com.telnyx.sdk.models.texml.accounts.calls.CallStreamsJsonResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
CallStreamsJsonParams params = CallStreamsJsonParams.builder()
.accountSid("account_sid")
.callSid("call_sid")
.build();
CallStreamsJsonResponse response = client.texml().accounts().calls().streamsJson(params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
response = telnyx.texml.accounts.calls.streams_json("call_sid", account_sid: "account_sid")
puts(response)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Telnyx\Client;
use Telnyx\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API Key');
try {
$response = $client->texml->accounts->calls->streamsJson(
'call_sid',
accountSid: 'account_sid',
bidirectionalCodec: 'G722',
bidirectionalMode: 'rtp',
name: 'My stream',
statusCallback: 'http://webhook.com/callback',
statusCallbackMethod: 'GET',
track: 'both_tracks',
url: 'wss://www.example.com/websocket',
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx texml:accounts:calls streams-json \
--api-key 'My API Key' \
--account-sid account_sid \
--call-sid call_sidcurl --request POST \
--url https://api.telnyx.com/v2/texml/Accounts/{account_sid}/Calls/{call_sid}/Streams.json \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data StatusCallback=http://webhook.com/callback \
--data StatusCallbackMethod=GET \
--data Track=both_tracks \
--data 'Name=My stream' \
--data BidirectionalMode=rtp \
--data BidirectionalCodec=G722 \
--data Url=wss://www.example.com/websocket{
"account_sid": "61bf923e-5e4d-4595-a110-56190ea18a1b",
"call_sid": "v3:KBnLO0ZK3DhKM5s7bE9VluaSmKsOchKht_fUYvxcp8ysbmzCCtpkmA",
"sid": "e9cea0be-7dbd-4b98-98b1-c0089d9d43b0",
"name": "My stream",
"status": "in-progress",
"date_updated": "2023-08-11T19:12:11Z",
"uri": "/v2/texml/Accounts/61bf923e-5e4d-4595-a110-56190ea18a1b/Calls/v3:KBnLO0ZK3DhKM5s7bE9VluaSmKsOchKht_fUYvxcp8ysbmzCCtpkmA/Streams/b08f0fa1-a32c-4218-b3b5-9cf78941ccac.json"
}{
"errors": [
{
"detail": "Resource not found"
}
]
}