telnyx-sip-integrations-javascript
Original:🇺🇸 English
Translated
Manage call recordings, media storage, Dialogflow integration, and external connections for SIP trunking. This skill provides JavaScript SDK examples.
8installs
Sourceteam-telnyx/skills
Added on
NPX Install
npx skill4agent add team-telnyx/skills telnyx-sip-integrations-javascriptTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →<!-- Auto-generated from Telnyx OpenAPI specs. Do not edit. -->
— Required: ,
— Required:
— Required:
— Required:
— Required:
Telnyx Sip Integrations - JavaScript
Installation
bash
npm install telnyxSetup
javascript
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});All examples below assume is already initialized as shown above.
clientError Handling
All API calls can fail with network errors, rate limits (429), validation errors (422),
or authentication errors (401). Always handle errors in production code:
javascript
try {
const result = await client.messages.send({ to: '+13125550001', from: '+13125550002', text: 'Hello' });
} catch (err) {
if (err instanceof Telnyx.APIConnectionError) {
console.error('Network error — check connectivity and retry');
} else if (err instanceof Telnyx.RateLimitError) {
// 429: rate limited — wait and retry with exponential backoff
const retryAfter = err.headers?.['retry-after'] || 1;
await new Promise(r => setTimeout(r, retryAfter * 1000));
} else if (err instanceof Telnyx.APIError) {
console.error(`API error ${err.status}: ${err.message}`);
if (err.status === 422) {
console.error('Validation error — check required fields and formats');
}
}
}Common error codes: invalid API key, insufficient permissions,
resource not found, validation error (check field formats),
rate limited (retry with exponential backoff).
401403404422429Important Notes
- Pagination: List methods return an auto-paginating iterator. Use to iterate through all pages automatically.
for await (const item of result) { ... }
Retrieve a stored credential
Returns the information about custom storage credentials.
GET /custom_storage_credentials/{connection_id}javascript
const customStorageCredential = await client.customStorageCredentials.retrieve('connection_id');
console.log(customStorageCredential.connection_id);Returns: (enum: gcs, s3, azure), (object)
backendconfigurationCreate a custom storage credential
Creates a custom storage credentials configuration.
POST /custom_storage_credentials/{connection_id}javascript
const customStorageCredential = await client.customStorageCredentials.create('connection_id', {
backend: 'gcs',
configuration: { backend: 'gcs' },
});
console.log(customStorageCredential.connection_id);Returns: (enum: gcs, s3, azure), (object)
backendconfigurationUpdate a stored credential
Updates a stored custom credentials configuration.
PUT /custom_storage_credentials/{connection_id}javascript
const customStorageCredential = await client.customStorageCredentials.update('connection_id', {
backend: 'gcs',
configuration: { backend: 'gcs' },
});
console.log(customStorageCredential.connection_id);Returns: (enum: gcs, s3, azure), (object)
backendconfigurationDelete a stored credential
Deletes a stored custom credentials configuration.
DELETE /custom_storage_credentials/{connection_id}javascript
await client.customStorageCredentials.delete('connection_id');Retrieve stored Dialogflow Connection
Return details of the Dialogflow connection associated with the given CallControl connection.
GET /dialogflow_connections/{connection_id}javascript
const dialogflowConnection = await client.dialogflowConnections.retrieve('connection_id');
console.log(dialogflowConnection.data);Returns: (string), (string), (string), (string), (string)
connection_idconversation_profile_idenvironmentrecord_typeservice_accountCreate a Dialogflow Connection
Save Dialogflow Credentiails to Telnyx, so it can be used with other Telnyx services.
POST /dialogflow_connections/{connection_id}javascript
const dialogflowConnection = await client.dialogflowConnections.create('connection_id', {
service_account: {
type: 'bar',
project_id: 'bar',
private_key_id: 'bar',
private_key: 'bar',
client_email: 'bar',
client_id: 'bar',
auth_uri: 'bar',
token_uri: 'bar',
auth_provider_x509_cert_url: 'bar',
client_x509_cert_url: 'bar',
},
});
console.log(dialogflowConnection.data);Returns: (string), (string), (string), (string), (string)
connection_idconversation_profile_idenvironmentrecord_typeservice_accountUpdate stored Dialogflow Connection
Updates a stored Dialogflow Connection.
PUT /dialogflow_connections/{connection_id}javascript
const dialogflowConnection = await client.dialogflowConnections.update('connection_id', {
service_account: {
type: 'bar',
project_id: 'bar',
private_key_id: 'bar',
private_key: 'bar',
client_email: 'bar',
client_id: 'bar',
auth_uri: 'bar',
token_uri: 'bar',
auth_provider_x509_cert_url: 'bar',
client_x509_cert_url: 'bar',
},
});
console.log(dialogflowConnection.data);Returns: (string), (string), (string), (string), (string)
connection_idconversation_profile_idenvironmentrecord_typeservice_accountDelete stored Dialogflow Connection
Deletes a stored Dialogflow Connection.
DELETE /dialogflow_connections/{connection_id}javascript
await client.dialogflowConnections.delete('connection_id');List all External Connections
This endpoint returns a list of your External Connections inside the 'data' attribute of the response. External Connections are used by Telnyx customers to seamless configure SIP trunking integrations with Telnyx Partners, through External Voice Integrations in Mission Control Portal.
GET /external_connectionsjavascript
// Automatically fetches more pages as needed.
for await (const externalConnection of client.externalConnections.list()) {
console.log(externalConnection.id);
}Returns: (boolean), (string), (boolean), (enum: zoom, operator_connect), (string), (object), (object), (string), (array[string]), (string), (enum: 1, 2), (uri), (uri), (integer | null)
activecreated_atcredential_activeexternal_sip_connectionidinboundoutboundrecord_typetagsupdated_atwebhook_api_versionwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsCreates an External Connection
Creates a new External Connection based on the parameters sent in the request. The external_sip_connection and outbound voice profile id are required. Once created, you can assign phone numbers to your application using the endpoint.
/phone_numbersPOST /external_connectionsexternal_sip_connectionoutboundOptional: (boolean), (object), (array[string]), (uri), (uri), (integer | null)
activeinboundtagswebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsjavascript
const externalConnection = await client.externalConnections.create({
external_sip_connection: 'zoom',
outbound: {},
});
console.log(externalConnection.data);Returns: (boolean), (string), (boolean), (enum: zoom, operator_connect), (string), (object), (object), (string), (array[string]), (string), (enum: 1, 2), (uri), (uri), (integer | null)
activecreated_atcredential_activeexternal_sip_connectionidinboundoutboundrecord_typetagsupdated_atwebhook_api_versionwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsList all log messages
Retrieve a list of log messages for all external connections associated with your account.
GET /external_connections/log_messagesjavascript
// Automatically fetches more pages as needed.
for await (const logMessageListResponse of client.externalConnections.logMessages.list()) {
console.log(logMessageListResponse.code);
}Returns: (array[object]), (object)
log_messagesmetaRetrieve a log message
Retrieve a log message for an external connection associated with your account.
GET /external_connections/log_messages/{id}javascript
const logMessage = await client.externalConnections.logMessages.retrieve('1293384261075731499');
console.log(logMessage.log_messages);Returns: (array[object])
log_messagesDismiss a log message
Dismiss a log message for an external connection associated with your account.
DELETE /external_connections/log_messages/{id}javascript
const response = await client.externalConnections.logMessages.dismiss('1293384261075731499');
console.log(response.success);Returns: (boolean)
successRetrieve an External Connection
Return the details of an existing External Connection inside the 'data' attribute of the response.
GET /external_connections/{id}javascript
const externalConnection = await client.externalConnections.retrieve('1293384261075731499');
console.log(externalConnection.data);Returns: (boolean), (string), (boolean), (enum: zoom, operator_connect), (string), (object), (object), (string), (array[string]), (string), (enum: 1, 2), (uri), (uri), (integer | null)
activecreated_atcredential_activeexternal_sip_connectionidinboundoutboundrecord_typetagsupdated_atwebhook_api_versionwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsUpdate an External Connection
Updates settings of an existing External Connection based on the parameters of the request.
PATCH /external_connections/{id}outboundOptional: (boolean), (object), (array[string]), (uri), (uri), (integer | null)
activeinboundtagswebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsjavascript
const externalConnection = await client.externalConnections.update('1293384261075731499', {
outbound: { outbound_voice_profile_id: '1911630617284445511' },
});
console.log(externalConnection.data);Returns: (boolean), (string), (boolean), (enum: zoom, operator_connect), (string), (object), (object), (string), (array[string]), (string), (enum: 1, 2), (uri), (uri), (integer | null)
activecreated_atcredential_activeexternal_sip_connectionidinboundoutboundrecord_typetagsupdated_atwebhook_api_versionwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsDeletes an External Connection
Permanently deletes an External Connection. Deletion may be prevented if the application is in use by phone numbers, is active, or if it is an Operator Connect connection. To remove an Operator Connect integration please contact Telnyx support.
DELETE /external_connections/{id}javascript
const externalConnection = await client.externalConnections.delete('1293384261075731499');
console.log(externalConnection.data);Returns: (boolean), (string), (boolean), (enum: zoom, operator_connect), (string), (object), (object), (string), (array[string]), (string), (enum: 1, 2), (uri), (uri), (integer | null)
activecreated_atcredential_activeexternal_sip_connectionidinboundoutboundrecord_typetagsupdated_atwebhook_api_versionwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsList all civic addresses and locations
Returns the civic addresses and locations from Microsoft Teams.
GET /external_connections/{id}/civic_addressesjavascript
const civicAddresses = await client.externalConnections.civicAddresses.list('1293384261075731499');
console.log(civicAddresses.data);Returns: (string), (string), (string), (string), (string), (uuid), (string), (string), (string), (uuid), (array[object]), (string), (string), (string), (string), (string)
city_or_towncity_or_town_aliascompany_namecountrycountry_or_districtdefault_location_iddescriptionhouse_numberhouse_number_suffixidlocationspostal_or_zip_coderecord_typestate_or_provincestreet_namestreet_suffixRetrieve a Civic Address
Return the details of an existing Civic Address with its Locations inside the 'data' attribute of the response.
GET /external_connections/{id}/civic_addresses/{address_id}javascript
const civicAddress = await client.externalConnections.civicAddresses.retrieve(
'318fb664-d341-44d2-8405-e6bfb9ced6d9',
{ id: '1293384261075731499' },
);
console.log(civicAddress.data);Returns: (string), (string), (string), (string), (string), (uuid), (string), (string), (string), (uuid), (array[object]), (string), (string), (string), (string), (string)
city_or_towncity_or_town_aliascompany_namecountrycountry_or_districtdefault_location_iddescriptionhouse_numberhouse_number_suffixidlocationspostal_or_zip_coderecord_typestate_or_provincestreet_namestreet_suffixUpdate a location's static emergency address
PATCH /external_connections/{id}/locations/{location_id}static_emergency_address_idjavascript
const response = await client.externalConnections.updateLocation(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
{
id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
static_emergency_address_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
},
);
console.log(response.data);Returns: (boolean), (uuid), (uuid)
accepted_address_suggestionslocation_idstatic_emergency_address_idList all phone numbers
Returns a list of all active phone numbers associated with the given external connection.
GET /external_connections/{id}/phone_numbersjavascript
// Automatically fetches more pages as needed.
for await (const externalConnectionPhoneNumber of client.externalConnections.phoneNumbers.list(
'1293384261075731499',
)) {
console.log(externalConnectionPhoneNumber.civic_address_id);
}Returns: (array[string]), (uuid), (string), (uuid), (string), (string), (uuid)
acquired_capabilitiescivic_address_iddisplayed_country_codelocation_idnumber_idtelephone_numberticket_idRetrieve a phone number
Return the details of a phone number associated with the given external connection.
GET /external_connections/{id}/phone_numbers/{phone_number_id}javascript
const phoneNumber = await client.externalConnections.phoneNumbers.retrieve('1234567889', {
id: '1293384261075731499',
});
console.log(phoneNumber.data);Returns: (array[string]), (uuid), (string), (uuid), (string), (string), (uuid)
acquired_capabilitiescivic_address_iddisplayed_country_codelocation_idnumber_idtelephone_numberticket_idUpdate a phone number
Asynchronously update settings of the phone number associated with the given external connection.
PATCH /external_connections/{id}/phone_numbers/{phone_number_id}Optional: (uuid)
location_idjavascript
const phoneNumber = await client.externalConnections.phoneNumbers.update('1234567889', {
id: '1293384261075731499',
});
console.log(phoneNumber.data);Returns: (array[string]), (uuid), (string), (uuid), (string), (string), (uuid)
acquired_capabilitiescivic_address_iddisplayed_country_codelocation_idnumber_idtelephone_numberticket_idList all Releases
Returns a list of your Releases for the given external connection. These are automatically created when you change the of a phone number that is currently on Microsoft Teams.
connection_idGET /external_connections/{id}/releasesjavascript
// Automatically fetches more pages as needed.
for await (const releaseListResponse of client.externalConnections.releases.list(
'1293384261075731499',
)) {
console.log(releaseListResponse.tenant_id);
}Returns: (string), (string), (enum: pending_upload, pending, in_progress, complete, failed, expired, unknown), (array[object]), (uuid), (uuid)
created_aterror_messagestatustelephone_numberstenant_idticket_idRetrieve a Release request
Return the details of a Release request and its phone numbers.
GET /external_connections/{id}/releases/{release_id}javascript
const release = await client.externalConnections.releases.retrieve(
'7b6a6449-b055-45a6-81f6-f6f0dffa4cc6',
{ id: '1293384261075731499' },
);
console.log(release.data);Returns: (string), (string), (enum: pending_upload, pending, in_progress, complete, failed, expired, unknown), (array[object]), (uuid), (uuid)
created_aterror_messagestatustelephone_numberstenant_idticket_idList all Upload requests
Returns a list of your Upload requests for the given external connection.
GET /external_connections/{id}/uploadsjavascript
// Automatically fetches more pages as needed.
for await (const upload of client.externalConnections.uploads.list('1293384261075731499')) {
console.log(upload.location_id);
}Returns: (array[string]), (string), (string), (uuid), (enum: pending_upload, pending, in_progress, partial_success, success, error), (uuid), (uuid), (array[object])
available_usageserror_codeerror_messagelocation_idstatustenant_idticket_idtn_upload_entriesCreates an Upload request
Creates a new Upload request to Microsoft teams with the included phone numbers. Only one of civic_address_id or location_id must be provided, not both. The maximum allowed phone numbers for the numbers_ids array is 1000.
POST /external_connections/{id}/uploadsnumber_idsOptional: (array[string]), (uuid), (uuid), (enum: calling_user_assignment, first_party_app_assignment)
additional_usagescivic_address_idlocation_idusagejavascript
const upload = await client.externalConnections.uploads.create('1293384261075731499', {
number_ids: [
'3920457616934164700',
'3920457616934164701',
'3920457616934164702',
'3920457616934164703',
],
});
console.log(upload.ticket_id);Returns: (boolean), (uuid)
successticket_idRefresh the status of all Upload requests
Forces a recheck of the status of all pending Upload requests for the given external connection in the background.
POST /external_connections/{id}/uploads/refreshjavascript
const response = await client.externalConnections.uploads.refreshStatus('1293384261075731499');
console.log(response.success);Returns: (boolean)
successGet the count of pending upload requests
Returns the count of all pending upload requests for the given external connection.
GET /external_connections/{id}/uploads/statusjavascript
const response = await client.externalConnections.uploads.pendingCount('1293384261075731499');
console.log(response.data);Returns: (integer), (integer)
pending_numbers_countpending_orders_countRetrieve an Upload request
Return the details of an Upload request and its phone numbers.
GET /external_connections/{id}/uploads/{ticket_id}javascript
const upload = await client.externalConnections.uploads.retrieve(
'7b6a6449-b055-45a6-81f6-f6f0dffa4cc6',
{ id: '1293384261075731499' },
);
console.log(upload.data);Returns: (array[string]), (string), (string), (uuid), (enum: pending_upload, pending, in_progress, partial_success, success, error), (uuid), (uuid), (array[object])
available_usageserror_codeerror_messagelocation_idstatustenant_idticket_idtn_upload_entriesRetry an Upload request
If there were any errors during the upload process, this endpoint will retry the upload request. In some cases this will reattempt the existing upload request, in other cases it may create a new upload request. Please check the ticket_id in the response to determine if a new upload request was created.
POST /external_connections/{id}/uploads/{ticket_id}/retryjavascript
const response = await client.externalConnections.uploads.retry(
'7b6a6449-b055-45a6-81f6-f6f0dffa4cc6',
{ id: '1293384261075731499' },
);
console.log(response.data);Returns: (array[string]), (string), (string), (uuid), (enum: pending_upload, pending, in_progress, partial_success, success, error), (uuid), (uuid), (array[object])
available_usageserror_codeerror_messagelocation_idstatustenant_idticket_idtn_upload_entriesList uploaded media
Returns a list of stored media files.
GET /mediajavascript
const media = await client.media.list();
console.log(media.data);Returns: (string), (string), (string), (string), (string)
content_typecreated_atexpires_atmedia_nameupdated_atUpload media
Upload media file to Telnyx so it can be used with other Telnyx services
POST /mediamedia_urlOptional: (string), (integer)
media_namettl_secsjavascript
const response = await client.media.upload({ media_url: 'http://www.example.com/audio.mp3' });
console.log(response.data);Returns: (string), (string), (string), (string), (string)
content_typecreated_atexpires_atmedia_nameupdated_atRetrieve stored media
Returns the information about a stored media file.
GET /media/{media_name}javascript
const media = await client.media.retrieve('media_name');
console.log(media.data);Returns: (string), (string), (string), (string), (string)
content_typecreated_atexpires_atmedia_nameupdated_atUpdate stored media
Updates a stored media file.
PUT /media/{media_name}Optional: (string), (integer)
media_urlttl_secsjavascript
const media = await client.media.update('media_name');
console.log(media.data);Returns: (string), (string), (string), (string), (string)
content_typecreated_atexpires_atmedia_nameupdated_atDeletes stored media
Deletes a stored media file.
DELETE /media/{media_name}javascript
await client.media.delete('media_name');Download stored media
Downloads a stored media file.
GET /media/{media_name}/downloadjavascript
const response = await client.media.download('media_name');
console.log(response);
const content = await response.blob();
console.log(content);Refresh Operator Connect integration
This endpoint will make an asynchronous request to refresh the Operator Connect integration with Microsoft Teams for the current user. This will create new external connections on the user's account if needed, and/or report the integration results as log messages.
POST /operator_connect/actions/refreshjavascript
const response = await client.operatorConnect.actions.refresh();
console.log(response.message);Returns: (string), (boolean)
messagesuccessList all recording transcriptions
Returns a list of your recording transcriptions.
GET /recording_transcriptionsjavascript
// Automatically fetches more pages as needed.
for await (const recordingTranscription of client.recordingTranscriptions.list()) {
console.log(recordingTranscription.id);
}Returns: (string), (int32), (string), (enum: recording_transcription), (string), (enum: in-progress, completed), (string), (string)
created_atduration_millisidrecord_typerecording_idstatustranscription_textupdated_atRetrieve a recording transcription
Retrieves the details of an existing recording transcription.
GET /recording_transcriptions/{recording_transcription_id}javascript
const recordingTranscription = await client.recordingTranscriptions.retrieve(
'6a09cdc3-8948-47f0-aa62-74ac943d6c58',
);
console.log(recordingTranscription.data);Returns: (string), (int32), (string), (enum: recording_transcription), (string), (enum: in-progress, completed), (string), (string)
created_atduration_millisidrecord_typerecording_idstatustranscription_textupdated_atDelete a recording transcription
Permanently deletes a recording transcription.
DELETE /recording_transcriptions/{recording_transcription_id}javascript
const recordingTranscription = await client.recordingTranscriptions.delete(
'6a09cdc3-8948-47f0-aa62-74ac943d6c58',
);
console.log(recordingTranscription.data);Returns: (string), (int32), (string), (enum: recording_transcription), (string), (enum: in-progress, completed), (string), (string)
created_atduration_millisidrecord_typerecording_idstatustranscription_textupdated_atList all call recordings
Returns a list of your call recordings.
GET /recordingsjavascript
// Automatically fetches more pages as needed.
for await (const recordingResponseData of client.recordings.list()) {
console.log(recordingResponseData.id);
}Returns: (string), (string), (string), (enum: single, dual), (string), (string), (string), (object), (int32), (string), (string), (string), (enum: recording), (string), (string), (enum: conference, call), (enum: completed), (string), (string)
call_control_idcall_leg_idcall_session_idchannelsconference_idconnection_idcreated_atdownload_urlsduration_millisfromidinitiated_byrecord_typerecording_ended_atrecording_started_atsourcestatustoupdated_atDelete a list of call recordings
Permanently deletes a list of call recordings.
POST /recordings/actions/deletejavascript
const action = await client.recordings.actions.delete({
ids: ['428c31b6-7af4-4bcb-b7f5-5013ef9657c1', '428c31b6-7af4-4bcb-b7f5-5013ef9657c2'],
});
console.log(action.status);Returns: (enum: ok)
statusRetrieve a call recording
Retrieves the details of an existing call recording.
GET /recordings/{recording_id}javascript
const recording = await client.recordings.retrieve('recording_id');
console.log(recording.data);Returns: (string), (string), (string), (enum: single, dual), (string), (string), (string), (object), (int32), (string), (string), (string), (enum: recording), (string), (string), (enum: conference, call), (enum: completed), (string), (string)
call_control_idcall_leg_idcall_session_idchannelsconference_idconnection_idcreated_atdownload_urlsduration_millisfromidinitiated_byrecord_typerecording_ended_atrecording_started_atsourcestatustoupdated_atDelete a call recording
Permanently deletes a call recording.
DELETE /recordings/{recording_id}javascript
const recording = await client.recordings.delete('recording_id');
console.log(recording.data);Returns: (string), (string), (string), (enum: single, dual), (string), (string), (string), (object), (int32), (string), (string), (string), (enum: recording), (string), (string), (enum: conference, call), (enum: completed), (string), (string)
call_control_idcall_leg_idcall_session_idchannelsconference_idconnection_idcreated_atdownload_urlsduration_millisfromidinitiated_byrecord_typerecording_ended_atrecording_started_atsourcestatustoupdated_atCreate a SIPREC connector
Creates a new SIPREC connector configuration.
POST /siprec_connectorsjavascript
const siprecConnector = await client.siprecConnectors.create({
host: 'siprec.telnyx.com',
name: 'my-siprec-connector',
port: 5060,
});
console.log(siprecConnector.data);Returns: (string), (string), (string), (string), (integer), (string), (string)
app_subdomaincreated_athostnameportrecord_typeupdated_atRetrieve a SIPREC connector
Returns details of a stored SIPREC connector.
GET /siprec_connectors/{connector_name}javascript
const siprecConnector = await client.siprecConnectors.retrieve('connector_name');
console.log(siprecConnector.data);Returns: (string), (string), (string), (string), (integer), (string), (string)
app_subdomaincreated_athostnameportrecord_typeupdated_atUpdate a SIPREC connector
Updates a stored SIPREC connector configuration.
PUT /siprec_connectors/{connector_name}javascript
const siprecConnector = await client.siprecConnectors.update('connector_name', {
host: 'siprec.telnyx.com',
name: 'my-siprec-connector',
port: 5060,
});
console.log(siprecConnector.data);Returns: (string), (string), (string), (string), (integer), (string), (string)
app_subdomaincreated_athostnameportrecord_typeupdated_atDelete a SIPREC connector
Deletes a stored SIPREC connector.
DELETE /siprec_connectors/{connector_name}javascript
await client.siprecConnectors.delete('connector_name');