telnyx-fax-java
Original:🇺🇸 English
Translated
Send and receive faxes programmatically. Manage fax applications and media. This skill provides Java SDK examples.
2installs
Sourceteam-telnyx/skills
Added on
NPX Install
npx skill4agent add team-telnyx/skills telnyx-fax-javaTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →<!-- Auto-generated from Telnyx OpenAPI specs. Do not edit. -->
— Required: ,
— Required: ,
— Required: , ,
Telnyx Fax - 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")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.
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).
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()
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_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_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_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_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_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_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_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_urlDelete a fax
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)
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)
resultWebhooks
Webhook Verification
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 |
Webhook payload fields
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. |