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
client
is already initialized as shown above.
java
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;

TelnyxClient client = TelnyxOkHttpClient.fromEnv();
以下所有示例均默认
client
已经按照上文方式完成初始化。

Error 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:
401
invalid API key,
403
insufficient permissions,
404
resource not found,
422
validation error (check field formats),
429
rate limited (retry with exponential backoff).
所有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);
    }
}
常见错误码:
401
API密钥无效,
403
权限不足,
404
资源不存在,
422
校验错误(检查字段格式),
429
触发速率限制(使用指数退避策略重试)。

Important Notes

重要注意事项

  • Phone numbers must be in E.164 format (e.g.,
    +13125550001
    ). Include the
    +
    prefix and country code. No spaces, dashes, or parentheses.
  • Pagination: List methods return a page. Use
    .autoPager()
    for automatic iteration:
    for (var item : page.autoPager()) { ... }
    . For manual control, use
    .hasNextPage()
    and
    .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_applications
java
import com.telnyx.sdk.models.faxapplications.FaxApplicationListPage;
import com.telnyx.sdk.models.faxapplications.FaxApplicationListParams;

FaxApplicationListPage page = client.faxApplications().list();
Returns:
active
(boolean),
anchorsite_override
(enum: Latency, Chicago, IL, Ashburn, VA, San Jose, CA, Sydney, Australia, Amsterdam, Netherlands, London, UK, Toronto, Canada, Vancouver, Canada, Frankfurt, Germany),
application_name
(string),
created_at
(string),
id
(string),
inbound
(object),
outbound
(object),
record_type
(string),
tags
(array[string]),
updated_at
(string),
webhook_event_failover_url
(uri),
webhook_event_url
(uri),
webhook_timeout_secs
(integer | null)
该端点返回的
data
属性中包含您的传真应用列表。您可以使用筛选参数调整返回的应用范围。传真应用用于配置Telnyx可编程传真API的收发规则。
GET /fax_applications
java
import com.telnyx.sdk.models.faxapplications.FaxApplicationListPage;
import com.telnyx.sdk.models.faxapplications.FaxApplicationListParams;

FaxApplicationListPage page = client.faxApplications().list();
返回字段:
active
(布尔值)、
anchorsite_override
(枚举值:Latency, Chicago, IL, Ashburn, VA, San Jose, CA, Sydney, Australia, Amsterdam, Netherlands, London, UK, Toronto, Canada, Vancouver, Canada, Frankfurt, Germany)、
application_name
(字符串)、
created_at
(字符串)、
id
(字符串)、
inbound
(对象)、
outbound
(对象)、
record_type
(字符串)、
tags
(字符串数组)、
updated_at
(字符串)、
webhook_event_failover_url
(URI)、
webhook_event_url
(URI)、
webhook_timeout_secs
(整数 | 空)

Creates 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
/phone_numbers
endpoint.
POST /fax_applications
— Required:
application_name
,
webhook_event_url
Optional:
active
(boolean),
anchorsite_override
(enum: Latency, Chicago, IL, Ashburn, VA, San Jose, CA, Sydney, Australia, Amsterdam, Netherlands, London, UK, Toronto, Canada, Vancouver, Canada, Frankfurt, Germany),
inbound
(object),
outbound
(object),
tags
(array[string]),
webhook_event_failover_url
(uri),
webhook_timeout_secs
(integer | null)
java
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:
active
(boolean),
anchorsite_override
(enum: Latency, Chicago, IL, Ashburn, VA, San Jose, CA, Sydney, Australia, Amsterdam, Netherlands, London, UK, Toronto, Canada, Vancouver, Canada, Frankfurt, Germany),
application_name
(string),
created_at
(string),
id
(string),
inbound
(object),
outbound
(object),
record_type
(string),
tags
(array[string]),
updated_at
(string),
webhook_event_failover_url
(uri),
webhook_event_url
(uri),
webhook_timeout_secs
(integer | null)
根据请求参数创建新的传真应用。应用名称和webhook URL为必填项。创建完成后,您可以通过
/phone_numbers
端点为应用分配电话号码。
POST /fax_applications
— 必填参数:
application_name
webhook_event_url
可选参数:
active
(布尔值)、
anchorsite_override
(枚举值:Latency, Chicago, IL, Ashburn, VA, San Jose, CA, Sydney, Australia, Amsterdam, Netherlands, London, UK, Toronto, Canada, Vancouver, Canada, Frankfurt, Germany)、
inbound
(对象)、
outbound
(对象)、
tags
(字符串数组)、
webhook_event_failover_url
(URI)、
webhook_timeout_secs
(整数 | 空)
java
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);
返回字段:
active
(布尔值)、
anchorsite_override
(枚举值:Latency, Chicago, IL, Ashburn, VA, San Jose, CA, Sydney, Australia, Amsterdam, Netherlands, London, UK, Toronto, Canada, Vancouver, Canada, Frankfurt, Germany)、
application_name
(字符串)、
created_at
(字符串)、
id
(字符串)、
inbound
(对象)、
outbound
(对象)、
record_type
(字符串)、
tags
(字符串数组)、
updated_at
(字符串)、
webhook_event_failover_url
(URI)、
webhook_event_url
(URI)、
webhook_timeout_secs
(整数 | 空)

Retrieve 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:
active
(boolean),
anchorsite_override
(enum: Latency, Chicago, IL, Ashburn, VA, San Jose, CA, Sydney, Australia, Amsterdam, Netherlands, London, UK, Toronto, Canada, Vancouver, Canada, Frankfurt, Germany),
application_name
(string),
created_at
(string),
id
(string),
inbound
(object),
outbound
(object),
record_type
(string),
tags
(array[string]),
updated_at
(string),
webhook_event_failover_url
(uri),
webhook_event_url
(uri),
webhook_timeout_secs
(integer | null)
返回的
data
属性中包含指定传真应用的详细信息。
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");
返回字段:
active
(布尔值)、
anchorsite_override
(枚举值:Latency, Chicago, IL, Ashburn, VA, San Jose, CA, Sydney, Australia, Amsterdam, Netherlands, London, UK, Toronto, Canada, Vancouver, Canada, Frankfurt, Germany)、
application_name
(字符串)、
created_at
(字符串)、
id
(字符串)、
inbound
(对象)、
outbound
(对象)、
record_type
(字符串)、
tags
(字符串数组)、
updated_at
(字符串)、
webhook_event_failover_url
(URI)、
webhook_event_url
(URI)、
webhook_timeout_secs
(整数 | 空)

Update a Fax Application

更新传真应用

Updates settings of an existing Fax Application based on the parameters of the request.
PATCH /fax_applications/{id}
— Required:
application_name
,
webhook_event_url
Optional:
active
(boolean),
anchorsite_override
(enum: Latency, Chicago, IL, Ashburn, VA, San Jose, CA, Sydney, Australia, Amsterdam, Netherlands, London, UK, Toronto, Canada, Vancouver, Canada, Frankfurt, Germany),
fax_email_recipient
(string | null),
inbound
(object),
outbound
(object),
tags
(array[string]),
webhook_event_failover_url
(uri),
webhook_timeout_secs
(integer | null)
java
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:
active
(boolean),
anchorsite_override
(enum: Latency, Chicago, IL, Ashburn, VA, San Jose, CA, Sydney, Australia, Amsterdam, Netherlands, London, UK, Toronto, Canada, Vancouver, Canada, Frankfurt, Germany),
application_name
(string),
created_at
(string),
id
(string),
inbound
(object),
outbound
(object),
record_type
(string),
tags
(array[string]),
updated_at
(string),
webhook_event_failover_url
(uri),
webhook_event_url
(uri),
webhook_timeout_secs
(integer | null)
根据请求参数更新现有传真应用的配置。
PATCH /fax_applications/{id}
— 必填参数:
application_name
webhook_event_url
可选参数:
active
(布尔值)、
anchorsite_override
(枚举值:Latency, Chicago, IL, Ashburn, VA, San Jose, CA, Sydney, Australia, Amsterdam, Netherlands, London, UK, Toronto, Canada, Vancouver, Canada, Frankfurt, Germany)、
fax_email_recipient
(字符串 | 空)、
inbound
(对象)、
outbound
(对象)、
tags
(字符串数组)、
webhook_event_failover_url
(URI)、
webhook_timeout_secs
(整数 | 空)
java
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);
返回字段:
active
(布尔值)、
anchorsite_override
(枚举值:Latency, Chicago, IL, Ashburn, VA, San Jose, CA, Sydney, Australia, Amsterdam, Netherlands, London, UK, Toronto, Canada, Vancouver, Canada, Frankfurt, Germany)、
application_name
(字符串)、
created_at
(字符串)、
id
(字符串)、
inbound
(对象)、
outbound
(对象)、
record_type
(字符串)、
tags
(字符串数组)、
updated_at
(字符串)、
webhook_event_failover_url
(URI)、
webhook_event_url
(URI)、
webhook_timeout_secs
(整数 | 空)

Deletes 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:
active
(boolean),
anchorsite_override
(enum: Latency, Chicago, IL, Ashburn, VA, San Jose, CA, Sydney, Australia, Amsterdam, Netherlands, London, UK, Toronto, Canada, Vancouver, Canada, Frankfurt, Germany),
application_name
(string),
created_at
(string),
id
(string),
inbound
(object),
outbound
(object),
record_type
(string),
tags
(array[string]),
updated_at
(string),
webhook_event_failover_url
(uri),
webhook_event_url
(uri),
webhook_timeout_secs
(integer | null)
永久删除传真应用。如果应用仍关联有电话号码,则无法完成删除。
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");
返回字段:
active
(布尔值)、
anchorsite_override
(枚举值:Latency, Chicago, IL, Ashburn, VA, San Jose, CA, Sydney, Australia, Amsterdam, Netherlands, London, UK, Toronto, Canada, Vancouver, Canada, Frankfurt, Germany)、
application_name
(字符串)、
created_at
(字符串)、
id
(字符串)、
inbound
(对象)、
outbound
(对象)、
record_type
(字符串)、
tags
(字符串数组)、
updated_at
(字符串)、
webhook_event_failover_url
(URI)、
webhook_event_url
(URI)、
webhook_timeout_secs
(整数 | 空)

View a list of faxes

获取传真列表

GET /faxes
java
import com.telnyx.sdk.models.faxes.FaxListPage;
import com.telnyx.sdk.models.faxes.FaxListParams;

FaxListPage page = client.faxes().list();
Returns:
client_state
(string),
connection_id
(string),
created_at
(date-time),
direction
(enum: inbound, outbound),
from
(string),
from_display_name
(string),
id
(uuid),
media_name
(string),
media_url
(string),
preview_url
(string),
quality
(enum: normal, high, very_high, ultra_light, ultra_dark),
record_type
(enum: fax),
status
(enum: queued, media.processed, originated, sending, delivered, failed, initiated, receiving, media.processing, received),
store_media
(boolean),
stored_media_url
(string),
to
(string),
updated_at
(date-time),
webhook_failover_url
(string),
webhook_url
(string)
GET /faxes
java
import com.telnyx.sdk.models.faxes.FaxListPage;
import com.telnyx.sdk.models.faxes.FaxListParams;

FaxListPage page = client.faxes().list();
返回字段:
client_state
(字符串)、
connection_id
(字符串)、
created_at
(日期时间)、
direction
(枚举值:inbound, outbound)、
from
(字符串)、
from_display_name
(字符串)、
id
(UUID)、
media_name
(字符串)、
media_url
(字符串)、
preview_url
(字符串)、
quality
(枚举值:normal, high, very_high, ultra_light, ultra_dark)、
record_type
(枚举值:fax)、
status
(枚举值:queued, media.processed, originated, sending, delivered, failed, initiated, receiving, media.processing, received)、
store_media
(布尔值)、
stored_media_url
(字符串)、
to
(字符串)、
updated_at
(日期时间)、
webhook_failover_url
(字符串)、
webhook_url
(字符串)

Send 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
file_size_limit_exceeded
and
page_count_limit_exceeded
respectively.
POST /faxes
— Required:
connection_id
,
from
,
to
Optional:
black_threshold
(integer),
client_state
(string),
from_display_name
(string),
media_name
(string),
media_url
(string),
monochrome
(boolean),
preview_format
(enum: pdf, tiff),
quality
(enum: normal, high, very_high, ultra_light, ultra_dark),
store_media
(boolean),
store_preview
(boolean),
t38_enabled
(boolean),
webhook_url
(string)
java
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:
client_state
(string),
connection_id
(string),
created_at
(date-time),
direction
(enum: inbound, outbound),
from
(string),
from_display_name
(string),
id
(uuid),
media_name
(string),
media_url
(string),
preview_url
(string),
quality
(enum: normal, high, very_high, ultra_light, ultra_dark),
record_type
(enum: fax),
status
(enum: queued, media.processed, originated, sending, delivered, failed, initiated, receiving, media.processing, received),
store_media
(boolean),
stored_media_url
(string),
to
(string),
updated_at
(date-time),
webhook_failover_url
(string),
webhook_url
(string)
发送传真。文件存在大小和页数限制:如果文件大于50MB或者页数超过350页,会分别返回
file_size_limit_exceeded
page_count_limit_exceeded
错误。
POST /faxes
— 必填参数:
connection_id
from
to
可选参数:
black_threshold
(整数)、
client_state
(字符串)、
from_display_name
(字符串)、
media_name
(字符串)、
media_url
(字符串)、
monochrome
(布尔值)、
preview_format
(枚举值:pdf, tiff)、
quality
(枚举值:normal, high, very_high, ultra_light, ultra_dark)、
store_media
(布尔值)、
store_preview
(布尔值)、
t38_enabled
(布尔值)、
webhook_url
(字符串)
java
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);
返回字段:
client_state
(字符串)、
connection_id
(字符串)、
created_at
(日期时间)、
direction
(枚举值:inbound, outbound)、
from
(字符串)、
from_display_name
(字符串)、
id
(UUID)、
media_name
(字符串)、
media_url
(字符串)、
preview_url
(字符串)、
quality
(枚举值:normal, high, very_high, ultra_light, ultra_dark)、
record_type
(枚举值:fax)、
status
(枚举值:queued, media.processed, originated, sending, delivered, failed, initiated, receiving, media.processing, received)、
store_media
(布尔值)、
stored_media_url
(字符串)、
to
(字符串)、
updated_at
(日期时间)、
webhook_failover_url
(字符串)、
webhook_url
(字符串)

View 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:
client_state
(string),
connection_id
(string),
created_at
(date-time),
direction
(enum: inbound, outbound),
from
(string),
from_display_name
(string),
id
(uuid),
media_name
(string),
media_url
(string),
preview_url
(string),
quality
(enum: normal, high, very_high, ultra_light, ultra_dark),
record_type
(enum: fax),
status
(enum: queued, media.processed, originated, sending, delivered, failed, initiated, receiving, media.processing, received),
store_media
(boolean),
stored_media_url
(string),
to
(string),
updated_at
(date-time),
webhook_failover_url
(string),
webhook_url
(string)
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");
返回字段:
client_state
(字符串)、
connection_id
(字符串)、
created_at
(日期时间)、
direction
(枚举值:inbound, outbound)、
from
(字符串)、
from_display_name
(字符串)、
id
(UUID)、
media_name
(字符串)、
media_url
(字符串)、
preview_url
(字符串)、
quality
(枚举值:normal, high, very_high, ultra_light, ultra_dark)、
record_type
(枚举值:fax)、
status
(枚举值:queued, media.processed, originated, sending, delivered, failed, initiated, receiving, media.processing, received)、
store_media
(布尔值)、
stored_media_url
(字符串)、
to
(字符串)、
updated_at
(日期时间)、
webhook_failover_url
(字符串)、
webhook_url
(字符串)

Delete 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:
queued
,
media.processed
,
originated
or
sending
POST /faxes/{id}/actions/cancel
java
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:
result
(string)
取消处于以下状态的外发传真:
queued
media.processed
originated
或者
sending
POST /faxes/{id}/actions/cancel
java
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");
返回字段:
result
(字符串)

Refresh a fax

刷新传真

Refreshes the inbound fax's media_url when it has expired
POST /faxes/{id}/actions/refresh
java
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:
result
(string)

当入站传真的
media_url
过期时,调用该接口刷新地址
POST /faxes/{id}/actions/refresh
java
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");
返回字段:
result
(字符串)

Webhooks

Webhooks

Webhook Verification

Webhook 签名验证

Telnyx signs webhooks with Ed25519. Each request includes
telnyx-signature-ed25519
and
telnyx-timestamp
headers. Always verify signatures in production:
java
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
telnyx-timestamp
and
telnyx-signature-ed25519
headers for Ed25519 signature verification. Use
client.webhooks.unwrap()
to verify.
EventDescription
fax.delivered
Fax Delivered
fax.failed
Fax Failed
fax.media.processed
Fax Media Processed
fax.queued
Fax Queued
fax.sending.started
Fax Sending Started
Telnyx使用Ed25519对Webhook请求签名。每个请求都会携带
telnyx-signature-ed25519
telnyx-timestamp
请求头。生产环境请务必验证签名:
java
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-timestamp
telnyx-signature-ed25519
头,可使用
client.webhooks.unwrap()
方法完成验证。
事件描述
fax.delivered
传真已送达
fax.failed
传真发送失败
fax.media.processed
传真媒体处理完成
fax.queued
传真已加入队列
fax.sending.started
传真开始发送

Webhook payload fields

Webhook 负载字段

fax.delivered
FieldTypeDescription
data.record_type
enum: eventIdentifies the type of the resource.
data.id
uuidIdentifies the type of resource.
data.occurred_at
date-timeISO 8601 datetime of when the event occurred.
data.event_type
enum: fax.deliveredThe type of event being delivered.
data.payload.call_duration_secs
integerThe duration of the call in seconds.
data.payload.connection_id
stringThe ID of the connection used to send the fax.
data.payload.direction
enum: inbound, outboundThe direction of the fax.
data.payload.fax_id
uuidIdentifies the fax.
data.payload.original_media_url
stringThe original URL to the PDF used for the fax's media.
data.payload.media_name
stringThe media_name used for the fax's media.
data.payload.to
stringThe phone number, in E.164 format, the fax will be sent to or SIP URI
data.payload.from
stringThe phone number, in E.164 format, the fax will be sent from.
data.payload.user_id
uuidIdentifier of the user to whom the fax belongs
data.payload.page_count
integerNumber of transferred pages
data.payload.status
enum: deliveredThe status of the fax.
data.payload.client_state
stringState received from a command.
meta.attempt
integerThe delivery attempt number.
meta.delivered_to
uriThe URL the webhook was delivered to.
fax.failed
FieldTypeDescription
data.record_type
enum: eventIdentifies the type of the resource.
data.id
uuidIdentifies the type of resource.
data.occurred_at
date-timeISO 8601 datetime of when the event occurred.
data.event_type
enum: fax.failedThe type of event being delivered.
data.payload.connection_id
stringThe ID of the connection used to send the fax.
data.payload.direction
enum: inbound, outboundThe direction of the fax.
data.payload.fax_id
uuidIdentifies the fax.
data.payload.original_media_url
stringThe original URL to the PDF used for the fax's media.
data.payload.media_name
stringThe media_name used for the fax's media.
data.payload.to
stringThe phone number, in E.164 format, the fax will be sent to or SIP URI
data.payload.from
stringThe phone number, in E.164 format, the fax will be sent from.
data.payload.user_id
uuidIdentifier of the user to whom the fax belongs
data.payload.failure_reason
enum: rejectedCause of the sending failure
data.payload.status
enum: failedThe status of the fax.
data.payload.client_state
stringState received from a command.
meta.attempt
integerThe delivery attempt number.
meta.delivered_to
uriThe URL the webhook was delivered to.
fax.media.processed
FieldTypeDescription
data.record_type
enum: eventIdentifies the type of the resource.
data.id
uuidIdentifies the type of resource.
data.occurred_at
date-timeISO 8601 datetime of when the event occurred.
data.event_type
enum: fax.media.processedThe type of event being delivered.
data.payload.connection_id
stringThe ID of the connection used to send the fax.
data.payload.direction
enum: inbound, outboundThe direction of the fax.
data.payload.fax_id
uuidIdentifies the fax.
data.payload.original_media_url
stringThe original URL to the PDF used for the fax's media.
data.payload.media_name
stringThe media_name used for the fax's media.
data.payload.to
stringThe phone number, in E.164 format, the fax will be sent to or SIP URI
data.payload.from
stringThe phone number, in E.164 format, the fax will be sent from.
data.payload.user_id
uuidIdentifier of the user to whom the fax belongs
data.payload.status
enum: media.processedThe status of the fax.
data.payload.client_state
stringState received from a command.
meta.attempt
integerThe delivery attempt number.
meta.delivered_to
uriThe URL the webhook was delivered to.
fax.queued
FieldTypeDescription
data.record_type
enum: eventIdentifies the type of the resource.
data.id
uuidIdentifies the type of resource.
data.occurred_at
date-timeISO 8601 datetime of when the event occurred.
data.event_type
enum: fax.queuedThe type of event being delivered.
data.payload.connection_id
stringThe ID of the connection used to send the fax.
data.payload.direction
enum: inbound, outboundThe direction of the fax.
data.payload.fax_id
uuidIdentifies the fax.
data.payload.original_media_url
stringThe original URL to the PDF used for the fax's media.
data.payload.media_name
stringThe media_name used for the fax's media.
data.payload.to
stringThe phone number, in E.164 format, the fax will be sent to or SIP URI
data.payload.from
stringThe phone number, in E.164 format, the fax will be sent from.
data.payload.user_id
uuidIdentifier of the user to whom the fax belongs
data.payload.status
enum: queuedThe status of the fax.
data.payload.client_state
stringState received from a command.
meta.attempt
integerThe delivery attempt number.
meta.delivered_to
uriThe URL the webhook was delivered to.
fax.sending.started
FieldTypeDescription
data.record_type
enum: eventIdentifies the type of the resource.
data.id
uuidIdentifies the type of resource.
data.occurred_at
date-timeISO 8601 datetime of when the event occurred.
data.event_type
enum: fax.sending.startedThe type of event being delivered.
data.payload.connection_id
stringThe ID of the connection used to send the fax.
data.payload.direction
enum: inbound, outboundThe direction of the fax.
data.payload.fax_id
uuidIdentifies the fax.
data.payload.original_media_url
stringThe original URL to the PDF used for the fax's media.
data.payload.media_name
stringThe media_name used for the fax's media.
data.payload.to
stringThe phone number, in E.164 format, the fax will be sent to or SIP URI
data.payload.from
stringThe phone number, in E.164 format, the fax will be sent from.
data.payload.user_id
uuidIdentifier of the user to whom the fax belongs
data.payload.status
enum: sendingThe status of the fax.
data.payload.client_state
stringState received from a command.
meta.attempt
integerThe delivery attempt number.
meta.delivered_to
uriThe URL the webhook was delivered to.
fax.delivered
字段类型描述
data.record_type
枚举值: event资源类型标识
data.id
uuid资源ID
data.occurred_at
date-time事件发生的ISO 8601格式时间
data.event_type
枚举值: fax.delivered事件类型
data.payload.call_duration_secs
integer通话时长(单位:秒)
data.payload.connection_id
string发送传真使用的连接ID
data.payload.direction
枚举值: inbound, outbound传真方向
data.payload.fax_id
uuid传真ID
data.payload.original_media_url
string传真媒体源PDF的URL
data.payload.media_name
string传真媒体使用的media_name
data.payload.to
string接收方的E.164格式电话号码或SIP URI
data.payload.from
string发送方的E.164格式电话号码
data.payload.user_id
uuid传真所属用户的ID
data.payload.page_count
integer已传输的页数
data.payload.status
枚举值: delivered传真状态
data.payload.client_state
string从命令中获取的状态信息
meta.attempt
integer投递尝试次数
meta.delivered_to
uriWebhook投递的目标URL
fax.failed
字段类型描述
data.record_type
枚举值: event资源类型标识
data.id
uuid资源ID
data.occurred_at
date-time事件发生的ISO 8601格式时间
data.event_type
枚举值: fax.failed事件类型
data.payload.connection_id
string发送传真使用的连接ID
data.payload.direction
枚举值: inbound, outbound传真方向
data.payload.fax_id
uuid传真ID
data.payload.original_media_url
string传真媒体源PDF的URL
data.payload.media_name
string传真媒体使用的media_name
data.payload.to
string接收方的E.164格式电话号码或SIP URI
data.payload.from
string发送方的E.164格式电话号码
data.payload.user_id
uuid传真所属用户的ID
data.payload.failure_reason
枚举值: rejected发送失败的原因
data.payload.status
枚举值: failed传真状态
data.payload.client_state
string从命令中获取的状态信息
meta.attempt
integer投递尝试次数
meta.delivered_to
uriWebhook投递的目标URL
fax.media.processed
字段类型描述
data.record_type
枚举值: event资源类型标识
data.id
uuid资源ID
data.occurred_at
date-time事件发生的ISO 8601格式时间
data.event_type
枚举值: fax.media.processed事件类型
data.payload.connection_id
string发送传真使用的连接ID
data.payload.direction
枚举值: inbound, outbound传真方向
data.payload.fax_id
uuid传真ID
data.payload.original_media_url
string传真媒体源PDF的URL
data.payload.media_name
string传真媒体使用的media_name
data.payload.to
string接收方的E.164格式电话号码或SIP URI
data.payload.from
string发送方的E.164格式电话号码
data.payload.user_id
uuid传真所属用户的ID
data.payload.status
枚举值: media.processed传真状态
data.payload.client_state
string从命令中获取的状态信息
meta.attempt
integer投递尝试次数
meta.delivered_to
uriWebhook投递的目标URL
fax.queued
字段类型描述
data.record_type
枚举值: event资源类型标识
data.id
uuid资源ID
data.occurred_at
date-time事件发生的ISO 8601格式时间
data.event_type
枚举值: fax.queued事件类型
data.payload.connection_id
string发送传真使用的连接ID
data.payload.direction
枚举值: inbound, outbound传真方向
data.payload.fax_id
uuid传真ID
data.payload.original_media_url
string传真媒体源PDF的URL
data.payload.media_name
string传真媒体使用的media_name
data.payload.to
string接收方的E.164格式电话号码或SIP URI
data.payload.from
string发送方的E.164格式电话号码
data.payload.user_id
uuid传真所属用户的ID
data.payload.status
枚举值: queued传真状态
data.payload.client_state
string从命令中获取的状态信息
meta.attempt
integer投递尝试次数
meta.delivered_to
uriWebhook投递的目标URL
fax.sending.started
字段类型描述
data.record_type
枚举值: event资源类型标识
data.id
uuid资源ID
data.occurred_at
date-time事件发生的ISO 8601格式时间
data.event_type
枚举值: fax.sending.started事件类型
data.payload.connection_id
string发送传真使用的连接ID
data.payload.direction
枚举值: inbound, outbound传真方向
data.payload.fax_id
uuid传真ID
data.payload.original_media_url
string传真媒体源PDF的URL
data.payload.media_name
string传真媒体使用的media_name
data.payload.to
string接收方的E.164格式电话号码或SIP URI
data.payload.from
string发送方的E.164格式电话号码
data.payload.user_id
uuid传真所属用户的ID
data.payload.status
枚举值: sending传真状态
data.payload.client_state
string从命令中获取的状态信息
meta.attempt
integer投递尝试次数
meta.delivered_to
uriWebhook投递的目标URL