Initiate an outbound call
Initiate an outbound TeXML call. Telnyx will request TeXML from the XML Request URL configured for the TeXML Application in the Mission Control Portal.
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.calls('account_sid', {
params: { Url: 'https://www.example.com/texml.xml' },
});
console.log(response.from);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.calls(
account_sid="account_sid",
params={
"url": "https://www.example.com/texml.xml"
},
)
print(response.from_)
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.Calls(
context.TODO(),
"account_sid",
telnyx.TexmlAccountCallCallsParams{
OfWithURL: &telnyx.TexmlAccountCallCallsParamsParamsWithURL{
URL: "https://www.example.com/texml.xml",
},
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.From)
}
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.CallCallsParams;
import com.telnyx.sdk.models.texml.accounts.calls.CallCallsResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
CallCallsParams params = CallCallsParams.builder()
.accountSid("account_sid")
.params(CallCallsParams.Params.WithUrl.builder()
.url("https://www.example.com/texml.xml")
.build())
.build();
CallCallsResponse response = client.texml().accounts().calls().calls(params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
response = telnyx.texml.accounts.calls.calls("account_sid", params: {Url: "https://www.example.com/texml.xml"})
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->calls(
'account_sid',
params: [
'url' => 'https://www.example.com/texml.xml',
'applicationSid' => 'example-app-sid',
'asyncAmd' => true,
'asyncAmdStatusCallback' => 'https://www.example.com/callback',
'asyncAmdStatusCallbackMethod' => 'GET',
'callerID' => 'Info',
'cancelPlaybackOnDetectMessageEnd' => false,
'cancelPlaybackOnMachineDetection' => false,
'customHeaders' => [
['name' => 'X-Custom-Header', 'value' => 'custom-value']
],
'deepfakeDetection' => 'Enable',
'deepfakeDetectionCallbackMethod' => 'GET',
'deepfakeDetectionCallbackURL' => 'https://www.example.com/deepfake-callback',
'detectionMode' => 'Premium',
'fallbackURL' => 'https://www.example.com/instructions-fallback.xml',
'from' => '+13120001234',
'machineDetection' => 'Enable',
'machineDetectionPromptEndTimeout' => 5000,
'machineDetectionSilenceTimeout' => 2000,
'machineDetectionSpeechEndThreshold' => 2000,
'machineDetectionSpeechThreshold' => 2000,
'machineDetectionTimeout' => 5000,
'mediaEncryption' => 'disabled',
'preferredCodecs' => 'PCMA,PCMU',
'record' => false,
'recordingChannels' => 'dual',
'recordingStatusCallback' => 'https://example.com/recording_status_callback',
'recordingStatusCallbackEvent' => 'in-progress completed absent',
'recordingStatusCallbackMethod' => 'GET',
'recordingTimeout' => 5,
'recordingTrack' => 'inbound',
'sendRecordingURL' => false,
'sipAuthPassword' => '1234',
'sipAuthUsername' => 'user',
'sipRegion' => 'Canada',
'statusCallback' => 'https://www.example.com/statuscallback-listener',
'statusCallbackEvent' => 'initiated',
'statusCallbackMethod' => 'GET',
'superviseCallSid' => 'v3:MdI91X4lWFEs7IgbBEOT9M4AigoY08M0WWZFISt1Yw2axZ_IiE4pqg',
'supervisingRole' => 'monitor',
'texml' => 'Texml',
'timeLimit' => 3600,
'timeout' => 60,
'to' => '+13121230000',
'trim' => 'trim-silence',
'urlMethod' => 'GET',
],
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx texml:accounts:calls calls \
--api-key 'My API Key' \
--account-sid account_sid \
--params '{Url: https://www.example.com/texml.xml}'curl --request POST \
--url https://api.telnyx.com/v2/texml/Accounts/{account_sid}/Calls \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"To": "+13121230000",
"From": "+13120001234",
"Url": "https://www.example.com/texml.xml",
"StatusCallback": "https://www.example.com/statuscallback-listener",
"ApplicationSid": "1293384261075731499"
}
'{
"from": "+13120001234",
"to": "+13121230000",
"status": "queued"
}Authorizations
Path Parameters
The UUID of the Telnyx account that owns the resource, for example f5586561-8ff0-4291-a51b-c7dfe4139ff9. The account_sid path segment is kept for Twilio API compatibility, but the value is a Telnyx account UUID, not a Twilio AC... SID. It must match the account that owns the API key used to authenticate the request, otherwise the endpoint returns 404. The same value is sent as AccountSid in TeXML webhooks.
"f5586561-8ff0-4291-a51b-c7dfe4139ff9"
Body
Initiate Call request object
- Initiate Call Request
- Initiate Call Request
- Initiate Call Request
The ID of the TeXML Application that will handle the call, for example 1293384261075731499. The ApplicationSid name is kept for Twilio API compatibility, but the value is the numeric ID of one of your TeXML Applications (see the TeXML Applications API or the Mission Control Portal), not a Twilio AP... SID. If Url and Texml are omitted, Telnyx fetches instructions from the XML Request URL configured on this application.
"1293384261075731499"
To be used as the caller id name (SIP From Display Name) presented to the destination (To number). The string should have a maximum of 128 characters, containing only letters, numbers, spaces, and -_~!.+ special characters. If ommited, the display name will be the same as the number in the From field.
"Info"
Allows you to choose between Regular, Premium, and PremiumCallScreening detections. See https://developers.telnyx.com/docs/voice/programmable-voice/answering-machine-detection
Premium, Regular, PremiumCallScreening "Premium"
Selects which detectors must validate a beep. both requires the amplitude and frequency detectors to agree. freq_only uses the frequency detector alone, for beeps whose volume is too unsteady for the default profile. Only used when MachineDetection is enabled.
both, freq_only "freq_only"
Lowest frequency, in Hz, that a tone must reach to be treated as a beep. Raising it above 480 excludes North American ringback (440 + 480 Hz), which can otherwise be reported as a beep when the freq_only profile is in use. Only used when MachineDetection is enabled.
200 <= x <= 4000550
The number of seconds that Telnyx will wait for the recording to be stopped if silence is detected. The timer only starts when the speech is detected. Please note that the transcription is used to detect silence and the related charge will be applied. The minimum value is 0. The default value is 0 (infinite)
5
Applies when Record is true. Silences spoken details of the given kinds in the recording: one or more of pci (card number, expiry date, security code), pii (personal details such as names, phone numbers, addresses and other identifying numbers) and phi (health details such as medications, doses and conditions), separated by commas, for example pci,pii. Redaction works on English speech only. Redacted recordings are charged at the Deepgram speech-to-text rate.
"pci,pii"
Defines whether media should be encrypted on the call. When set to SRTP, the call will use Secure Real-time Transport Protocol for media encryption. When set to DTLS, the call will use DTLS for media encryption. Only supported for SIP destinations.
disabled, SRTP, DTLS "disabled"
The call control ID of the existing call to supervise. When provided, the created leg will be added to the specified call in supervising mode. Status callbacks and action callbacks will NOT be sent for the supervising leg.
"v3:MdI91X4lWFEs7IgbBEOT9M4AigoY08M0WWZFISt1Yw2axZ_IiE4pqg"
The destination WebSocket address where the call's media stream is delivered, for example wss://www.example.com/websocket. When set, a media stream is started on the outbound call. Required when any other Stream* parameter is set. Can't be combined with SuperviseCallSid.
"wss://www.example.com/websocket"
An authentication token for the WebSocket server. It is sent as the x-telnyx-streaming-auth-token header of the WebSocket handshake and repeated as connected.x-telnyx-streaming-auth-token in the connected event. Maximum length is 4000 characters. Requires StreamUrl.
4000"your-auth-token"
Establishes the WebSocket connection before the destination is dialed, so no audio is missed while the connection is set up. If the WebSocket connection can't be established, the call is not placed and the request fails with a 422 error. StreamUrl is required when this is true.
true
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.calls('account_sid', {
params: { Url: 'https://www.example.com/texml.xml' },
});
console.log(response.from);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.calls(
account_sid="account_sid",
params={
"url": "https://www.example.com/texml.xml"
},
)
print(response.from_)
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.Calls(
context.TODO(),
"account_sid",
telnyx.TexmlAccountCallCallsParams{
OfWithURL: &telnyx.TexmlAccountCallCallsParamsParamsWithURL{
URL: "https://www.example.com/texml.xml",
},
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.From)
}
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.CallCallsParams;
import com.telnyx.sdk.models.texml.accounts.calls.CallCallsResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
CallCallsParams params = CallCallsParams.builder()
.accountSid("account_sid")
.params(CallCallsParams.Params.WithUrl.builder()
.url("https://www.example.com/texml.xml")
.build())
.build();
CallCallsResponse response = client.texml().accounts().calls().calls(params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
response = telnyx.texml.accounts.calls.calls("account_sid", params: {Url: "https://www.example.com/texml.xml"})
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->calls(
'account_sid',
params: [
'url' => 'https://www.example.com/texml.xml',
'applicationSid' => 'example-app-sid',
'asyncAmd' => true,
'asyncAmdStatusCallback' => 'https://www.example.com/callback',
'asyncAmdStatusCallbackMethod' => 'GET',
'callerID' => 'Info',
'cancelPlaybackOnDetectMessageEnd' => false,
'cancelPlaybackOnMachineDetection' => false,
'customHeaders' => [
['name' => 'X-Custom-Header', 'value' => 'custom-value']
],
'deepfakeDetection' => 'Enable',
'deepfakeDetectionCallbackMethod' => 'GET',
'deepfakeDetectionCallbackURL' => 'https://www.example.com/deepfake-callback',
'detectionMode' => 'Premium',
'fallbackURL' => 'https://www.example.com/instructions-fallback.xml',
'from' => '+13120001234',
'machineDetection' => 'Enable',
'machineDetectionPromptEndTimeout' => 5000,
'machineDetectionSilenceTimeout' => 2000,
'machineDetectionSpeechEndThreshold' => 2000,
'machineDetectionSpeechThreshold' => 2000,
'machineDetectionTimeout' => 5000,
'mediaEncryption' => 'disabled',
'preferredCodecs' => 'PCMA,PCMU',
'record' => false,
'recordingChannels' => 'dual',
'recordingStatusCallback' => 'https://example.com/recording_status_callback',
'recordingStatusCallbackEvent' => 'in-progress completed absent',
'recordingStatusCallbackMethod' => 'GET',
'recordingTimeout' => 5,
'recordingTrack' => 'inbound',
'sendRecordingURL' => false,
'sipAuthPassword' => '1234',
'sipAuthUsername' => 'user',
'sipRegion' => 'Canada',
'statusCallback' => 'https://www.example.com/statuscallback-listener',
'statusCallbackEvent' => 'initiated',
'statusCallbackMethod' => 'GET',
'superviseCallSid' => 'v3:MdI91X4lWFEs7IgbBEOT9M4AigoY08M0WWZFISt1Yw2axZ_IiE4pqg',
'supervisingRole' => 'monitor',
'texml' => 'Texml',
'timeLimit' => 3600,
'timeout' => 60,
'to' => '+13121230000',
'trim' => 'trim-silence',
'urlMethod' => 'GET',
],
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx texml:accounts:calls calls \
--api-key 'My API Key' \
--account-sid account_sid \
--params '{Url: https://www.example.com/texml.xml}'curl --request POST \
--url https://api.telnyx.com/v2/texml/Accounts/{account_sid}/Calls \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"To": "+13121230000",
"From": "+13120001234",
"Url": "https://www.example.com/texml.xml",
"StatusCallback": "https://www.example.com/statuscallback-listener",
"ApplicationSid": "1293384261075731499"
}
'{
"from": "+13120001234",
"to": "+13121230000",
"status": "queued"
}