Loading...
Loading...
Port phone numbers into Telnyx. Check portability, create port orders, upload LOA documents, and track porting status. This skill provides Ruby SDK examples.
npx skill4agent add team-telnyx/skills telnyx-porting-in-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+13125550001+.auto_paging_eachpage.auto_paging_each { |item| puts item.id }POST /portability_checksphone_numbersresponse = client.portability_checks.run(phone_numbers: ["+18005550101"])
puts(response)fast_portablenot_portable_reasonphone_numberportablerecord_typeGET /porting/eventspage = client.porting.events.list
puts(page)available_notification_methodsevent_typeidpayloadpayload_statusporting_order_idGET /porting/events/{id}event = client.porting.events.retrieve("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
puts(event)available_notification_methodsevent_typeidpayloadpayload_statusporting_order_idPOST /porting/events/{id}/republishresult = client.porting.events.republish("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
puts(result)GET /porting/loa_configurationspage = client.porting.loa_configurations.list
puts(page)addresscompany_namecontactcreated_atidlogonameorganization_idrecord_typeupdated_atPOST /porting/loa_configurationsloa_configuration = client.porting.loa_configurations.create(
address: {city: "Austin", country_code: "US", state: "TX", street_address: "600 Congress Avenue", zip_code: "78701"},
company_name: "Telnyx",
contact: {email: "testing@client.com", phone_number: "+12003270001"},
logo: {document_id: "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"},
name: "My LOA Configuration"
)
puts(loa_configuration)addresscompany_namecontactcreated_atidlogonameorganization_idrecord_typeupdated_atPOST /porting/loa_configurations/previewresponse = client.porting.loa_configurations.preview(
address: {city: "Austin", country_code: "US", state: "TX", street_address: "600 Congress Avenue", zip_code: "78701"},
company_name: "Telnyx",
contact: {email: "testing@client.com", phone_number: "+12003270001"},
logo: {document_id: "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"},
name: "My LOA Configuration"
)
puts(response)GET /porting/loa_configurations/{id}loa_configuration = client.porting.loa_configurations.retrieve("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
puts(loa_configuration)addresscompany_namecontactcreated_atidlogonameorganization_idrecord_typeupdated_atPATCH /porting/loa_configurations/{id}loa_configuration = client.porting.loa_configurations.update(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
address: {city: "Austin", country_code: "US", state: "TX", street_address: "600 Congress Avenue", zip_code: "78701"},
company_name: "Telnyx",
contact: {email: "testing@client.com", phone_number: "+12003270001"},
logo: {document_id: "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"},
name: "My LOA Configuration"
)
puts(loa_configuration)addresscompany_namecontactcreated_atidlogonameorganization_idrecord_typeupdated_atDELETE /porting/loa_configurations/{id}result = client.porting.loa_configurations.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
puts(result)GET /porting/loa_configurations/{id}/previewresponse = client.porting.loa_configurations.preview_1("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
puts(response)GET /porting/reportspage = client.porting.reports.list
puts(page)created_atdocument_ididparamsrecord_typereport_typestatusupdated_atPOST /porting/reportsreport = client.porting.reports.create(params: {filters: {}}, report_type: :export_porting_orders_csv)
puts(report)created_atdocument_ididparamsrecord_typereport_typestatusupdated_atGET /porting/reports/{id}report = client.porting.reports.retrieve("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
puts(report)created_atdocument_ididparamsrecord_typereport_typestatusupdated_atGET /porting/uk_carriersresponse = client.porting.list_uk_carriers
puts(response)alternative_cupidscreated_atcupididnamerecord_typeupdated_atGET /porting_orderspage = client.porting_orders.list
puts(page)activation_settingsadditional_stepscreated_atcustomer_group_referencecustomer_referencedescriptiondocumentsend_useridmessagingmiscold_service_provider_ocnparent_support_keyphone_number_configurationphone_number_typephone_numbersporting_phone_numbers_countrecord_typerequirementsrequirements_metstatussupport_keyupdated_atuser_feedbackuser_idwebhook_urlPOST /porting_ordersphone_numberscustomer_group_referencecustomer_referenceporting_order = client.porting_orders.create(phone_numbers: ["+13035550000", "+13035550001", "+13035550002"])
puts(porting_order)activation_settingsadditional_stepscreated_atcustomer_group_referencecustomer_referencedescriptiondocumentsend_useridmessagingmiscold_service_provider_ocnparent_support_keyphone_number_configurationphone_number_typephone_numbersporting_phone_numbers_countrecord_typerequirementsrequirements_metstatussupport_keyupdated_atuser_feedbackuser_idwebhook_urlGET /porting_orders/exception_typesresponse = client.porting_orders.retrieve_exception_types
puts(response)codedescriptionGET /porting_orders/phone_number_configurationspage = client.porting_orders.phone_number_configurations.list
puts(page)created_atidporting_phone_number_idrecord_typeupdated_atuser_bundle_idPOST /porting_orders/phone_number_configurationsphone_number_configuration = client.porting_orders.phone_number_configurations.create
puts(phone_number_configuration)created_atidporting_phone_number_idrecord_typeupdated_atuser_bundle_idGET /porting_orders/{id}porting_order = client.porting_orders.retrieve("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
puts(porting_order)activation_settingsadditional_stepscreated_atcustomer_group_referencecustomer_referencedescriptiondocumentsend_useridmessagingmiscold_service_provider_ocnparent_support_keyphone_number_configurationphone_number_typephone_numbersporting_phone_numbers_countrecord_typerequirementsrequirements_metstatussupport_keyupdated_atuser_feedbackuser_idwebhook_urlPATCH /porting_orders/{id}activation_settingscustomer_group_referencecustomer_referencedocumentsend_usermessagingmiscphone_number_configurationrequirement_group_idrequirementsuser_feedbackwebhook_urlporting_order = client.porting_orders.update("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
puts(porting_order)activation_settingsadditional_stepscreated_atcustomer_group_referencecustomer_referencedescriptiondocumentsend_useridmessagingmiscold_service_provider_ocnparent_support_keyphone_number_configurationphone_number_typephone_numbersporting_phone_numbers_countrecord_typerequirementsrequirements_metstatussupport_keyupdated_atuser_feedbackuser_idwebhook_urlDELETE /porting_orders/{id}result = client.porting_orders.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
puts(result)POST /porting_orders/{id}/actions/activateresponse = client.porting_orders.actions.activate("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
puts(response)activate_atactivation_typeactivation_windowscreated_atidrecord_typestatusupdated_atPOST /porting_orders/{id}/actions/cancelresponse = client.porting_orders.actions.cancel("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
puts(response)activation_settingsadditional_stepscreated_atcustomer_group_referencecustomer_referencedescriptiondocumentsend_useridmessagingmiscold_service_provider_ocnparent_support_keyphone_number_configurationphone_number_typephone_numbersporting_phone_numbers_countrecord_typerequirementsrequirements_metstatussupport_keyupdated_atuser_feedbackuser_idwebhook_urlPOST /porting_orders/{id}/actions/confirmresponse = client.porting_orders.actions.confirm("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
puts(response)activation_settingsadditional_stepscreated_atcustomer_group_referencecustomer_referencedescriptiondocumentsend_useridmessagingmiscold_service_provider_ocnparent_support_keyphone_number_configurationphone_number_typephone_numbersporting_phone_numbers_countrecord_typerequirementsrequirements_metstatussupport_keyupdated_atuser_feedbackuser_idwebhook_urlPOST /porting_orders/{id}/actions/shareresponse = client.porting_orders.actions.share("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
puts(response)created_atexpires_atexpires_in_secondsidpermissionsporting_order_idrecord_typetokenGET /porting_orders/{id}/activation_jobspage = client.porting_orders.activation_jobs.list("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
puts(page)activate_atactivation_typeactivation_windowscreated_atidrecord_typestatusupdated_atGET /porting_orders/{id}/activation_jobs/{activationJobId}activation_job = client.porting_orders.activation_jobs.retrieve(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
id: "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
)
puts(activation_job)activate_atactivation_typeactivation_windowscreated_atidrecord_typestatusupdated_atPATCH /porting_orders/{id}/activation_jobs/{activationJobId}activation_job = client.porting_orders.activation_jobs.update(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
id: "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
)
puts(activation_job)activate_atactivation_typeactivation_windowscreated_atidrecord_typestatusupdated_atGET /porting_orders/{id}/additional_documentspage = client.porting_orders.additional_documents.list("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
puts(page)content_typecreated_atdocument_iddocument_typefilenameidporting_order_idrecord_typeupdated_atPOST /porting_orders/{id}/additional_documentsadditional_document = client.porting_orders.additional_documents.create("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
puts(additional_document)content_typecreated_atdocument_iddocument_typefilenameidporting_order_idrecord_typeupdated_atDELETE /porting_orders/{id}/additional_documents/{additional_document_id}result = client.porting_orders.additional_documents.delete(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
id: "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
)
puts(result)GET /porting_orders/{id}/allowed_foc_windowsresponse = client.porting_orders.retrieve_allowed_foc_windows("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
puts(response)ended_atrecord_typestarted_atGET /porting_orders/{id}/commentspage = client.porting_orders.comments.list("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
puts(page)bodycreated_atidporting_order_idrecord_typeuser_typePOST /porting_orders/{id}/commentsbodycomment = client.porting_orders.comments.create("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
puts(comment)bodycreated_atidporting_order_idrecord_typeuser_typeGET /porting_orders/{id}/loa_templateresponse = client.porting_orders.retrieve_loa_template("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
puts(response)GET /porting_orders/{id}/requirementspage = client.porting_orders.retrieve_requirements("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
puts(page)field_typefield_valuerecord_typerequirement_statusrequirement_typeGET /porting_orders/{id}/sub_requestresponse = client.porting_orders.retrieve_sub_request("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
puts(response)port_request_idsub_request_idGET /porting_orders/{id}/verification_codespage = client.porting_orders.verification_codes.list("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
puts(page)created_atidphone_numberporting_order_idrecord_typeupdated_atverifiedPOST /porting_orders/{id}/verification_codes/sendresult = client.porting_orders.verification_codes.send_("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
puts(result)POST /porting_orders/{id}/verification_codes/verifyresponse = client.porting_orders.verification_codes.verify("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
puts(response)created_atidphone_numberporting_order_idrecord_typeupdated_atverifiedGET /porting_orders/{porting_order_id}/action_requirementspage = client.porting_orders.action_requirements.list("porting_order_id")
puts(page)action_typeaction_urlcancel_reasoncreated_atidporting_order_idrecord_typerequirement_type_idstatusupdated_atPOST /porting_orders/{porting_order_id}/action_requirements/{id}/initiateresponse = client.porting_orders.action_requirements.initiate(
"id",
porting_order_id: "550e8400-e29b-41d4-a716-446655440000",
params: {first_name: "John", last_name: "Doe"}
)
puts(response)action_typeaction_urlcancel_reasoncreated_atidporting_order_idrecord_typerequirement_type_idstatusupdated_atGET /porting_orders/{porting_order_id}/associated_phone_numberspage = client.porting_orders.associated_phone_numbers.list("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
puts(page)actioncountry_codecreated_atidphone_number_rangephone_number_typeporting_order_idrecord_typeupdated_atPOST /porting_orders/{porting_order_id}/associated_phone_numbersassociated_phone_number = client.porting_orders.associated_phone_numbers.create(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
action: :keep,
phone_number_range: {}
)
puts(associated_phone_number)actioncountry_codecreated_atidphone_number_rangephone_number_typeporting_order_idrecord_typeupdated_atDELETE /porting_orders/{porting_order_id}/associated_phone_numbers/{id}associated_phone_number = client.porting_orders.associated_phone_numbers.delete(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
porting_order_id: "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
)
puts(associated_phone_number)actioncountry_codecreated_atidphone_number_rangephone_number_typeporting_order_idrecord_typeupdated_atGET /porting_orders/{porting_order_id}/phone_number_blockspage = client.porting_orders.phone_number_blocks.list("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
puts(page)activation_rangescountry_codecreated_atidphone_number_rangephone_number_typerecord_typeupdated_atPOST /porting_orders/{porting_order_id}/phone_number_blocksphone_number_block = client.porting_orders.phone_number_blocks.create(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
activation_ranges: [{end_at: "+4930244999910", start_at: "+4930244999901"}],
phone_number_range: {end_at: "+4930244999910", start_at: "+4930244999901"}
)
puts(phone_number_block)activation_rangescountry_codecreated_atidphone_number_rangephone_number_typerecord_typeupdated_atDELETE /porting_orders/{porting_order_id}/phone_number_blocks/{id}phone_number_block = client.porting_orders.phone_number_blocks.delete(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
porting_order_id: "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
)
puts(phone_number_block)activation_rangescountry_codecreated_atidphone_number_rangephone_number_typerecord_typeupdated_atGET /porting_orders/{porting_order_id}/phone_number_extensionspage = client.porting_orders.phone_number_extensions.list("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
puts(page)activation_rangescreated_atextension_rangeidporting_phone_number_idrecord_typeupdated_atPOST /porting_orders/{porting_order_id}/phone_number_extensionsphone_number_extension = client.porting_orders.phone_number_extensions.create(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
activation_ranges: [{end_at: 10, start_at: 1}],
extension_range: {end_at: 10, start_at: 1},
porting_phone_number_id: "f24151b6-3389-41d3-8747-7dd8c681e5e2"
)
puts(phone_number_extension)activation_rangescreated_atextension_rangeidporting_phone_number_idrecord_typeupdated_atDELETE /porting_orders/{porting_order_id}/phone_number_extensions/{id}phone_number_extension = client.porting_orders.phone_number_extensions.delete(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
porting_order_id: "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
)
puts(phone_number_extension)activation_rangescreated_atextension_rangeidporting_phone_number_idrecord_typeupdated_atGET /porting_phone_numberspage = client.porting_phone_numbers.list
puts(page)activation_statusphone_numberphone_number_typeportability_statusporting_order_idporting_order_statusrecord_typerequirements_statussupport_key