telnyx-fax-java
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese<!-- Auto-generated from Telnyx OpenAPI specs. Do not edit. -->
<!-- 从Telnyx OpenAPI规范自动生成,请勿编辑。 -->
Telnyx Fax - Java
Telnyx 传真 - Java
Installation
安装
text
<!-- 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")text
<!-- 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")Setup
初始化配置
java
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
TelnyxClient client = TelnyxOkHttpClient.fromEnv();All examples below assume is already initialized as shown above.
clientjava
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
TelnyxClient client = TelnyxOkHttpClient.fromEnv();以下所有示例均默认已经按照上文方式完成初始化。
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:
java
import com.telnyx.sdk.errors.TelnyxServiceException;
try {
var result = client.messages().send(params);
} catch (TelnyxServiceException e) {
System.err.println("API error " + e.statusCode() + ": " + e.getMessage());
if (e.statusCode() == 422) {
System.err.println("Validation error — check required fields and formats");
} else if (e.statusCode() == 429) {
// Rate limited — wait and retry with exponential backoff
Thread.sleep(1000);
}
}Common error codes: invalid API key, insufficient permissions,
resource not found, validation error (check field formats),
rate limited (retry with exponential backoff).
401403404422429所有API调用都可能因为网络错误、速率限制(429)、校验错误(422)或者认证错误(401)失败。在生产代码中请始终做好错误处理:
java
import com.telnyx.sdk.errors.TelnyxServiceException;
try {
var result = client.messages().send(params);
} catch (TelnyxServiceException e) {
System.err.println("API error " + e.statusCode() + ": " + e.getMessage());
if (e.statusCode() == 422) {
System.err.println("校验错误 — 请检查必填字段和格式是否正确");
} else if (e.statusCode() == 429) {
// 触发速率限制 — 等待后使用指数退避策略重试
Thread.sleep(1000);
}
}常见错误码: API密钥无效, 权限不足, 资源不存在, 校验错误(检查字段格式), 触发速率限制(使用指数退避策略重试)。
401403404422429Important Notes
重要注意事项
- Phone numbers must be in E.164 format (e.g., ). Include the
+13125550001prefix and country code. No spaces, dashes, or parentheses.+ - Pagination: List methods return a page. Use for automatic iteration:
.autoPager(). For manual control, usefor (var item : page.autoPager()) { ... }and.hasNextPage()..nextPage()
- 电话号码必须使用E.164格式(例如),需包含
+13125550001前缀和国家码,不允许有空格、横杠或者括号。+ - 分页: 列表接口返回单页数据。使用可以自动迭代所有数据:
.autoPager()。如果需要手动控制,可使用for (var item : page.autoPager()) { ... }和.hasNextPage()方法。.nextPage()
List all Fax Applications
列出所有传真应用
This endpoint returns a list of your Fax Applications inside the 'data' attribute of the response. You can adjust which applications are listed by using filters. Fax Applications are used to configure how you send and receive faxes using the Programmable Fax API with Telnyx.
GET /fax_applicationsjava
import com.telnyx.sdk.models.faxapplications.FaxApplicationListPage;
import com.telnyx.sdk.models.faxapplications.FaxApplicationListParams;
FaxApplicationListPage page = client.faxApplications().list();Returns: (boolean), (enum: Latency, Chicago, IL, Ashburn, VA, San Jose, CA, Sydney, Australia, Amsterdam, Netherlands, London, UK, Toronto, Canada, Vancouver, Canada, Frankfurt, Germany), (string), (string), (string), (object), (object), (string), (array[string]), (string), (uri), (uri), (integer | null)
activeanchorsite_overrideapplication_namecreated_atidinboundoutboundrecord_typetagsupdated_atwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secs该端点返回的属性中包含您的传真应用列表。您可以使用筛选参数调整返回的应用范围。传真应用用于配置Telnyx可编程传真API的收发规则。
dataGET /fax_applicationsjava
import com.telnyx.sdk.models.faxapplications.FaxApplicationListPage;
import com.telnyx.sdk.models.faxapplications.FaxApplicationListParams;
FaxApplicationListPage page = client.faxApplications().list();返回字段:(布尔值)、(枚举值:Latency, Chicago, IL, Ashburn, VA, San Jose, CA, Sydney, Australia, Amsterdam, Netherlands, London, UK, Toronto, Canada, Vancouver, Canada, Frankfurt, Germany)、(字符串)、(字符串)、(字符串)、(对象)、(对象)、(字符串)、(字符串数组)、(字符串)、(URI)、(URI)、(整数 | 空)
activeanchorsite_overrideapplication_namecreated_atidinboundoutboundrecord_typetagsupdated_atwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsCreates a Fax Application
创建传真应用
Creates a new Fax Application based on the parameters sent in the request. The application name and webhook URL are required. Once created, you can assign phone numbers to your application using the endpoint.
/phone_numbersPOST /fax_applicationsapplication_namewebhook_event_urlOptional: (boolean), (enum: Latency, Chicago, IL, Ashburn, VA, San Jose, CA, Sydney, Australia, Amsterdam, Netherlands, London, UK, Toronto, Canada, Vancouver, Canada, Frankfurt, Germany), (object), (object), (array[string]), (uri), (integer | null)
activeanchorsite_overrideinboundoutboundtagswebhook_event_failover_urlwebhook_timeout_secsjava
import com.telnyx.sdk.models.faxapplications.FaxApplicationCreateParams;
import com.telnyx.sdk.models.faxapplications.FaxApplicationCreateResponse;
FaxApplicationCreateParams params = FaxApplicationCreateParams.builder()
.applicationName("fax-router")
.webhookEventUrl("https://example.com")
.build();
FaxApplicationCreateResponse faxApplication = client.faxApplications().create(params);Returns: (boolean), (enum: Latency, Chicago, IL, Ashburn, VA, San Jose, CA, Sydney, Australia, Amsterdam, Netherlands, London, UK, Toronto, Canada, Vancouver, Canada, Frankfurt, Germany), (string), (string), (string), (object), (object), (string), (array[string]), (string), (uri), (uri), (integer | null)
activeanchorsite_overrideapplication_namecreated_atidinboundoutboundrecord_typetagsupdated_atwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secs根据请求参数创建新的传真应用。应用名称和webhook URL为必填项。创建完成后,您可以通过端点为应用分配电话号码。
/phone_numbersPOST /fax_applicationsapplication_namewebhook_event_url可选参数:(布尔值)、(枚举值:Latency, Chicago, IL, Ashburn, VA, San Jose, CA, Sydney, Australia, Amsterdam, Netherlands, London, UK, Toronto, Canada, Vancouver, Canada, Frankfurt, Germany)、(对象)、(对象)、(字符串数组)、(URI)、(整数 | 空)
activeanchorsite_overrideinboundoutboundtagswebhook_event_failover_urlwebhook_timeout_secsjava
import com.telnyx.sdk.models.faxapplications.FaxApplicationCreateParams;
import com.telnyx.sdk.models.faxapplications.FaxApplicationCreateResponse;
FaxApplicationCreateParams params = FaxApplicationCreateParams.builder()
.applicationName("fax-router")
.webhookEventUrl("https://example.com")
.build();
FaxApplicationCreateResponse faxApplication = client.faxApplications().create(params);返回字段:(布尔值)、(枚举值:Latency, Chicago, IL, Ashburn, VA, San Jose, CA, Sydney, Australia, Amsterdam, Netherlands, London, UK, Toronto, Canada, Vancouver, Canada, Frankfurt, Germany)、(字符串)、(字符串)、(字符串)、(对象)、(对象)、(字符串)、(字符串数组)、(字符串)、(URI)、(URI)、(整数 | 空)
activeanchorsite_overrideapplication_namecreated_atidinboundoutboundrecord_typetagsupdated_atwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsRetrieve a Fax Application
获取单个传真应用详情
Return the details of an existing Fax Application inside the 'data' attribute of the response.
GET /fax_applications/{id}java
import com.telnyx.sdk.models.faxapplications.FaxApplicationRetrieveParams;
import com.telnyx.sdk.models.faxapplications.FaxApplicationRetrieveResponse;
FaxApplicationRetrieveResponse faxApplication = client.faxApplications().retrieve("1293384261075731499");Returns: (boolean), (enum: Latency, Chicago, IL, Ashburn, VA, San Jose, CA, Sydney, Australia, Amsterdam, Netherlands, London, UK, Toronto, Canada, Vancouver, Canada, Frankfurt, Germany), (string), (string), (string), (object), (object), (string), (array[string]), (string), (uri), (uri), (integer | null)
activeanchorsite_overrideapplication_namecreated_atidinboundoutboundrecord_typetagsupdated_atwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secs返回的属性中包含指定传真应用的详细信息。
dataGET /fax_applications/{id}java
import com.telnyx.sdk.models.faxapplications.FaxApplicationRetrieveParams;
import com.telnyx.sdk.models.faxapplications.FaxApplicationRetrieveResponse;
FaxApplicationRetrieveResponse faxApplication = client.faxApplications().retrieve("1293384261075731499");返回字段:(布尔值)、(枚举值:Latency, Chicago, IL, Ashburn, VA, San Jose, CA, Sydney, Australia, Amsterdam, Netherlands, London, UK, Toronto, Canada, Vancouver, Canada, Frankfurt, Germany)、(字符串)、(字符串)、(字符串)、(对象)、(对象)、(字符串)、(字符串数组)、(字符串)、(URI)、(URI)、(整数 | 空)
activeanchorsite_overrideapplication_namecreated_atidinboundoutboundrecord_typetagsupdated_atwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsUpdate a Fax Application
更新传真应用
Updates settings of an existing Fax Application based on the parameters of the request.
PATCH /fax_applications/{id}application_namewebhook_event_urlOptional: (boolean), (enum: Latency, Chicago, IL, Ashburn, VA, San Jose, CA, Sydney, Australia, Amsterdam, Netherlands, London, UK, Toronto, Canada, Vancouver, Canada, Frankfurt, Germany), (string | null), (object), (object), (array[string]), (uri), (integer | null)
activeanchorsite_overridefax_email_recipientinboundoutboundtagswebhook_event_failover_urlwebhook_timeout_secsjava
import com.telnyx.sdk.models.faxapplications.FaxApplicationUpdateParams;
import com.telnyx.sdk.models.faxapplications.FaxApplicationUpdateResponse;
FaxApplicationUpdateParams params = FaxApplicationUpdateParams.builder()
.id("1293384261075731499")
.applicationName("fax-router")
.webhookEventUrl("https://example.com")
.build();
FaxApplicationUpdateResponse faxApplication = client.faxApplications().update(params);Returns: (boolean), (enum: Latency, Chicago, IL, Ashburn, VA, San Jose, CA, Sydney, Australia, Amsterdam, Netherlands, London, UK, Toronto, Canada, Vancouver, Canada, Frankfurt, Germany), (string), (string), (string), (object), (object), (string), (array[string]), (string), (uri), (uri), (integer | null)
activeanchorsite_overrideapplication_namecreated_atidinboundoutboundrecord_typetagsupdated_atwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secs根据请求参数更新现有传真应用的配置。
PATCH /fax_applications/{id}application_namewebhook_event_url可选参数:(布尔值)、(枚举值:Latency, Chicago, IL, Ashburn, VA, San Jose, CA, Sydney, Australia, Amsterdam, Netherlands, London, UK, Toronto, Canada, Vancouver, Canada, Frankfurt, Germany)、(字符串 | 空)、(对象)、(对象)、(字符串数组)、(URI)、(整数 | 空)
activeanchorsite_overridefax_email_recipientinboundoutboundtagswebhook_event_failover_urlwebhook_timeout_secsjava
import com.telnyx.sdk.models.faxapplications.FaxApplicationUpdateParams;
import com.telnyx.sdk.models.faxapplications.FaxApplicationUpdateResponse;
FaxApplicationUpdateParams params = FaxApplicationUpdateParams.builder()
.id("1293384261075731499")
.applicationName("fax-router")
.webhookEventUrl("https://example.com")
.build();
FaxApplicationUpdateResponse faxApplication = client.faxApplications().update(params);返回字段:(布尔值)、(枚举值:Latency, Chicago, IL, Ashburn, VA, San Jose, CA, Sydney, Australia, Amsterdam, Netherlands, London, UK, Toronto, Canada, Vancouver, Canada, Frankfurt, Germany)、(字符串)、(字符串)、(字符串)、(对象)、(对象)、(字符串)、(字符串数组)、(字符串)、(URI)、(URI)、(整数 | 空)
activeanchorsite_overrideapplication_namecreated_atidinboundoutboundrecord_typetagsupdated_atwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsDeletes a Fax Application
删除传真应用
Permanently deletes a Fax Application. Deletion may be prevented if the application is in use by phone numbers.
DELETE /fax_applications/{id}java
import com.telnyx.sdk.models.faxapplications.FaxApplicationDeleteParams;
import com.telnyx.sdk.models.faxapplications.FaxApplicationDeleteResponse;
FaxApplicationDeleteResponse faxApplication = client.faxApplications().delete("1293384261075731499");Returns: (boolean), (enum: Latency, Chicago, IL, Ashburn, VA, San Jose, CA, Sydney, Australia, Amsterdam, Netherlands, London, UK, Toronto, Canada, Vancouver, Canada, Frankfurt, Germany), (string), (string), (string), (object), (object), (string), (array[string]), (string), (uri), (uri), (integer | null)
activeanchorsite_overrideapplication_namecreated_atidinboundoutboundrecord_typetagsupdated_atwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secs永久删除传真应用。如果应用仍关联有电话号码,则无法完成删除。
DELETE /fax_applications/{id}java
import com.telnyx.sdk.models.faxapplications.FaxApplicationDeleteParams;
import com.telnyx.sdk.models.faxapplications.FaxApplicationDeleteResponse;
FaxApplicationDeleteResponse faxApplication = client.faxApplications().delete("1293384261075731499");返回字段:(布尔值)、(枚举值:Latency, Chicago, IL, Ashburn, VA, San Jose, CA, Sydney, Australia, Amsterdam, Netherlands, London, UK, Toronto, Canada, Vancouver, Canada, Frankfurt, Germany)、(字符串)、(字符串)、(字符串)、(对象)、(对象)、(字符串)、(字符串数组)、(字符串)、(URI)、(URI)、(整数 | 空)
activeanchorsite_overrideapplication_namecreated_atidinboundoutboundrecord_typetagsupdated_atwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsView a list of faxes
获取传真列表
GET /faxesjava
import com.telnyx.sdk.models.faxes.FaxListPage;
import com.telnyx.sdk.models.faxes.FaxListParams;
FaxListPage page = client.faxes().list();Returns: (string), (string), (date-time), (enum: inbound, outbound), (string), (string), (uuid), (string), (string), (string), (enum: normal, high, very_high, ultra_light, ultra_dark), (enum: fax), (enum: queued, media.processed, originated, sending, delivered, failed, initiated, receiving, media.processing, received), (boolean), (string), (string), (date-time), (string), (string)
client_stateconnection_idcreated_atdirectionfromfrom_display_nameidmedia_namemedia_urlpreview_urlqualityrecord_typestatusstore_mediastored_media_urltoupdated_atwebhook_failover_urlwebhook_urlGET /faxesjava
import com.telnyx.sdk.models.faxes.FaxListPage;
import com.telnyx.sdk.models.faxes.FaxListParams;
FaxListPage page = client.faxes().list();返回字段:(字符串)、(字符串)、(日期时间)、(枚举值:inbound, outbound)、(字符串)、(字符串)、(UUID)、(字符串)、(字符串)、(字符串)、(枚举值:normal, high, very_high, ultra_light, ultra_dark)、(枚举值:fax)、(枚举值:queued, media.processed, originated, sending, delivered, failed, initiated, receiving, media.processing, received)、(布尔值)、(字符串)、(字符串)、(日期时间)、(字符串)、(字符串)
client_stateconnection_idcreated_atdirectionfromfrom_display_nameidmedia_namemedia_urlpreview_urlqualityrecord_typestatusstore_mediastored_media_urltoupdated_atwebhook_failover_urlwebhook_urlSend a fax
发送传真
Send a fax. Files have size limits and page count limit validations. If a file is bigger than 50MB or has more than 350 pages it will fail with and respectively.
file_size_limit_exceededpage_count_limit_exceededPOST /faxesconnection_idfromtoOptional: (integer), (string), (string), (string), (string), (boolean), (enum: pdf, tiff), (enum: normal, high, very_high, ultra_light, ultra_dark), (boolean), (boolean), (boolean), (string)
black_thresholdclient_statefrom_display_namemedia_namemedia_urlmonochromepreview_formatqualitystore_mediastore_previewt38_enabledwebhook_urljava
import com.telnyx.sdk.models.faxes.FaxCreateParams;
import com.telnyx.sdk.models.faxes.FaxCreateResponse;
FaxCreateParams params = FaxCreateParams.builder()
.connectionId("234423")
.from("+13125790015")
.to("+13127367276")
.mediaUrl("https://example.com/document.pdf")
.build();
FaxCreateResponse fax = client.faxes().create(params);Returns: (string), (string), (date-time), (enum: inbound, outbound), (string), (string), (uuid), (string), (string), (string), (enum: normal, high, very_high, ultra_light, ultra_dark), (enum: fax), (enum: queued, media.processed, originated, sending, delivered, failed, initiated, receiving, media.processing, received), (boolean), (string), (string), (date-time), (string), (string)
client_stateconnection_idcreated_atdirectionfromfrom_display_nameidmedia_namemedia_urlpreview_urlqualityrecord_typestatusstore_mediastored_media_urltoupdated_atwebhook_failover_urlwebhook_url发送传真。文件存在大小和页数限制:如果文件大于50MB或者页数超过350页,会分别返回和错误。
file_size_limit_exceededpage_count_limit_exceededPOST /faxesconnection_idfromto可选参数:(整数)、(字符串)、(字符串)、(字符串)、(字符串)、(布尔值)、(枚举值:pdf, tiff)、(枚举值:normal, high, very_high, ultra_light, ultra_dark)、(布尔值)、(布尔值)、(布尔值)、(字符串)
black_thresholdclient_statefrom_display_namemedia_namemedia_urlmonochromepreview_formatqualitystore_mediastore_previewt38_enabledwebhook_urljava
import com.telnyx.sdk.models.faxes.FaxCreateParams;
import com.telnyx.sdk.models.faxes.FaxCreateResponse;
FaxCreateParams params = FaxCreateParams.builder()
.connectionId("234423")
.from("+13125790015")
.to("+13127367276")
.mediaUrl("https://example.com/document.pdf")
.build();
FaxCreateResponse fax = client.faxes().create(params);返回字段:(字符串)、(字符串)、(日期时间)、(枚举值:inbound, outbound)、(字符串)、(字符串)、(UUID)、(字符串)、(字符串)、(字符串)、(枚举值:normal, high, very_high, ultra_light, ultra_dark)、(枚举值:fax)、(枚举值:queued, media.processed, originated, sending, delivered, failed, initiated, receiving, media.processing, received)、(布尔值)、(字符串)、(字符串)、(日期时间)、(字符串)、(字符串)
client_stateconnection_idcreated_atdirectionfromfrom_display_nameidmedia_namemedia_urlpreview_urlqualityrecord_typestatusstore_mediastored_media_urltoupdated_atwebhook_failover_urlwebhook_urlView a fax
获取单个传真详情
GET /faxes/{id}java
import com.telnyx.sdk.models.faxes.FaxRetrieveParams;
import com.telnyx.sdk.models.faxes.FaxRetrieveResponse;
FaxRetrieveResponse fax = client.faxes().retrieve("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e");Returns: (string), (string), (date-time), (enum: inbound, outbound), (string), (string), (uuid), (string), (string), (string), (enum: normal, high, very_high, ultra_light, ultra_dark), (enum: fax), (enum: queued, media.processed, originated, sending, delivered, failed, initiated, receiving, media.processing, received), (boolean), (string), (string), (date-time), (string), (string)
client_stateconnection_idcreated_atdirectionfromfrom_display_nameidmedia_namemedia_urlpreview_urlqualityrecord_typestatusstore_mediastored_media_urltoupdated_atwebhook_failover_urlwebhook_urlGET /faxes/{id}java
import com.telnyx.sdk.models.faxes.FaxRetrieveParams;
import com.telnyx.sdk.models.faxes.FaxRetrieveResponse;
FaxRetrieveResponse fax = client.faxes().retrieve("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e");返回字段:(字符串)、(字符串)、(日期时间)、(枚举值:inbound, outbound)、(字符串)、(字符串)、(UUID)、(字符串)、(字符串)、(字符串)、(枚举值:normal, high, very_high, ultra_light, ultra_dark)、(枚举值:fax)、(枚举值:queued, media.processed, originated, sending, delivered, failed, initiated, receiving, media.processing, received)、(布尔值)、(字符串)、(字符串)、(日期时间)、(字符串)、(字符串)
client_stateconnection_idcreated_atdirectionfromfrom_display_nameidmedia_namemedia_urlpreview_urlqualityrecord_typestatusstore_mediastored_media_urltoupdated_atwebhook_failover_urlwebhook_urlDelete a fax
删除传真
DELETE /faxes/{id}java
import com.telnyx.sdk.models.faxes.FaxDeleteParams;
client.faxes().delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e");DELETE /faxes/{id}java
import com.telnyx.sdk.models.faxes.FaxDeleteParams;
client.faxes().delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e");Cancel a fax
取消传真
Cancel the outbound fax that is in one of the following states: , , or
queuedmedia.processedoriginatedsendingPOST /faxes/{id}/actions/canceljava
import com.telnyx.sdk.models.faxes.actions.ActionCancelParams;
import com.telnyx.sdk.models.faxes.actions.ActionCancelResponse;
ActionCancelResponse response = client.faxes().actions().cancel("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e");Returns: (string)
result取消处于以下状态的外发传真:、、或者
queuedmedia.processedoriginatedsendingPOST /faxes/{id}/actions/canceljava
import com.telnyx.sdk.models.faxes.actions.ActionCancelParams;
import com.telnyx.sdk.models.faxes.actions.ActionCancelResponse;
ActionCancelResponse response = client.faxes().actions().cancel("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e");返回字段:(字符串)
resultRefresh a fax
刷新传真
Refreshes the inbound fax's media_url when it has expired
POST /faxes/{id}/actions/refreshjava
import com.telnyx.sdk.models.faxes.actions.ActionRefreshParams;
import com.telnyx.sdk.models.faxes.actions.ActionRefreshResponse;
ActionRefreshResponse response = client.faxes().actions().refresh("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e");Returns: (string)
result当入站传真的过期时,调用该接口刷新地址
media_urlPOST /faxes/{id}/actions/refreshjava
import com.telnyx.sdk.models.faxes.actions.ActionRefreshParams;
import com.telnyx.sdk.models.faxes.actions.ActionRefreshResponse;
ActionRefreshResponse response = client.faxes().actions().refresh("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e");返回字段:(字符串)
resultWebhooks
Webhooks
Webhook Verification
Webhook 签名验证
Telnyx signs webhooks with Ed25519. Each request includes
and headers. Always verify signatures in production:
telnyx-signature-ed25519telnyx-timestampjava
import 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");
}
}The following webhook events are sent to your configured webhook URL.
All webhooks include and headers for Ed25519 signature verification. Use to verify.
telnyx-timestamptelnyx-signature-ed25519client.webhooks.unwrap()| Event | Description |
|---|---|
| Fax Delivered |
| Fax Failed |
| Fax Media Processed |
| Fax Queued |
| Fax Sending Started |
Telnyx使用Ed25519对Webhook请求签名。每个请求都会携带和请求头。生产环境请务必验证签名:
telnyx-signature-ed25519telnyx-timestampjava
import com.telnyx.sdk.core.UnwrapWebhookParams;
import com.telnyx.sdk.core.http.Headers;
// 在您的Webhook处理逻辑中(例如Spring — 使用原始请求体):
@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");
}
}以下Webhook事件会发送到您配置的Webhook URL。所有Webhook请求都会携带用于Ed25519签名验证的和头,可使用方法完成验证。
telnyx-timestamptelnyx-signature-ed25519client.webhooks.unwrap()| 事件 | 描述 |
|---|---|
| 传真已送达 |
| 传真发送失败 |
| 传真媒体处理完成 |
| 传真已加入队列 |
| 传真开始发送 |
Webhook payload fields
Webhook 负载字段
fax.delivered| Field | Type | Description |
|---|---|---|
| enum: event | Identifies the type of the resource. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| enum: fax.delivered | The type of event being delivered. |
| integer | The duration of the call in seconds. |
| string | The ID of the connection used to send the fax. |
| enum: inbound, outbound | The direction of the fax. |
| uuid | Identifies the fax. |
| string | The original URL to the PDF used for the fax's media. |
| string | The media_name used for the fax's media. |
| string | The phone number, in E.164 format, the fax will be sent to or SIP URI |
| string | The phone number, in E.164 format, the fax will be sent from. |
| uuid | Identifier of the user to whom the fax belongs |
| integer | Number of transferred pages |
| enum: delivered | The status of the fax. |
| string | State received from a command. |
| integer | The delivery attempt number. |
| uri | The URL the webhook was delivered to. |
fax.failed| Field | Type | Description |
|---|---|---|
| enum: event | Identifies the type of the resource. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| enum: fax.failed | The type of event being delivered. |
| string | The ID of the connection used to send the fax. |
| enum: inbound, outbound | The direction of the fax. |
| uuid | Identifies the fax. |
| string | The original URL to the PDF used for the fax's media. |
| string | The media_name used for the fax's media. |
| string | The phone number, in E.164 format, the fax will be sent to or SIP URI |
| string | The phone number, in E.164 format, the fax will be sent from. |
| uuid | Identifier of the user to whom the fax belongs |
| enum: rejected | Cause of the sending failure |
| enum: failed | The status of the fax. |
| string | State received from a command. |
| integer | The delivery attempt number. |
| uri | The URL the webhook was delivered to. |
fax.media.processed| Field | Type | Description |
|---|---|---|
| enum: event | Identifies the type of the resource. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| enum: fax.media.processed | The type of event being delivered. |
| string | The ID of the connection used to send the fax. |
| enum: inbound, outbound | The direction of the fax. |
| uuid | Identifies the fax. |
| string | The original URL to the PDF used for the fax's media. |
| string | The media_name used for the fax's media. |
| string | The phone number, in E.164 format, the fax will be sent to or SIP URI |
| string | The phone number, in E.164 format, the fax will be sent from. |
| uuid | Identifier of the user to whom the fax belongs |
| enum: media.processed | The status of the fax. |
| string | State received from a command. |
| integer | The delivery attempt number. |
| uri | The URL the webhook was delivered to. |
fax.queued| Field | Type | Description |
|---|---|---|
| enum: event | Identifies the type of the resource. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| enum: fax.queued | The type of event being delivered. |
| string | The ID of the connection used to send the fax. |
| enum: inbound, outbound | The direction of the fax. |
| uuid | Identifies the fax. |
| string | The original URL to the PDF used for the fax's media. |
| string | The media_name used for the fax's media. |
| string | The phone number, in E.164 format, the fax will be sent to or SIP URI |
| string | The phone number, in E.164 format, the fax will be sent from. |
| uuid | Identifier of the user to whom the fax belongs |
| enum: queued | The status of the fax. |
| string | State received from a command. |
| integer | The delivery attempt number. |
| uri | The URL the webhook was delivered to. |
fax.sending.started| Field | Type | Description |
|---|---|---|
| enum: event | Identifies the type of the resource. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| enum: fax.sending.started | The type of event being delivered. |
| string | The ID of the connection used to send the fax. |
| enum: inbound, outbound | The direction of the fax. |
| uuid | Identifies the fax. |
| string | The original URL to the PDF used for the fax's media. |
| string | The media_name used for the fax's media. |
| string | The phone number, in E.164 format, the fax will be sent to or SIP URI |
| string | The phone number, in E.164 format, the fax will be sent from. |
| uuid | Identifier of the user to whom the fax belongs |
| enum: sending | The status of the fax. |
| string | State received from a command. |
| integer | The delivery attempt number. |
| uri | The URL the webhook was delivered to. |
fax.delivered| 字段 | 类型 | 描述 |
|---|---|---|
| 枚举值: event | 资源类型标识 |
| uuid | 资源ID |
| date-time | 事件发生的ISO 8601格式时间 |
| 枚举值: fax.delivered | 事件类型 |
| integer | 通话时长(单位:秒) |
| string | 发送传真使用的连接ID |
| 枚举值: inbound, outbound | 传真方向 |
| uuid | 传真ID |
| string | 传真媒体源PDF的URL |
| string | 传真媒体使用的media_name |
| string | 接收方的E.164格式电话号码或SIP URI |
| string | 发送方的E.164格式电话号码 |
| uuid | 传真所属用户的ID |
| integer | 已传输的页数 |
| 枚举值: delivered | 传真状态 |
| string | 从命令中获取的状态信息 |
| integer | 投递尝试次数 |
| uri | Webhook投递的目标URL |
fax.failed| 字段 | 类型 | 描述 |
|---|---|---|
| 枚举值: event | 资源类型标识 |
| uuid | 资源ID |
| date-time | 事件发生的ISO 8601格式时间 |
| 枚举值: fax.failed | 事件类型 |
| string | 发送传真使用的连接ID |
| 枚举值: inbound, outbound | 传真方向 |
| uuid | 传真ID |
| string | 传真媒体源PDF的URL |
| string | 传真媒体使用的media_name |
| string | 接收方的E.164格式电话号码或SIP URI |
| string | 发送方的E.164格式电话号码 |
| uuid | 传真所属用户的ID |
| 枚举值: rejected | 发送失败的原因 |
| 枚举值: failed | 传真状态 |
| string | 从命令中获取的状态信息 |
| integer | 投递尝试次数 |
| uri | Webhook投递的目标URL |
fax.media.processed| 字段 | 类型 | 描述 |
|---|---|---|
| 枚举值: event | 资源类型标识 |
| uuid | 资源ID |
| date-time | 事件发生的ISO 8601格式时间 |
| 枚举值: fax.media.processed | 事件类型 |
| string | 发送传真使用的连接ID |
| 枚举值: inbound, outbound | 传真方向 |
| uuid | 传真ID |
| string | 传真媒体源PDF的URL |
| string | 传真媒体使用的media_name |
| string | 接收方的E.164格式电话号码或SIP URI |
| string | 发送方的E.164格式电话号码 |
| uuid | 传真所属用户的ID |
| 枚举值: media.processed | 传真状态 |
| string | 从命令中获取的状态信息 |
| integer | 投递尝试次数 |
| uri | Webhook投递的目标URL |
fax.queued| 字段 | 类型 | 描述 |
|---|---|---|
| 枚举值: event | 资源类型标识 |
| uuid | 资源ID |
| date-time | 事件发生的ISO 8601格式时间 |
| 枚举值: fax.queued | 事件类型 |
| string | 发送传真使用的连接ID |
| 枚举值: inbound, outbound | 传真方向 |
| uuid | 传真ID |
| string | 传真媒体源PDF的URL |
| string | 传真媒体使用的media_name |
| string | 接收方的E.164格式电话号码或SIP URI |
| string | 发送方的E.164格式电话号码 |
| uuid | 传真所属用户的ID |
| 枚举值: queued | 传真状态 |
| string | 从命令中获取的状态信息 |
| integer | 投递尝试次数 |
| uri | Webhook投递的目标URL |
fax.sending.started| 字段 | 类型 | 描述 |
|---|---|---|
| 枚举值: event | 资源类型标识 |
| uuid | 资源ID |
| date-time | 事件发生的ISO 8601格式时间 |
| 枚举值: fax.sending.started | 事件类型 |
| string | 发送传真使用的连接ID |
| 枚举值: inbound, outbound | 传真方向 |
| uuid | 传真ID |
| string | 传真媒体源PDF的URL |
| string | 传真媒体使用的media_name |
| string | 接收方的E.164格式电话号码或SIP URI |
| string | 发送方的E.164格式电话号码 |
| uuid | 传真所属用户的ID |
| 枚举值: sending | 传真状态 |
| string | 从命令中获取的状态信息 |
| integer | 投递尝试次数 |
| uri | Webhook投递的目标URL |