Loading...
Loading...
Compare original and translation side by side
<!-- Maven -->
<dependency>
<groupId>com.telnyx.sdk</groupId>
<artifactId>telnyx</artifactId>
<version>6.36.0</version>
</dependency>
// Gradle
implementation("com.telnyx.sdk:telnyx:6.36.0")<!-- Maven -->
<dependency>
<groupId>com.telnyx.sdk</groupId>
<artifactId>telnyx</artifactId>
<version>6.36.0</version>
</dependency>
// Gradle
implementation("com.telnyx.sdk:telnyx:6.36.0")import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
TelnyxClient client = TelnyxOkHttpClient.fromEnv();clientimport com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
TelnyxClient client = TelnyxOkHttpClient.fromEnv();clientimport 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);401403404422429import 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);401403404422429+13125550001+.autoPager()for (var item : page.autoPager()) { ... }.hasNextPage().nextPage()+13125550001+.autoPager()for (var item : page.autoPager()) { ... }.hasNextPage().nextPage()dial()call_control_iddial()dial()call_control_iddial()## Additional Operations## 额外操作client.calls().dial()POST /calls| Parameter | Type | Required | Description |
|---|---|---|---|
| string (E.164) | Yes | The DID or SIP URI to dial out to. |
| string (E.164) | Yes | The |
| string (UUID) | Yes | The ID of the Call Control App (formerly ID of the connectio... |
| integer | No | The number of seconds that Telnyx will wait for the call to ... |
| string (UUID) | No | Use this field to set the Billing Group ID for the call. |
| string | No | Use this field to add state to every subsequent webhook. |
| ... | +48 optional params in references/api-details.md |
import 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);response.data.callControlIdresponse.data.callLegIdresponse.data.callSessionIdresponse.data.isAliveresponse.data.recordingIdresponse.data.callDurationclient.calls().dial()POST /calls| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| string (E.164) | 是 | 要拨打的DID或SIP URI |
| string (E.164) | 是 | 向被叫展示的主叫来电号码 |
| string (UUID) | 是 | 呼叫控制应用的ID(原连接ID) |
| integer | 否 | Telnyx等待呼叫接通的最大秒数 |
| string (UUID) | 否 | 用于设置该通话的计费组ID |
| string | 否 | 用于向后续所有webhook添加自定义状态 |
| ... | 其余48个可选参数见references/api-details.md |
import 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);response.data.callControlIdresponse.data.callLegIdresponse.data.callSessionIdresponse.data.isAliveresponse.data.recordingIdresponse.data.callDurationclient.calls().actions().answer()POST /calls/{call_control_id}/actions/answer| Parameter | Type | Required | Description |
|---|---|---|---|
| string (UUID) | Yes | Unique identifier and token for controlling the call |
| string (UUID) | No | Use this field to set the Billing Group ID for the call. |
| string | No | Use this field to add state to every subsequent webhook. |
| string (URL) | No | Use this field to override the URL for which Telnyx will sen... |
| ... | +26 optional params in references/api-details.md |
import com.telnyx.sdk.models.calls.actions.ActionAnswerParams;
import com.telnyx.sdk.models.calls.actions.ActionAnswerResponse;
ActionAnswerResponse response = client.calls().actions().answer("v3:550e8400-e29b-41d4-a716-446655440000_gRU1OGRkYQ");response.data.resultresponse.data.recordingIdclient.calls().actions().answer()POST /calls/{call_control_id}/actions/answer| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| string (UUID) | 是 | 用于控制呼叫的唯一标识符和令牌 |
| string (UUID) | 否 | 用于设置该通话的计费组ID |
| string | 否 | 用于向后续所有webhook添加自定义状态 |
| string (URL) | 否 | 用于覆盖Telnyx发送事件的默认webhook地址 |
| ... | 其余26个可选参数见references/api-details.md |
import com.telnyx.sdk.models.calls.actions.ActionAnswerParams;
import com.telnyx.sdk.models.calls.actions.ActionAnswerResponse;
ActionAnswerResponse response = client.calls().actions().answer("v3:550e8400-e29b-41d4-a716-446655440000_gRU1OGRkYQ");response.data.resultresponse.data.recordingIdclient.calls().actions().transfer()POST /calls/{call_control_id}/actions/transfer| Parameter | Type | Required | Description |
|---|---|---|---|
| string (E.164) | Yes | The DID or SIP URI to dial out to. |
| string (UUID) | Yes | Unique identifier and token for controlling the call |
| integer | No | The number of seconds that Telnyx will wait for the call to ... |
| string | No | Use this field to add state to every subsequent webhook. |
| string (URL) | No | Use this field to override the URL for which Telnyx will sen... |
| ... | +33 optional params in references/api-details.md |
import com.telnyx.sdk.models.calls.actions.ActionTransferParams;
import com.telnyx.sdk.models.calls.actions.ActionTransferResponse;
ActionTransferParams params = ActionTransferParams.builder()
.callControlId("v3:550e8400-e29b-41d4-a716-446655440000_gRU1OGRkYQ")
.to("+18005550100")
.build();
ActionTransferResponse response = client.calls().actions().transfer(params);response.data.resultclient.calls().actions().transfer()POST /calls/{call_control_id}/actions/transfer| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| string (E.164) | 是 | 要转接的目标DID或SIP URI |
| string (UUID) | 是 | 用于控制呼叫的唯一标识符和令牌 |
| integer | 否 | Telnyx等待转接呼叫接通的最大秒数 |
| string | 否 | 用于向后续所有webhook添加自定义状态 |
| string (URL) | 否 | 用于覆盖Telnyx发送事件的默认webhook地址 |
| ... | 其余33个可选参数见references/api-details.md |
import com.telnyx.sdk.models.calls.actions.ActionTransferParams;
import com.telnyx.sdk.models.calls.actions.ActionTransferResponse;
ActionTransferParams params = ActionTransferParams.builder()
.callControlId("v3:550e8400-e29b-41d4-a716-446655440000_gRU1OGRkYQ")
.to("+18005550100")
.build();
ActionTransferResponse response = client.calls().actions().transfer(params);response.data.resulttelnyx-signature-ed25519telnyx-timestampimport com.telnyx.sdk.core.UnwrapWebhookParams;
import com.telnyx.sdk.core.http.Headers;
// In your webhook handler (e.g., Spring — use raw body):
@PostMapping("/webhooks")
public ResponseEntity<String> handleWebhook(
@RequestBody String payload,
HttpServletRequest request) {
try {
Headers headers = Headers.builder()
.put("telnyx-signature-ed25519", request.getHeader("telnyx-signature-ed25519"))
.put("telnyx-timestamp", request.getHeader("telnyx-timestamp"))
.build();
var event = client.webhooks().unwrap(
UnwrapWebhookParams.builder()
.body(payload)
.headers(headers)
.build());
// Signature valid — process the event
System.out.println("Received webhook event");
return ResponseEntity.ok("OK");
} catch (Exception e) {
System.err.println("Webhook verification failed: " + e.getMessage());
return ResponseEntity.badRequest().body("Invalid signature");
}
}telnyx-signature-ed25519telnyx-timestampimport com.telnyx.sdk.core.UnwrapWebhookParams;
import com.telnyx.sdk.core.http.Headers;
// 在你的webhook处理器中(例如Spring请使用原始body):
@PostMapping("/webhooks")
public ResponseEntity<String> handleWebhook(
@RequestBody String payload,
HttpServletRequest request) {
try {
Headers headers = Headers.builder()
.put("telnyx-signature-ed25519", request.getHeader("telnyx-signature-ed25519"))
.put("telnyx-timestamp", request.getHeader("telnyx-timestamp"))
.build();
var event = client.webhooks().unwrap(
UnwrapWebhookParams.builder()
.body(payload)
.headers(headers)
.build());
// 签名验证通过,处理事件
System.out.println("Received webhook event");
return ResponseEntity.ok("OK");
} catch (Exception e) {
System.err.println("Webhook verification failed: " + e.getMessage());
return ResponseEntity.badRequest().body("Invalid signature");
}
}| Field | Type | Description |
|---|---|---|
| enum: event | Identifies the type of the resource. |
| enum: call.answered | 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 ev... |
| 字段 | 类型 | 描述 |
|---|---|---|
| enum: event | 资源类型标识 |
| enum: call.answered | 交付的事件类型 |
| uuid | 资源类型标识 |
| date-time | 事件发生的ISO 8601格式时间 |
| string | 用于通过呼叫控制API下发指令的呼叫ID |
| string | 通话使用的呼叫控制应用ID(原Telnyx连接ID) |
| string | 呼叫唯一ID,可用于关联webhook事件 |
| string | 呼叫会话唯一ID,可用于关联webhook事件 |
| Field | Type | Description |
|---|---|---|
| enum: event | Identifies the type of the resource. |
| enum: call.hangup | 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 ev... |
| 字段 | 类型 | 描述 |
|---|---|---|
| enum: event | 资源类型标识 |
| enum: call.hangup | 交付的事件类型 |
| uuid | 资源类型标识 |
| date-time | 事件发生的ISO 8601格式时间 |
| string | 用于通过呼叫控制API下发指令的呼叫ID |
| string | 通话使用的呼叫控制应用ID(原Telnyx连接ID) |
| string | 呼叫唯一ID,可用于关联webhook事件 |
| string | 呼叫会话唯一ID,可用于关联webhook事件 |
| Field | Type | Description |
|---|---|---|
| enum: event | Identifies the type of the resource. |
| enum: call.initiated | 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. |
| 字段 | 类型 | 描述 |
|---|---|---|
| enum: event | 资源类型标识 |
| enum: call.initiated | 交付的事件类型 |
| uuid | 资源类型标识 |
| date-time | 事件发生的ISO 8601格式时间 |
| string | 用于通过呼叫控制API下发指令的呼叫ID |
| string | 通话使用的呼叫控制应用ID(原Telnyx连接ID) |
| string | 连接启用的逗号分隔编解码器列表 |
| string | 主叫提供的逗号分隔编解码器列表 |
client.calls().actions().hangup()POST /calls/{call_control_id}/actions/hangup| Parameter | Type | Required | Description |
|---|---|---|---|
| string (UUID) | Yes | Unique identifier and token for controlling the call |
| string | No | Use this field to add state to every subsequent webhook. |
| string (UUID) | No | Use this field to avoid duplicate commands. |
| array[object] | No | Custom headers to be added to the SIP BYE message. |
import com.telnyx.sdk.models.calls.actions.ActionHangupParams;
import com.telnyx.sdk.models.calls.actions.ActionHangupResponse;
ActionHangupResponse response = client.calls().actions().hangup("v3:550e8400-e29b-41d4-a716-446655440000_gRU1OGRkYQ");response.data.resultclient.calls().actions().hangup()POST /calls/{call_control_id}/actions/hangup| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| string (UUID) | 是 | 用于控制呼叫的唯一标识符和令牌 |
| string | 否 | 用于向后续所有webhook添加自定义状态 |
| string (UUID) | 否 | 用于避免重复执行指令 |
| array[object] | 否 | 添加到SIP BYE消息中的自定义头 |
import com.telnyx.sdk.models.calls.actions.ActionHangupParams;
import com.telnyx.sdk.models.calls.actions.ActionHangupResponse;
ActionHangupResponse response = client.calls().actions().hangup("v3:550e8400-e29b-41d4-a716-446655440000_gRU1OGRkYQ");response.data.resultclient.calls().actions().bridge()POST /calls/{call_control_id}/actions/bridge| Parameter | Type | Required | Description |
|---|---|---|---|
| string (UUID) | Yes | The Call Control ID of the call you want to bridge with, can... |
| string (UUID) | Yes | Unique identifier and token for controlling the call |
| string | No | Use this field to add state to every subsequent webhook. |
| string (UUID) | No | Use this field to avoid duplicate commands. |
| string (UUID) | No | The ID of the video room you want to bridge with, can't be u... |
| ... | +16 optional params in references/api-details.md |
import com.telnyx.sdk.models.calls.actions.ActionBridgeParams;
import com.telnyx.sdk.models.calls.actions.ActionBridgeResponse;
ActionBridgeParams params = ActionBridgeParams.builder()
.callControlIdToBridge("v3:550e8400-e29b-41d4-a716-446655440000_gRU1OGRkYQ")
.callControlId("v3:MdI91X4lWFEs7IgbBEOT9M4AigoY08M0WWZFISt1Yw2axZ_IiE4pqg")
.build();
ActionBridgeResponse response = client.calls().actions().bridge(params);response.data.resultclient.calls().actions().bridge()POST /calls/{call_control_id}/actions/bridge| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| string (UUID) | 是 | 要桥接的目标通话的呼叫控制ID |
| string (UUID) | 是 | 用于控制当前呼叫的唯一标识符和令牌 |
| string | 否 | 用于向后续所有webhook添加自定义状态 |
| string (UUID) | 否 | 用于避免重复执行指令 |
| string (UUID) | 否 | 要桥接的视频房间ID,不可与其他桥接目标共用 |
| ... | 其余16个可选参数见references/api-details.md |
import com.telnyx.sdk.models.calls.actions.ActionBridgeParams;
import com.telnyx.sdk.models.calls.actions.ActionBridgeResponse;
ActionBridgeParams params = ActionBridgeParams.builder()
.callControlIdToBridge("v3:550e8400-e29b-41d4-a716-446655440000_gRU1OGRkYQ")
.callControlId("v3:MdI91X4lWFEs7IgbBEOT9M4AigoY08M0WWZFISt1Yw2axZ_IiE4pqg")
.build();
ActionBridgeResponse response = client.calls().actions().bridge(params);response.data.resultclient.calls().actions().reject()POST /calls/{call_control_id}/actions/reject| Parameter | Type | Required | Description |
|---|---|---|---|
| enum (CALL_REJECTED, USER_BUSY) | Yes | Cause for call rejection. |
| string (UUID) | Yes | Unique identifier and token for controlling the call |
| string | No | Use this field to add state to every subsequent webhook. |
| string (UUID) | No | Use this field to avoid duplicate commands. |
import com.telnyx.sdk.models.calls.actions.ActionRejectParams;
import com.telnyx.sdk.models.calls.actions.ActionRejectResponse;
ActionRejectParams params = ActionRejectParams.builder()
.callControlId("v3:550e8400-e29b-41d4-a716-446655440000_gRU1OGRkYQ")
.cause(ActionRejectParams.Cause.USER_BUSY)
.build();
ActionRejectResponse response = client.calls().actions().reject(params);response.data.resultclient.calls().actions().reject()POST /calls/{call_control_id}/actions/reject| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| enum (CALL_REJECTED, USER_BUSY) | 是 | 拒接呼叫的原因 |
| string (UUID) | 是 | 用于控制呼叫的唯一标识符和令牌 |
| string | 否 | 用于向后续所有webhook添加自定义状态 |
| string (UUID) | 否 | 用于避免重复执行指令 |
import com.telnyx.sdk.models.calls.actions.ActionRejectParams;
import com.telnyx.sdk.models.calls.actions.ActionRejectResponse;
ActionRejectParams params = ActionRejectParams.builder()
.callControlId("v3:550e8400-e29b-41d4-a716-446655440000_gRU1OGRkYQ")
.cause(ActionRejectParams.Cause.USER_BUSY)
.build();
ActionRejectResponse response = client.calls().actions().reject(params);response.data.resultclient.calls().retrieveStatus()GET /calls/{call_control_id}| Parameter | Type | Required | Description |
|---|---|---|---|
| string (UUID) | Yes | Unique identifier and token for controlling the call |
import com.telnyx.sdk.models.calls.CallRetrieveStatusParams;
import com.telnyx.sdk.models.calls.CallRetrieveStatusResponse;
CallRetrieveStatusResponse response = client.calls().retrieveStatus("v3:550e8400-e29b-41d4-a716-446655440000_gRU1OGRkYQ");response.data.callControlIdresponse.data.callDurationresponse.data.callLegIdresponse.data.callSessionIdresponse.data.clientStateresponse.data.endTimeclient.calls().retrieveStatus()GET /calls/{call_control_id}| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| string (UUID) | 是 | 用于控制呼叫的唯一标识符和令牌 |
import com.telnyx.sdk.models.calls.CallRetrieveStatusParams;
import com.telnyx.sdk.models.calls.CallRetrieveStatusResponse;
CallRetrieveStatusResponse response = client.calls().retrieveStatus("v3:550e8400-e29b-41d4-a716-446655440000_gRU1OGRkYQ");response.data.callControlIdresponse.data.callDurationresponse.data.callLegIdresponse.data.callSessionIdresponse.data.clientStateresponse.data.endTimeclient.connections().listActiveCalls()GET /connections/{connection_id}/active_calls| Parameter | Type | Required | Description |
|---|---|---|---|
| string (UUID) | Yes | Telnyx connection id |
| object | No | Consolidated page parameter (deepObject style). |
import com.telnyx.sdk.models.connections.ConnectionListActiveCallsPage;
import com.telnyx.sdk.models.connections.ConnectionListActiveCallsParams;
ConnectionListActiveCallsPage page = client.connections().listActiveCalls("1293384261075731461");page.datapage.metacallControlIdcallDurationcallLegIdcallSessionIdclientStaterecordTypeclient.connections().listActiveCalls()GET /connections/{connection_id}/active_calls| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| string (UUID) | 是 | Telnyx连接ID |
| object | 否 | 统一分页参数(deepObject格式) |
import com.telnyx.sdk.models.connections.ConnectionListActiveCallsPage;
import com.telnyx.sdk.models.connections.ConnectionListActiveCallsParams;
ConnectionListActiveCallsPage page = client.connections().listActiveCalls("1293384261075731461");page.datapage.metacallControlIdcallDurationcallLegIdcallSessionIdclientStaterecordTypeclient.callControlApplications().list()GET /call_control_applications| Parameter | Type | Required | Description |
|---|---|---|---|
| enum (created_at, connection_name, active) | No | Specifies the sort order for results. |
| object | No | Consolidated filter parameter (deepObject style). |
| object | No | Consolidated page parameter (deepObject style). |
import com.telnyx.sdk.models.callcontrolapplications.CallControlApplicationListPage;
import com.telnyx.sdk.models.callcontrolapplications.CallControlApplicationListParams;
CallControlApplicationListPage page = client.callControlApplications().list();page.datapage.metaidcreatedAtupdatedAtactiveanchorsiteOverrideapplicationNameclient.callControlApplications().list()GET /call_control_applications| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| enum (created_at, connection_name, active) | 否 | 指定结果的排序规则 |
| object | 否 | 统一过滤参数(deepObject格式) |
| object | 否 | 统一分页参数(deepObject格式) |
import com.telnyx.sdk.models.callcontrolapplications.CallControlApplicationListPage;
import com.telnyx.sdk.models.callcontrolapplications.CallControlApplicationListParams;
CallControlApplicationListPage page = client.callControlApplications().list();page.datapage.metaidcreatedAtupdatedAtactiveanchorsiteOverrideapplicationName| Operation | SDK method | Endpoint | Use when | Required params |
|---|---|---|---|---|
| Create a call control application | | | Create or provision an additional resource when the core tasks do not cover this flow. | |
| Retrieve a call control application | | | Fetch the current state before updating, deleting, or making control-flow decisions. | |
| Update a call control application | | | Modify an existing resource without recreating it. | |
| Delete a call control application | | | Remove, detach, or clean up an existing resource. | |
| SIP Refer a call | | | Trigger a follow-up action in an existing workflow rather than creating a new top-level resource. | |
| Send SIP info | | | Trigger a follow-up action in an existing workflow rather than creating a new top-level resource. | |
| 操作 | SDK方法 | 接口地址 | 使用场景 | 必填参数 |
|---|---|---|---|---|
| 创建呼叫控制应用 | | | 当核心任务未覆盖该流程时,创建或配置额外资源 | |
| 获取呼叫控制应用信息 | | | 在更新、删除或做控制流决策前获取当前状态 | |
| 更新呼叫控制应用 | | | 修改现有资源无需重新创建 | |
| 删除呼叫控制应用 | | | 移除、解绑或清理现有资源 | |
| SIP转接呼叫 | | | 在现有工作流中触发后续操作,而非创建新的顶层资源 | |
| 发送SIP信息 | | | 在现有工作流中触发后续操作,而非创建新的顶层资源 | |
| Event | | Description |
|---|---|---|
| | Call Bridged |
| 事件 | | 描述 |
|---|---|---|
| | 通话已桥接 |