Loading...
Loading...
Port phone numbers into Telnyx. Check portability, create port orders, upload LOA documents, and track porting status. This skill provides Python SDK examples.
npx skill4agent add team-telnyx/telnyx-ext-agent-skills telnyx-porting-in-pythonpip install telnyximport os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)clientGET /porting/eventspage = client.porting.events.list()
page = page.data[0]
print(page)GET /porting/events/{id}event = client.porting.events.retrieve(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(event.data)POST /porting/events/{id}/republishclient.porting.events.republish(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)POST /porting/loa_configuration_previewresponse = client.porting.loa_configurations.preview_0(
address={
"city": "Austin",
"country_code": "US",
"state": "TX",
"street_address": "600 Congress Avenue",
"zip_code": "78701",
},
company_name="Telnyx",
contact={
"email": "testing@telnyx.com",
"phone_number": "+12003270001",
},
logo={
"document_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
},
name="My LOA Configuration",
)
print(response)
content = response.read()
print(content)GET /porting/loa_configurationspage = client.porting.loa_configurations.list()
page = page.data[0]
print(page.id)POST /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@telnyx.com",
"phone_number": "+12003270001",
},
logo={
"document_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
},
name="My LOA Configuration",
)
print(loa_configuration.data)GET /porting/loa_configurations/{id}loa_configuration = client.porting.loa_configurations.retrieve(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(loa_configuration.data)PATCH /porting/loa_configurations/{id}loa_configuration = client.porting.loa_configurations.update(
id="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@telnyx.com",
"phone_number": "+12003270001",
},
logo={
"document_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
},
name="My LOA Configuration",
)
print(loa_configuration.data)DELETE /porting/loa_configurations/{id}client.porting.loa_configurations.delete(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)GET /porting/loa_configurations/{id}/previewresponse = client.porting.loa_configurations.preview_1(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(response)
content = response.read()
print(content)GET /porting_orderspage = client.porting_orders.list()
page = page.data[0]
print(page.id)POST /porting_ordersphone_numberscustomer_group_referencecustomer_referenceporting_order = client.porting_orders.create(
phone_numbers=["+13035550000", "+13035550001", "+13035550002"],
)
print(porting_order.data)GET /porting_orders/{id}porting_order = client.porting_orders.retrieve(
id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(porting_order.data)PATCH /porting_orders/{id}activation_settingscustomer_group_referencecustomer_referencedocumentsend_usermessagingmiscphone_number_configurationrequirement_group_idrequirementsuser_feedbackwebhook_urlporting_order = client.porting_orders.update(
id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(porting_order.data)DELETE /porting_orders/{id}client.porting_orders.delete(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)POST /porting_orders/{id}/actions/activateresponse = client.porting_orders.actions.activate(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(response.data)POST /porting_orders/{id}/actions/cancelresponse = client.porting_orders.actions.cancel(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(response.data)POST /porting_orders/{id}/actions/confirmresponse = client.porting_orders.actions.confirm(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(response.data)POST /porting_orders/{id}/actions/shareresponse = client.porting_orders.actions.share(
id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(response.data)GET /porting_orders/{id}/activation_jobspage = client.porting_orders.activation_jobs.list(
id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
page = page.data[0]
print(page.id)GET /porting_orders/{id}/activation_jobs/{activationJobId}activation_job = client.porting_orders.activation_jobs.retrieve(
activation_job_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(activation_job.data)PATCH /porting_orders/{id}/activation_jobs/{activationJobId}activation_job = client.porting_orders.activation_jobs.update(
activation_job_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(activation_job.data)GET /porting_orders/{id}/additional_documentspage = client.porting_orders.additional_documents.list(
id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
page = page.data[0]
print(page.id)POST /porting_orders/{id}/additional_documentsadditional_document = client.porting_orders.additional_documents.create(
id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(additional_document.data)DELETE /porting_orders/{id}/additional_documents/{additional_document_id}client.porting_orders.additional_documents.delete(
additional_document_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)GET /porting_orders/{id}/allowed_foc_windowsresponse = client.porting_orders.retrieve_allowed_foc_windows(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(response.data)GET /porting_orders/{id}/commentspage = client.porting_orders.comments.list(
id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
page = page.data[0]
print(page.id)POST /porting_orders/{id}/commentsbodycomment = client.porting_orders.comments.create(
id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(comment.data)GET /porting_orders/{id}/loa_templateresponse = client.porting_orders.retrieve_loa_template(
id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(response)
content = response.read()
print(content)GET /porting_orders/{id}/requirementspage = client.porting_orders.retrieve_requirements(
id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
page = page.data[0]
print(page.field_type)GET /porting_orders/{id}/sub_requestresponse = client.porting_orders.retrieve_sub_request(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(response.data)GET /porting_orders/{id}/verification_codespage = client.porting_orders.verification_codes.list(
id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
page = page.data[0]
print(page.id)POST /porting_orders/{id}/verification_codes/sendclient.porting_orders.verification_codes.send(
id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)POST /porting_orders/{id}/verification_codes/verifyresponse = client.porting_orders.verification_codes.verify(
id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(response.data)GET /porting_orders/{porting_order_id}/action_requirementspage = client.porting_orders.action_requirements.list(
porting_order_id="porting_order_id",
)
page = page.data[0]
print(page.id)POST /porting_orders/{porting_order_id}/action_requirements/{id}/initiateresponse = client.porting_orders.action_requirements.initiate(
id="id",
porting_order_id="porting_order_id",
params={
"first_name": "John",
"last_name": "Doe",
},
)
print(response.data)GET /porting_orders/{porting_order_id}/associated_phone_numberspage = client.porting_orders.associated_phone_numbers.list(
porting_order_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
page = page.data[0]
print(page.id)POST /porting_orders/{porting_order_id}/associated_phone_numbersassociated_phone_number = client.porting_orders.associated_phone_numbers.create(
porting_order_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
action="keep",
phone_number_range={},
)
print(associated_phone_number.data)DELETE /porting_orders/{porting_order_id}/associated_phone_numbers/{id}associated_phone_number = client.porting_orders.associated_phone_numbers.delete(
id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
porting_order_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(associated_phone_number.data)GET /porting_orders/{porting_order_id}/phone_number_blockspage = client.porting_orders.phone_number_blocks.list(
porting_order_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
page = page.data[0]
print(page.id)POST /porting_orders/{porting_order_id}/phone_number_blocksphone_number_block = client.porting_orders.phone_number_blocks.create(
porting_order_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
activation_ranges=[{
"end_at": "+4930244999910",
"start_at": "+4930244999901",
}],
phone_number_range={
"end_at": "+4930244999910",
"start_at": "+4930244999901",
},
)
print(phone_number_block.data)DELETE /porting_orders/{porting_order_id}/phone_number_blocks/{id}phone_number_block = client.porting_orders.phone_number_blocks.delete(
id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
porting_order_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(phone_number_block.data)GET /porting_orders/{porting_order_id}/phone_number_extensionspage = client.porting_orders.phone_number_extensions.list(
porting_order_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
page = page.data[0]
print(page.id)POST /porting_orders/{porting_order_id}/phone_number_extensionsphone_number_extension = client.porting_orders.phone_number_extensions.create(
porting_order_id="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",
)
print(phone_number_extension.data)DELETE /porting_orders/{porting_order_id}/phone_number_extensions/{id}phone_number_extension = client.porting_orders.phone_number_extensions.delete(
id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
porting_order_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(phone_number_extension.data)GET /porting_orders/exception_typesresponse = client.porting_orders.retrieve_exception_types()
print(response.data)GET /porting_orders/phone_number_configurationspage = client.porting_orders.phone_number_configurations.list()
page = page.data[0]
print(page.id)POST /porting_orders/phone_number_configurationsphone_number_configuration = client.porting_orders.phone_number_configurations.create()
print(phone_number_configuration.data)GET /porting/phone_numberspage = client.porting_phone_numbers.list()
page = page.data[0]
print(page.porting_order_id)GET /porting/reportspage = client.porting.reports.list()
page = page.data[0]
print(page.id)POST /porting/reportsreport = client.porting.reports.create(
params={
"filters": {}
},
report_type="export_porting_orders_csv",
)
print(report.data)GET /porting/reports/{id}report = client.porting.reports.retrieve(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(report.data)GET /porting/uk_carriersresponse = client.porting.list_uk_carriers()
print(response.data)POST /portability_checksphone_numbersresponse = client.portability_checks.run()
print(response.data)