Loading...
Loading...
Configure SIP trunking connections and outbound voice profiles. Use when connecting PBX systems or managing SIP infrastructure. This skill provides JavaScript SDK examples.
npx skill4agent add team-telnyx/skills telnyx-sip-javascriptnpm install telnyximport Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});clienttry {
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');
}
}
}401403404422429for await (const item of result) { ... }GET /access_ip_ranges// Automatically fetches more pages as needed.
for await (const accessIPRange of client.accessIPRanges.list()) {
console.log(accessIPRange.id);
}cidr_blockcreated_atdescriptionidstatusupdated_atuser_idPOST /access_ip_rangescidr_blockdescriptionconst accessIPRange = await client.accessIPRanges.create({ cidr_block: 'cidr_block' });
console.log(accessIPRange.id);cidr_blockcreated_atdescriptionidstatusupdated_atuser_idDELETE /access_ip_ranges/{access_ip_range_id}const accessIPRange = await client.accessIPRanges.delete('550e8400-e29b-41d4-a716-446655440000');
console.log(accessIPRange.id);cidr_blockcreated_atdescriptionidstatusupdated_atuser_idGET /connections// Automatically fetches more pages as needed.
for await (const connectionListResponse of client.connections.list()) {
console.log(connectionListResponse.id);
}activeanchorsite_overrideconnection_namecreated_atidoutbound_voice_profile_idrecord_typetagsupdated_atwebhook_api_versionwebhook_event_failover_urlwebhook_event_urlGET /connections/{id}const connection = await client.connections.retrieve('550e8400-e29b-41d4-a716-446655440000');
console.log(connection.data);activeanchorsite_overrideconnection_namecreated_atidoutbound_voice_profile_idrecord_typetagsupdated_atwebhook_api_versionwebhook_event_failover_urlwebhook_event_urlGET /credential_connections// Automatically fetches more pages as needed.
for await (const credentialConnection of client.credentialConnections.list()) {
console.log(credentialConnection.id);
}activeanchorsite_overrideandroid_push_credential_idcall_cost_in_webhooksconnection_namecreated_atdefault_on_hold_comfort_noise_enableddtmf_typeencode_contact_header_enabledencrypted_mediaidinboundios_push_credential_idjitter_buffernoise_suppressionnoise_suppression_detailsonnet_t38_passthrough_enabledoutboundpasswordrecord_typertcp_settingssip_uri_calling_preferencetagsupdated_atuser_namewebhook_api_versionwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsPOST /credential_connectionsuser_namepasswordconnection_nameactiveanchorsite_overrideandroid_push_credential_idcall_cost_in_webhooksdefault_on_hold_comfort_noise_enableddtmf_typeencode_contact_header_enabledencrypted_mediainboundios_push_credential_idjitter_buffernoise_suppressionnoise_suppression_detailsonnet_t38_passthrough_enabledoutboundrtcp_settingssip_uri_calling_preferencetagswebhook_api_versionwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsconst credentialConnection = await client.credentialConnections.create({
connection_name: 'my name',
password: 'my123secure456password789',
user_name: 'myusername123',
});
console.log(credentialConnection.data);activeanchorsite_overrideandroid_push_credential_idcall_cost_in_webhooksconnection_namecreated_atdefault_on_hold_comfort_noise_enableddtmf_typeencode_contact_header_enabledencrypted_mediaidinboundios_push_credential_idjitter_buffernoise_suppressionnoise_suppression_detailsonnet_t38_passthrough_enabledoutboundpasswordrecord_typertcp_settingssip_uri_calling_preferencetagsupdated_atuser_namewebhook_api_versionwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsGET /credential_connections/{id}const credentialConnection = await client.credentialConnections.retrieve('550e8400-e29b-41d4-a716-446655440000');
console.log(credentialConnection.data);activeanchorsite_overrideandroid_push_credential_idcall_cost_in_webhooksconnection_namecreated_atdefault_on_hold_comfort_noise_enableddtmf_typeencode_contact_header_enabledencrypted_mediaidinboundios_push_credential_idjitter_buffernoise_suppressionnoise_suppression_detailsonnet_t38_passthrough_enabledoutboundpasswordrecord_typertcp_settingssip_uri_calling_preferencetagsupdated_atuser_namewebhook_api_versionwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsPATCH /credential_connections/{id}activeanchorsite_overrideandroid_push_credential_idcall_cost_in_webhooksconnection_namedefault_on_hold_comfort_noise_enableddtmf_typeencode_contact_header_enabledencrypted_mediainboundios_push_credential_idjitter_buffernoise_suppressionnoise_suppression_detailsonnet_t38_passthrough_enabledoutboundpasswordrtcp_settingssip_uri_calling_preferencetagsuser_namewebhook_api_versionwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsconst credentialConnection = await client.credentialConnections.update('550e8400-e29b-41d4-a716-446655440000');
console.log(credentialConnection.data);activeanchorsite_overrideandroid_push_credential_idcall_cost_in_webhooksconnection_namecreated_atdefault_on_hold_comfort_noise_enableddtmf_typeencode_contact_header_enabledencrypted_mediaidinboundios_push_credential_idjitter_buffernoise_suppressionnoise_suppression_detailsonnet_t38_passthrough_enabledoutboundpasswordrecord_typertcp_settingssip_uri_calling_preferencetagsupdated_atuser_namewebhook_api_versionwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsDELETE /credential_connections/{id}const credentialConnection = await client.credentialConnections.delete('550e8400-e29b-41d4-a716-446655440000');
console.log(credentialConnection.data);activeanchorsite_overrideandroid_push_credential_idcall_cost_in_webhooksconnection_namecreated_atdefault_on_hold_comfort_noise_enableddtmf_typeencode_contact_header_enabledencrypted_mediaidinboundios_push_credential_idjitter_buffernoise_suppressionnoise_suppression_detailsonnet_t38_passthrough_enabledoutboundpasswordrecord_typertcp_settingssip_uri_calling_preferencetagsupdated_atuser_namewebhook_api_versionwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsregistration_statusregistration_status_updated_atPOST /credential_connections/{id}/actions/check_registration_statusconst response = await client.credentialConnections.actions.checkRegistrationStatus('550e8400-e29b-41d4-a716-446655440000');
console.log(response.data);ip_addresslast_registrationportrecord_typesip_usernamestatustransportuser_agentGET /fqdn_connections// Automatically fetches more pages as needed.
for await (const fqdnConnection of client.fqdnConnections.list()) {
console.log(fqdnConnection.id);
}activeadjust_dtmf_timestampanchorsite_overrideandroid_push_credential_idcall_cost_enabledcall_cost_in_webhooksconnection_namecreated_atdefault_on_hold_comfort_noise_enableddtmf_typeencode_contact_header_enabledencrypted_mediaidignore_dtmf_durationignore_mark_bitinboundios_push_credential_idjitter_buffermicrosoft_teams_sbcnoise_suppressionnoise_suppression_detailsonnet_t38_passthrough_enabledoutboundpasswordrecord_typertcp_settingsrtp_pass_codecs_on_stream_changesend_normalized_timestampstagsthird_party_control_enabledtransport_protocoltxt_nametxt_ttltxt_valueupdated_atuser_namewebhook_api_versionwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsPOST /fqdn_connectionsconnection_nameactiveanchorsite_overrideandroid_push_credential_idcall_cost_in_webhooksdefault_on_hold_comfort_noise_enableddtmf_typeencode_contact_header_enabledencrypted_mediainboundios_push_credential_idjitter_buffermicrosoft_teams_sbcnoise_suppressionnoise_suppression_detailsonnet_t38_passthrough_enabledoutboundrtcp_settingstagstransport_protocolwebhook_api_versionwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsconst fqdnConnection = await client.fqdnConnections.create({ connection_name: 'my-resource' });
console.log(fqdnConnection.data);activeadjust_dtmf_timestampanchorsite_overrideandroid_push_credential_idcall_cost_enabledcall_cost_in_webhooksconnection_namecreated_atdefault_on_hold_comfort_noise_enableddtmf_typeencode_contact_header_enabledencrypted_mediaidignore_dtmf_durationignore_mark_bitinboundios_push_credential_idjitter_buffermicrosoft_teams_sbcnoise_suppressionnoise_suppression_detailsonnet_t38_passthrough_enabledoutboundpasswordrecord_typertcp_settingsrtp_pass_codecs_on_stream_changesend_normalized_timestampstagsthird_party_control_enabledtransport_protocoltxt_nametxt_ttltxt_valueupdated_atuser_namewebhook_api_versionwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsGET /fqdn_connections/{id}const fqdnConnection = await client.fqdnConnections.retrieve('1293384261075731499');
console.log(fqdnConnection.data);activeadjust_dtmf_timestampanchorsite_overrideandroid_push_credential_idcall_cost_enabledcall_cost_in_webhooksconnection_namecreated_atdefault_on_hold_comfort_noise_enableddtmf_typeencode_contact_header_enabledencrypted_mediaidignore_dtmf_durationignore_mark_bitinboundios_push_credential_idjitter_buffermicrosoft_teams_sbcnoise_suppressionnoise_suppression_detailsonnet_t38_passthrough_enabledoutboundpasswordrecord_typertcp_settingsrtp_pass_codecs_on_stream_changesend_normalized_timestampstagsthird_party_control_enabledtransport_protocoltxt_nametxt_ttltxt_valueupdated_atuser_namewebhook_api_versionwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsPATCH /fqdn_connections/{id}activeanchorsite_overrideandroid_push_credential_idcall_cost_in_webhooksconnection_namedefault_on_hold_comfort_noise_enableddtmf_typeencode_contact_header_enabledencrypted_mediainboundios_push_credential_idjitter_buffernoise_suppressionnoise_suppression_detailsonnet_t38_passthrough_enabledoutboundrtcp_settingstagstransport_protocolwebhook_api_versionwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsconst fqdnConnection = await client.fqdnConnections.update('1293384261075731499');
console.log(fqdnConnection.data);activeadjust_dtmf_timestampanchorsite_overrideandroid_push_credential_idcall_cost_enabledcall_cost_in_webhooksconnection_namecreated_atdefault_on_hold_comfort_noise_enableddtmf_typeencode_contact_header_enabledencrypted_mediaidignore_dtmf_durationignore_mark_bitinboundios_push_credential_idjitter_buffermicrosoft_teams_sbcnoise_suppressionnoise_suppression_detailsonnet_t38_passthrough_enabledoutboundpasswordrecord_typertcp_settingsrtp_pass_codecs_on_stream_changesend_normalized_timestampstagsthird_party_control_enabledtransport_protocoltxt_nametxt_ttltxt_valueupdated_atuser_namewebhook_api_versionwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsDELETE /fqdn_connections/{id}const fqdnConnection = await client.fqdnConnections.delete('1293384261075731499');
console.log(fqdnConnection.data);activeadjust_dtmf_timestampanchorsite_overrideandroid_push_credential_idcall_cost_enabledcall_cost_in_webhooksconnection_namecreated_atdefault_on_hold_comfort_noise_enableddtmf_typeencode_contact_header_enabledencrypted_mediaidignore_dtmf_durationignore_mark_bitinboundios_push_credential_idjitter_buffermicrosoft_teams_sbcnoise_suppressionnoise_suppression_detailsonnet_t38_passthrough_enabledoutboundpasswordrecord_typertcp_settingsrtp_pass_codecs_on_stream_changesend_normalized_timestampstagsthird_party_control_enabledtransport_protocoltxt_nametxt_ttltxt_valueupdated_atuser_namewebhook_api_versionwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsGET /fqdns// Automatically fetches more pages as needed.
for await (const fqdn of client.fqdns.list()) {
console.log(fqdn.id);
}connection_idcreated_atdns_record_typefqdnidportrecord_typeupdated_atPOST /fqdnsfqdndns_record_typeconnection_idportconst fqdn = await client.fqdns.create({
connection_id: '1516447646313612565',
dns_record_type: 'a',
fqdn: 'example.com',
});
console.log(fqdn.data);connection_idcreated_atdns_record_typefqdnidportrecord_typeupdated_atGET /fqdns/{id}const fqdn = await client.fqdns.retrieve('1517907029795014409');
console.log(fqdn.data);connection_idcreated_atdns_record_typefqdnidportrecord_typeupdated_atPATCH /fqdns/{id}connection_iddns_record_typefqdnportconst fqdn = await client.fqdns.update('1517907029795014409');
console.log(fqdn.data);connection_idcreated_atdns_record_typefqdnidportrecord_typeupdated_atDELETE /fqdns/{id}const fqdn = await client.fqdns.delete('1517907029795014409');
console.log(fqdn.data);connection_idcreated_atdns_record_typefqdnidportrecord_typeupdated_atGET /ip_connections// Automatically fetches more pages as needed.
for await (const ipConnection of client.ipConnections.list()) {
console.log(ipConnection.id);
}activeanchorsite_overrideandroid_push_credential_idcall_cost_in_webhooksconnection_namecreated_atdefault_on_hold_comfort_noise_enableddtmf_typeencode_contact_header_enabledencrypted_mediaidinboundios_push_credential_idjitter_buffernoise_suppressionnoise_suppression_detailsonnet_t38_passthrough_enabledoutboundrecord_typertcp_settingstagstransport_protocolupdated_atwebhook_api_versionwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsPOST /ip_connectionsactiveanchorsite_overrideandroid_push_credential_idcall_cost_in_webhooksconnection_namedefault_on_hold_comfort_noise_enableddtmf_typeencode_contact_header_enabledencrypted_mediainboundios_push_credential_idjitter_buffernoise_suppressionnoise_suppression_detailsonnet_t38_passthrough_enabledoutboundrtcp_settingstagstransport_protocolwebhook_api_versionwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsconst ipConnection = await client.ipConnections.create({
connectionName: 'my-ip-connection',
});
console.log(ipConnection.data);activeanchorsite_overrideandroid_push_credential_idcall_cost_in_webhooksconnection_namecreated_atdefault_on_hold_comfort_noise_enableddtmf_typeencode_contact_header_enabledencrypted_mediaidinboundios_push_credential_idjitter_buffernoise_suppressionnoise_suppression_detailsonnet_t38_passthrough_enabledoutboundrecord_typertcp_settingstagstransport_protocolupdated_atwebhook_api_versionwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsGET /ip_connections/{id}const ipConnection = await client.ipConnections.retrieve('550e8400-e29b-41d4-a716-446655440000');
console.log(ipConnection.data);activeanchorsite_overrideandroid_push_credential_idcall_cost_in_webhooksconnection_namecreated_atdefault_on_hold_comfort_noise_enableddtmf_typeencode_contact_header_enabledencrypted_mediaidinboundios_push_credential_idjitter_buffernoise_suppressionnoise_suppression_detailsonnet_t38_passthrough_enabledoutboundrecord_typertcp_settingstagstransport_protocolupdated_atwebhook_api_versionwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsPATCH /ip_connections/{id}activeanchorsite_overrideandroid_push_credential_idcall_cost_in_webhooksconnection_namedefault_on_hold_comfort_noise_enableddtmf_typeencode_contact_header_enabledencrypted_mediainboundios_push_credential_idjitter_buffernoise_suppressionnoise_suppression_detailsonnet_t38_passthrough_enabledoutboundrtcp_settingstagstransport_protocolwebhook_api_versionwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsconst ipConnection = await client.ipConnections.update('550e8400-e29b-41d4-a716-446655440000');
console.log(ipConnection.data);activeanchorsite_overrideandroid_push_credential_idcall_cost_in_webhooksconnection_namecreated_atdefault_on_hold_comfort_noise_enableddtmf_typeencode_contact_header_enabledencrypted_mediaidinboundios_push_credential_idjitter_buffernoise_suppressionnoise_suppression_detailsonnet_t38_passthrough_enabledoutboundrecord_typertcp_settingstagstransport_protocolupdated_atwebhook_api_versionwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsDELETE /ip_connections/{id}const ipConnection = await client.ipConnections.delete('550e8400-e29b-41d4-a716-446655440000');
console.log(ipConnection.data);activeanchorsite_overrideandroid_push_credential_idcall_cost_in_webhooksconnection_namecreated_atdefault_on_hold_comfort_noise_enableddtmf_typeencode_contact_header_enabledencrypted_mediaidinboundios_push_credential_idjitter_buffernoise_suppressionnoise_suppression_detailsonnet_t38_passthrough_enabledoutboundrecord_typertcp_settingstagstransport_protocolupdated_atwebhook_api_versionwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsGET /ips// Automatically fetches more pages as needed.
for await (const ip of client.ips.list()) {
console.log(ip.id);
}connection_idcreated_atidip_addressportrecord_typeupdated_atPOST /ipsip_addressconnection_idportconst ip = await client.ips.create({ ip_address: '192.168.0.0' });
console.log(ip.data);connection_idcreated_atidip_addressportrecord_typeupdated_atGET /ips/{id}const ip = await client.ips.retrieve('6a09cdc3-8948-47f0-aa62-74ac943d6c58');
console.log(ip.data);connection_idcreated_atidip_addressportrecord_typeupdated_atPATCH /ips/{id}ip_addressconnection_idportconst ip = await client.ips.update('6a09cdc3-8948-47f0-aa62-74ac943d6c58', {
ip_address: '192.168.0.0',
});
console.log(ip.data);connection_idcreated_atidip_addressportrecord_typeupdated_atDELETE /ips/{id}const ip = await client.ips.delete('6a09cdc3-8948-47f0-aa62-74ac943d6c58');
console.log(ip.data);connection_idcreated_atidip_addressportrecord_typeupdated_atGET /outbound_voice_profiles// Automatically fetches more pages as needed.
for await (const outboundVoiceProfile of client.outboundVoiceProfiles.list()) {
console.log(outboundVoiceProfile.id);
}billing_group_idcall_recordingcalling_windowconcurrent_call_limitconnections_countcreated_atdaily_spend_limitdaily_spend_limit_enabledenabledidmax_destination_ratenamerecord_typeservice_plantagstraffic_typeupdated_atusage_payment_methodwhitelisted_destinationsPOST /outbound_voice_profilesnamebilling_group_idcall_recordingcalling_windowconcurrent_call_limitdaily_spend_limitdaily_spend_limit_enabledenabledmax_destination_rateservice_plantagstraffic_typeusage_payment_methodwhitelisted_destinationsconst outboundVoiceProfile = await client.outboundVoiceProfiles.create({ name: 'office' });
console.log(outboundVoiceProfile.data);billing_group_idcall_recordingcalling_windowconcurrent_call_limitconnections_countcreated_atdaily_spend_limitdaily_spend_limit_enabledenabledidmax_destination_ratenamerecord_typeservice_plantagstraffic_typeupdated_atusage_payment_methodwhitelisted_destinationsGET /outbound_voice_profiles/{id}const outboundVoiceProfile = await client.outboundVoiceProfiles.retrieve('1293384261075731499');
console.log(outboundVoiceProfile.data);billing_group_idcall_recordingcalling_windowconcurrent_call_limitconnections_countcreated_atdaily_spend_limitdaily_spend_limit_enabledenabledidmax_destination_ratenamerecord_typeservice_plantagstraffic_typeupdated_atusage_payment_methodwhitelisted_destinationsPATCH /outbound_voice_profiles/{id}namebilling_group_idcall_recordingcalling_windowconcurrent_call_limitdaily_spend_limitdaily_spend_limit_enabledenabledmax_destination_rateservice_plantagstraffic_typeusage_payment_methodwhitelisted_destinationsconst outboundVoiceProfile = await client.outboundVoiceProfiles.update('1293384261075731499', {
name: 'office',
});
console.log(outboundVoiceProfile.data);billing_group_idcall_recordingcalling_windowconcurrent_call_limitconnections_countcreated_atdaily_spend_limitdaily_spend_limit_enabledenabledidmax_destination_ratenamerecord_typeservice_plantagstraffic_typeupdated_atusage_payment_methodwhitelisted_destinationsDELETE /outbound_voice_profiles/{id}const outboundVoiceProfile = await client.outboundVoiceProfiles.delete('1293384261075731499');
console.log(outboundVoiceProfile.data);billing_group_idcall_recordingcalling_windowconcurrent_call_limitconnections_countcreated_atdaily_spend_limitdaily_spend_limit_enabledenabledidmax_destination_ratenamerecord_typeservice_plantagstraffic_typeupdated_atusage_payment_methodwhitelisted_destinations