Loading...
Loading...
Manage account balance, payments, invoices, webhooks, and view audit logs and detail records. This skill provides Java SDK examples.
npx skill4agent add team-telnyx/skills telnyx-account-java<!-- 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.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);
}
}401403404422429.autoPager()for (var item : page.autoPager()) { ... }.hasNextPage().nextPage()GET /audit_eventsimport com.telnyx.sdk.models.auditevents.AuditEventListPage;
import com.telnyx.sdk.models.auditevents.AuditEventListParams;
AuditEventListPage page = client.auditEvents().list();alternate_resource_idchange_made_bychange_typechangescreated_atidorganization_idrecord_typeresource_iduser_idGET /balanceimport com.telnyx.sdk.models.balance.BalanceRetrieveParams;
import com.telnyx.sdk.models.balance.BalanceRetrieveResponse;
BalanceRetrieveResponse balance = client.balance().retrieve();available_creditbalancecredit_limitcurrencypendingrecord_typeGET /charges_breakdownimport com.telnyx.sdk.models.chargesbreakdown.ChargesBreakdownRetrieveParams;
import com.telnyx.sdk.models.chargesbreakdown.ChargesBreakdownRetrieveResponse;
import java.time.LocalDate;
ChargesBreakdownRetrieveParams params = ChargesBreakdownRetrieveParams.builder()
.startDate(LocalDate.parse("2025-05-01"))
.build();
ChargesBreakdownRetrieveResponse chargesBreakdown = client.chargesBreakdown().retrieve(params);currencyend_dateresultsstart_dateuser_emailuser_idGET /charges_summaryimport com.telnyx.sdk.models.chargessummary.ChargesSummaryRetrieveParams;
import com.telnyx.sdk.models.chargessummary.ChargesSummaryRetrieveResponse;
import java.time.LocalDate;
ChargesSummaryRetrieveParams params = ChargesSummaryRetrieveParams.builder()
.endDate(LocalDate.parse("2025-06-01"))
.startDate(LocalDate.parse("2025-05-01"))
.build();
ChargesSummaryRetrieveResponse chargesSummary = client.chargesSummary().retrieve(params);currencyend_datestart_datesummarytotaluser_emailuser_idGET /detail_recordsimport com.telnyx.sdk.models.detailrecords.DetailRecordListPage;
import com.telnyx.sdk.models.detailrecords.DetailRecordListParams;
DetailRecordListPage page = client.detailRecords().list();carriercarrier_feecldclicompleted_atcostcountry_codecreated_atcurrencydelivery_statusdelivery_status_failover_urldelivery_status_webhook_urldirectionerrorsfteumccmessage_typemncon_netpartsprofile_idprofile_nameraterecord_typesent_atsource_country_codestatustagsupdated_atuser_iduuidGET /invoicesimport com.telnyx.sdk.models.invoices.InvoiceListPage;
import com.telnyx.sdk.models.invoices.InvoiceListParams;
InvoiceListPage page = client.invoices().list();file_idinvoice_idpaidperiod_endperiod_starturlGET /invoices/{id}import com.telnyx.sdk.models.invoices.InvoiceRetrieveParams;
import com.telnyx.sdk.models.invoices.InvoiceRetrieveResponse;
InvoiceRetrieveResponse invoice = client.invoices().retrieve("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e");download_urlfile_idinvoice_idpaidperiod_endperiod_starturlGET /payment/auto_recharge_prefsimport com.telnyx.sdk.models.payment.autorechargeprefs.AutoRechargePrefListParams;
import com.telnyx.sdk.models.payment.autorechargeprefs.AutoRechargePrefListResponse;
AutoRechargePrefListResponse autoRechargePrefs = client.payment().autoRechargePrefs().list();enabledidinvoice_enabledpreferencerecharge_amountrecord_typethreshold_amountPATCH /payment/auto_recharge_prefsenabledinvoice_enabledpreferencerecharge_amountthreshold_amountimport com.telnyx.sdk.models.payment.autorechargeprefs.AutoRechargePrefUpdateParams;
import com.telnyx.sdk.models.payment.autorechargeprefs.AutoRechargePrefUpdateResponse;
AutoRechargePrefUpdateResponse autoRechargePref = client.payment().autoRechargePrefs().update();enabledidinvoice_enabledpreferencerecharge_amountrecord_typethreshold_amountGET /user_tagsimport com.telnyx.sdk.models.usertags.UserTagListParams;
import com.telnyx.sdk.models.usertags.UserTagListResponse;
UserTagListResponse userTags = client.userTags().list();number_tagsoutbound_profile_tagsPOST /v2/payment/stored_payment_transactionsamountimport com.telnyx.sdk.models.payment.PaymentCreateStoredPaymentTransactionParams;
import com.telnyx.sdk.models.payment.PaymentCreateStoredPaymentTransactionResponse;
PaymentCreateStoredPaymentTransactionParams params = PaymentCreateStoredPaymentTransactionParams.builder()
.amount("120.00")
.build();
PaymentCreateStoredPaymentTransactionResponse response = client.payment().createStoredPaymentTransaction(params);amount_centsamount_currencyauto_rechargecreated_atidprocessor_statusrecord_typetransaction_processing_typeGET /webhook_deliveriesimport com.telnyx.sdk.models.webhookdeliveries.WebhookDeliveryListPage;
import com.telnyx.sdk.models.webhookdeliveries.WebhookDeliveryListParams;
WebhookDeliveryListPage page = client.webhookDeliveries().list();attemptsfinished_atidrecord_typestarted_atstatususer_idwebhookGET /webhook_deliveries/{id}import com.telnyx.sdk.models.webhookdeliveries.WebhookDeliveryRetrieveParams;
import com.telnyx.sdk.models.webhookdeliveries.WebhookDeliveryRetrieveResponse;
WebhookDeliveryRetrieveResponse webhookDelivery = client.webhookDeliveries().retrieve("C9C0797E-901D-4349-A33C-C2C8F31A92C2");attemptsfinished_atidrecord_typestarted_atstatususer_idwebhook