Loading...
Loading...
Manage account balance, payments, invoices, webhooks, and view audit logs and detail records. This skill provides Ruby SDK examples.
npx skill4agent add team-telnyx/skills telnyx-account-rubygem install telnyxrequire "telnyx"
client = Telnyx::Client.new(
api_key: ENV["TELNYX_API_KEY"], # This is the default and can be omitted
)clientbegin
result = client.messages.send_(to: "+13125550001", from: "+13125550002", text: "Hello")
rescue Telnyx::Errors::APIConnectionError
puts "Network error — check connectivity and retry"
rescue Telnyx::Errors::RateLimitError
# 429: rate limited — wait and retry with exponential backoff
sleep(1) # Check Retry-After header for actual delay
rescue Telnyx::Errors::APIStatusError => e
puts "API error #{e.status}: #{e.message}"
if e.status == 422
puts "Validation error — check required fields and formats"
end
end401403404422429.auto_paging_eachpage.auto_paging_each { |item| puts item.id }GET /audit_eventspage = client.audit_events.list
puts(page)alternate_resource_idchange_made_bychange_typechangescreated_atidorganization_idrecord_typeresource_iduser_idGET /balancebalance = client.balance.retrieve
puts(balance)available_creditbalancecredit_limitcurrencypendingrecord_typeGET /charges_breakdowncharges_breakdown = client.charges_breakdown.retrieve(start_date: "2025-05-01")
puts(charges_breakdown)currencyend_dateresultsstart_dateuser_emailuser_idGET /charges_summarycharges_summary = client.charges_summary.retrieve(end_date: "2025-06-01", start_date: "2025-05-01")
puts(charges_summary)currencyend_datestart_datesummarytotaluser_emailuser_idGET /detail_recordspage = client.detail_records.list
puts(page)carriercarrier_feecldclicompleted_atcostcountry_codecreated_atcurrencydelivery_statusdelivery_status_failover_urldelivery_status_webhook_urldirectionerrorsfteumccmessage_typemncon_netpartsprofile_idprofile_nameraterecord_typesent_atsource_country_codestatustagsupdated_atuser_iduuidGET /invoicespage = client.invoices.list
puts(page)file_idinvoice_idpaidperiod_endperiod_starturlGET /invoices/{id}invoice = client.invoices.retrieve("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
puts(invoice)download_urlfile_idinvoice_idpaidperiod_endperiod_starturlGET /payment/auto_recharge_prefsauto_recharge_prefs = client.payment.auto_recharge_prefs.list
puts(auto_recharge_prefs)enabledidinvoice_enabledpreferencerecharge_amountrecord_typethreshold_amountPATCH /payment/auto_recharge_prefsenabledinvoice_enabledpreferencerecharge_amountthreshold_amountauto_recharge_pref = client.payment.auto_recharge_prefs.update
puts(auto_recharge_pref)enabledidinvoice_enabledpreferencerecharge_amountrecord_typethreshold_amountGET /user_tagsuser_tags = client.user_tags.list
puts(user_tags)number_tagsoutbound_profile_tagsPOST /v2/payment/stored_payment_transactionsamountresponse = client.payment.create_stored_payment_transaction(amount: "120.00")
puts(response)amount_centsamount_currencyauto_rechargecreated_atidprocessor_statusrecord_typetransaction_processing_typeGET /webhook_deliveriespage = client.webhook_deliveries.list
puts(page)attemptsfinished_atidrecord_typestarted_atstatususer_idwebhookGET /webhook_deliveries/{id}webhook_delivery = client.webhook_deliveries.retrieve("C9C0797E-901D-4349-A33C-C2C8F31A92C2")
puts(webhook_delivery)attemptsfinished_atidrecord_typestarted_atstatususer_idwebhook