Loading...
Loading...
Make and receive calls, transfer, bridge, and manage call lifecycle with Call Control. Includes application management and call events. This skill provides Java SDK examples.
npx skill4agent add team-telnyx/telnyx-ext-agent-skills telnyx-voice-java// See https://github.com/team-telnyx/telnyx-java for Maven/Gradle setupimport com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
TelnyxClient client = TelnyxOkHttpClient.fromEnv();clientPOST /calls/{call_control_id}/actions/answerbilling_group_idclient_statecommand_idcustom_headerspreferred_codecsrecordrecord_channelsrecord_custom_file_namerecord_formatrecord_max_lengthrecord_timeout_secsrecord_trackrecord_trimsend_silence_when_idlesip_headerssound_modificationsstream_bidirectional_codecstream_bidirectional_modestream_bidirectional_target_legsstream_codecstream_trackstream_urltranscriptiontranscription_configwebhook_urlwebhook_url_methodimport com.telnyx.sdk.models.calls.actions.ActionAnswerParams;
import com.telnyx.sdk.models.calls.actions.ActionAnswerResponse;
ActionAnswerResponse response = client.calls().actions().answer("call_control_id");POST /calls/{call_control_id}/actions/bridgecall_control_idclient_statecommand_idmute_dtmfpark_after_unbridgeplay_ringtonequeuerecordrecord_channelsrecord_custom_file_namerecord_formatrecord_max_lengthrecord_timeout_secsrecord_trackrecord_trimringtonevideo_room_contextvideo_room_idimport com.telnyx.sdk.models.calls.actions.ActionBridgeParams;
import com.telnyx.sdk.models.calls.actions.ActionBridgeResponse;
ActionBridgeParams params = ActionBridgeParams.builder()
.callControlIdToBridge("call_control_id")
.callControlId("v3:MdI91X4lWFEs7IgbBEOT9M4AigoY08M0WWZFISt1Yw2axZ_IiE4pqg")
.build();
ActionBridgeResponse response = client.calls().actions().bridge(params);POST /callsconnection_idtofromanswering_machine_detectionanswering_machine_detection_configaudio_urlbilling_group_idbridge_intentbridge_on_answerclient_statecommand_idconference_configcustom_headersdialogflow_configenable_dialogflowfrom_display_namelink_tomedia_encryptionmedia_namepark_after_unbridgepreferred_codecsrecordrecord_channelsrecord_custom_file_namerecord_formatrecord_max_lengthrecord_timeout_secsrecord_trackrecord_trimsend_silence_when_idlesip_auth_passwordsip_auth_usernamesip_headerssip_regionsip_transport_protocolsound_modificationsstream_auth_tokenstream_bidirectional_codecstream_bidirectional_modestream_bidirectional_sampling_ratestream_bidirectional_target_legsstream_codecstream_establish_before_call_originatestream_trackstream_urlsupervise_call_control_idsupervisor_roletime_limit_secstimeout_secstranscriptiontranscription_configwebhook_urlwebhook_url_methodimport com.telnyx.sdk.models.calls.CallDialParams;
import com.telnyx.sdk.models.calls.CallDialResponse;
CallDialParams params = CallDialParams.builder()
.connectionId("7267xxxxxxxxxxxxxx")
.from("+18005550101")
.to("+18005550100")
.build();
CallDialResponse response = client.calls().dial(params);POST /calls/{call_control_id}/actions/hangupclient_statecommand_idimport com.telnyx.sdk.models.calls.actions.ActionHangupParams;
import com.telnyx.sdk.models.calls.actions.ActionHangupResponse;
ActionHangupResponse response = client.calls().actions().hangup("call_control_id");POST /calls/{call_control_id}/actions/transfertoanswering_machine_detectionanswering_machine_detection_configaudio_urlclient_statecommand_idcustom_headersearly_mediafromfrom_display_namemedia_encryptionmedia_namemute_dtmfpark_after_unbridgepreferred_codecsrecordrecord_channelsrecord_custom_file_namerecord_formatrecord_max_lengthrecord_timeout_secsrecord_trackrecord_trimsip_auth_passwordsip_auth_usernamesip_headerssip_regionsip_transport_protocolsound_modificationstarget_leg_client_statetime_limit_secstimeout_secswebhook_retries_policieswebhook_urlwebhook_url_methodwebhook_urlswebhook_urls_methodimport com.telnyx.sdk.models.calls.actions.ActionTransferParams;
import com.telnyx.sdk.models.calls.actions.ActionTransferResponse;
ActionTransferParams params = ActionTransferParams.builder()
.callControlId("call_control_id")
.to("+18005550100")
.build();
ActionTransferResponse response = client.calls().actions().transfer(params);GET /connections/{connection_id}/active_callsimport com.telnyx.sdk.models.connections.ConnectionListActiveCallsPage;
import com.telnyx.sdk.models.connections.ConnectionListActiveCallsParams;
ConnectionListActiveCallsPage page = client.connections().listActiveCalls("1293384261075731461");GET /call_control_applicationsimport com.telnyx.sdk.models.callcontrolapplications.CallControlApplicationListPage;
import com.telnyx.sdk.models.callcontrolapplications.CallControlApplicationListParams;
CallControlApplicationListPage page = client.callControlApplications().list();POST /call_control_applicationsapplication_namewebhook_event_urlactiveanchorsite_overridecall_cost_in_webhooksdtmf_typefirst_command_timeoutfirst_command_timeout_secsinboundoutboundredact_dtmf_debug_loggingwebhook_api_versionwebhook_event_failover_urlwebhook_timeout_secsimport com.telnyx.sdk.models.callcontrolapplications.CallControlApplicationCreateParams;
import com.telnyx.sdk.models.callcontrolapplications.CallControlApplicationCreateResponse;
CallControlApplicationCreateParams params = CallControlApplicationCreateParams.builder()
.applicationName("call-router")
.webhookEventUrl("https://example.com")
.build();
CallControlApplicationCreateResponse callControlApplication = client.callControlApplications().create(params);GET /call_control_applications/{id}import com.telnyx.sdk.models.callcontrolapplications.CallControlApplicationRetrieveParams;
import com.telnyx.sdk.models.callcontrolapplications.CallControlApplicationRetrieveResponse;
CallControlApplicationRetrieveResponse callControlApplication = client.callControlApplications().retrieve("1293384261075731499");PATCH /call_control_applications/{id}application_namewebhook_event_urlactiveanchorsite_overridecall_cost_in_webhooksdtmf_typefirst_command_timeoutfirst_command_timeout_secsinboundoutboundredact_dtmf_debug_loggingtagswebhook_api_versionwebhook_event_failover_urlwebhook_timeout_secsimport com.telnyx.sdk.models.callcontrolapplications.CallControlApplicationUpdateParams;
import com.telnyx.sdk.models.callcontrolapplications.CallControlApplicationUpdateResponse;
CallControlApplicationUpdateParams params = CallControlApplicationUpdateParams.builder()
.id("1293384261075731499")
.applicationName("call-router")
.webhookEventUrl("https://example.com")
.build();
CallControlApplicationUpdateResponse callControlApplication = client.callControlApplications().update(params);DELETE /call_control_applications/{id}import com.telnyx.sdk.models.callcontrolapplications.CallControlApplicationDeleteParams;
import com.telnyx.sdk.models.callcontrolapplications.CallControlApplicationDeleteResponse;
CallControlApplicationDeleteResponse callControlApplication = client.callControlApplications().delete("1293384261075731499");GET /call_eventsimport com.telnyx.sdk.models.callevents.CallEventListPage;
import com.telnyx.sdk.models.callevents.CallEventListParams;
CallEventListPage page = client.callEvents().list();telnyx-timestamptelnyx-signature-ed25519| Event | Description |
|---|---|
| Call Answered |
| Call Streaming Started |
| Call Streaming Stopped |
| Call Streaming Failed |
| Call Bridged |
| Call Initiated |
| Call Hangup |
| Call Recording Saved |
| Call Machine Detection Ended |
| Call Machine Greeting Ended |
| Call Machine Premium Detection Ended |
| Call Machine Premium Greeting Ended |
callAnswered| Field | Type | Description |
|---|---|---|
| enum | Identifies the type of the resource. |
| enum | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | Call ID used to issue commands via Call Control API. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | State received from a command. |
| array[object] | Custom headers set on answer command |
| array[object] | User-to-User and Diversion headers from sip invite. |
| string | Number or SIP URI placing the call. |
| string | Destination number or SIP URI of the call. |
| date-time | ISO 8601 datetime of when the call started. |
| enum | State received from a command. |
| array[string] | Array of tags associated to number. |
callStreamingStarted| Field | Type | Description |
|---|---|---|
| enum | Identifies the type of the resource. |
| enum | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | Call ID used to issue commands via Call Control API. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | State received from a command. |
| string | Destination WebSocket address where the stream is going to be delivered. |
callStreamingStopped| Field | Type | Description |
|---|---|---|
| enum | Identifies the type of the resource. |
| enum | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | Call ID used to issue commands via Call Control API. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | State received from a command. |
| string | Destination WebSocket address where the stream is going to be delivered. |
callStreamingFailed| Field | Type | Description |
|---|---|---|
| enum | Identifies the resource. |
| enum | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | Call ID used to issue commands via Call Control API. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | State received from a command. |
| string | A short description explaning why the media streaming failed. |
| uuid | Identifies the streaming. |
| enum | The type of stream connection the stream is performing. |
callBridged| Field | Type | Description |
|---|---|---|
| enum | Identifies the type of the resource. |
| enum | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | Call ID used to issue commands via Call Control API. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | State received from a command. |
| string | Number or SIP URI placing the call. |
| string | Destination number or SIP URI of the call. |
callInitiated| Field | Type | Description |
|---|---|---|
| enum | Identifies the type of the resource. |
| enum | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | Call ID used to issue commands via Call Control API. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | The list of comma-separated codecs enabled for the connection. |
| string | The list of comma-separated codecs offered by caller. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| array[object] | Custom headers from sip invite |
| array[object] | User-to-User and Diversion headers from sip invite. |
| string | SHAKEN/STIR attestation level. |
| boolean | Whether attestation was successfully validated or not. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | State received from a command. |
| string | Caller id. |
| string | Call screening result. |
| string | Number or SIP URI placing the call. |
| string | Destination number or SIP URI of the call. |
| enum | Whether the call is |
| enum | State received from a command. |
| date-time | ISO 8601 datetime of when the call started. |
| array[string] | Array of tags associated to number. |
callHangup| Field | Type | Description |
|---|---|---|
| enum | Identifies the type of the resource. |
| enum | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | Call ID used to issue commands via Call Control API. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | State received from a command. |
| array[object] | Custom headers set on answer command |
| array[object] | User-to-User and Diversion headers from sip invite. |
| string | Number or SIP URI placing the call. |
| string | Destination number or SIP URI of the call. |
| date-time | ISO 8601 datetime of when the call started. |
| enum | State received from a command. |
| array[string] | Array of tags associated to number. |
| enum | The reason the call was ended ( |
| enum | The party who ended the call ( |
| string | The reason the call was ended (SIP response code). |
| ['object', 'null'] | Call quality statistics aggregated from the CHANNEL_HANGUP_COMPLETE event. |
callRecordingSaved| Field | Type | Description |
|---|---|---|
| enum | Identifies the type of the resource. |
| enum | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | State received from a command. |
| date-time | ISO 8601 datetime of when recording started. |
| date-time | ISO 8601 datetime of when recording ended. |
| enum | Whether recording was recorded in |
callMachineDetectionEnded| Field | Type | Description |
|---|---|---|
| enum | Identifies the type of the resource. |
| enum | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | Call ID used to issue commands via Call Control API. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | State received from a command. |
| string | Number or SIP URI placing the call. |
| string | Destination number or SIP URI of the call. |
| enum | Answering machine detection result. |
callMachineGreetingEnded| Field | Type | Description |
|---|---|---|
| enum | Identifies the type of the resource. |
| enum | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | Call ID used to issue commands via Call Control API. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | State received from a command. |
| string | Number or SIP URI placing the call. |
| string | Destination number or SIP URI of the call. |
| enum | Answering machine greeting ended result. |
callMachinePremiumDetectionEnded| Field | Type | Description |
|---|---|---|
| enum | Identifies the type of the resource. |
| enum | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | Call ID used to issue commands via Call Control API. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | State received from a command. |
| string | Number or SIP URI placing the call. |
| string | Destination number or SIP URI of the call. |
| enum | Premium Answering Machine Detection result. |
callMachinePremiumGreetingEnded| Field | Type | Description |
|---|---|---|
| enum | Identifies the type of the resource. |
| enum | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | Call ID used to issue commands via Call Control API. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | State received from a command. |
| string | Number or SIP URI placing the call. |
| string | Destination number or SIP URI of the call. |
| enum | Premium Answering Machine Greeting Ended result. |