telnyx-sip-integrations-python
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese<!-- Auto-generated from Telnyx OpenAPI specs. Do not edit. -->
<!-- Auto-generated from Telnyx OpenAPI specs. Do not edit. -->
Telnyx Sip Integrations - Python
Telnyx SIP集成 - Python 版
Installation
安装
bash
pip install telnyxbash
pip install telnyxSetup
配置
python
import os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)All examples below assume is already initialized as shown above.
clientpython
import os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # 这是默认配置,可以省略
)以下所有示例都假设已经按照上述方式完成初始化。
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:
python
import telnyx
try:
result = client.messages.send(to="+13125550001", from_="+13125550002", text="Hello")
except telnyx.APIConnectionError:
print("Network error — check connectivity and retry")
except telnyx.RateLimitError:
# 429: rate limited — wait and retry with exponential backoff
import time
time.sleep(1) # Check Retry-After header for actual delay
except telnyx.APIStatusError as e:
print(f"API error {e.status_code}: {e.message}")
if e.status_code == 422:
print("Validation error — check required fields and formats")Common error codes: invalid API key, insufficient permissions,
resource not found, validation error (check field formats),
rate limited (retry with exponential backoff).
401403404422429所有API调用都可能失败,原因包括网络错误、速率限制(429)、校验错误(422)、或者鉴权错误(401)。在生产代码中请务必做好错误处理:
python
import telnyx
try:
result = client.messages.send(to="+13125550001", from_="+13125550002", text="Hello")
except telnyx.APIConnectionError:
print("网络错误 — 检查网络连接并重试")
except telnyx.RateLimitError:
# 429: 触发速率限制 — 等待后使用指数退避策略重试
import time
time.sleep(1) # 可查看Retry-After响应头获取准确的等待时长
except telnyx.APIStatusError as e:
print(f"API错误 {e.status_code}: {e.message}")
if e.status_code == 422:
print("校验错误 — 检查必填字段和格式是否正确")常见错误码: 无效的API密钥, 权限不足, 资源不存在, 校验错误(请检查字段格式), 触发速率限制(请使用指数退避策略重试)。
401403404422429Important Notes
重要注意事项
- Pagination: List methods return an auto-paginating iterator. Use to iterate through all pages automatically.
for item in page_result:
- 分页: 列表类方法返回支持自动分页的迭代器。使用可以自动遍历所有分页的内容。
for item in page_result:
Retrieve a stored credential
获取存储的凭证
Returns the information about custom storage credentials.
GET /custom_storage_credentials/{connection_id}python
custom_storage_credential = client.custom_storage_credentials.retrieve(
"connection_id",
)
print(custom_storage_credential.connection_id)Returns: (enum: gcs, s3, azure), (object)
backendconfiguration返回自定义存储凭证的相关信息。
GET /custom_storage_credentials/{connection_id}python
custom_storage_credential = client.custom_storage_credentials.retrieve(
"connection_id",
)
print(custom_storage_credential.connection_id)返回: (枚举: gcs, s3, azure), (对象)
backendconfigurationCreate a custom storage credential
创建自定义存储凭证
Creates a custom storage credentials configuration.
POST /custom_storage_credentials/{connection_id}python
custom_storage_credential = client.custom_storage_credentials.create(
connection_id="550e8400-e29b-41d4-a716-446655440000",
backend="gcs",
configuration={
"backend": "gcs"
},
)
print(custom_storage_credential.connection_id)Returns: (enum: gcs, s3, azure), (object)
backendconfiguration创建自定义存储凭证配置。
POST /custom_storage_credentials/{connection_id}python
custom_storage_credential = client.custom_storage_credentials.create(
connection_id="550e8400-e29b-41d4-a716-446655440000",
backend="gcs",
configuration={
"backend": "gcs"
},
)
print(custom_storage_credential.connection_id)返回: (枚举: gcs, s3, azure), (对象)
backendconfigurationUpdate a stored credential
更新存储的凭证
Updates a stored custom credentials configuration.
PUT /custom_storage_credentials/{connection_id}python
custom_storage_credential = client.custom_storage_credentials.update(
connection_id="550e8400-e29b-41d4-a716-446655440000",
backend="gcs",
configuration={
"backend": "gcs"
},
)
print(custom_storage_credential.connection_id)Returns: (enum: gcs, s3, azure), (object)
backendconfiguration更新已存储的自定义凭证配置。
PUT /custom_storage_credentials/{connection_id}python
custom_storage_credential = client.custom_storage_credentials.update(
connection_id="550e8400-e29b-41d4-a716-446655440000",
backend="gcs",
configuration={
"backend": "gcs"
},
)
print(custom_storage_credential.connection_id)返回: (枚举: gcs, s3, azure), (对象)
backendconfigurationDelete a stored credential
删除存储的凭证
Deletes a stored custom credentials configuration.
DELETE /custom_storage_credentials/{connection_id}python
client.custom_storage_credentials.delete(
"connection_id",
)删除已存储的自定义凭证配置。
DELETE /custom_storage_credentials/{connection_id}python
client.custom_storage_credentials.delete(
"connection_id",
)Retrieve stored Dialogflow Connection
获取存储的Dialogflow连接
Return details of the Dialogflow connection associated with the given CallControl connection.
GET /dialogflow_connections/{connection_id}python
dialogflow_connection = client.dialogflow_connections.retrieve(
"connection_id",
)
print(dialogflow_connection.data)Returns: (string), (string), (string), (string), (string)
connection_idconversation_profile_idenvironmentrecord_typeservice_account返回与指定CallControl关联的Dialogflow连接详情。
GET /dialogflow_connections/{connection_id}python
dialogflow_connection = client.dialogflow_connections.retrieve(
"connection_id",
)
print(dialogflow_connection.data)返回: (字符串), (字符串), (字符串), (字符串), (字符串)
connection_idconversation_profile_idenvironmentrecord_typeservice_accountCreate a Dialogflow Connection
创建Dialogflow连接
Save Dialogflow Credentiails to Telnyx, so it can be used with other Telnyx services.
POST /dialogflow_connections/{connection_id}python
dialogflow_connection = client.dialogflow_connections.create(
connection_id="550e8400-e29b-41d4-a716-446655440000",
service_account={
"type": "bar",
"project_id": "bar",
"private_key_id": "bar",
"private_key": "bar",
"client_email": "bar",
"client_id": "bar",
"auth_uri": "bar",
"token_uri": "bar",
"auth_provider_x509_cert_url": "bar",
"client_x509_cert_url": "bar",
},
)
print(dialogflow_connection.data)Returns: (string), (string), (string), (string), (string)
connection_idconversation_profile_idenvironmentrecord_typeservice_account将Dialogflow凭证保存到Telnyx,以便与其他Telnyx服务配合使用。
POST /dialogflow_connections/{connection_id}python
dialogflow_connection = client.dialogflow_connections.create(
connection_id="550e8400-e29b-41d4-a716-446655440000",
service_account={
"type": "bar",
"project_id": "bar",
"private_key_id": "bar",
"private_key": "bar",
"client_email": "bar",
"client_id": "bar",
"auth_uri": "bar",
"token_uri": "bar",
"auth_provider_x509_cert_url": "bar",
"client_x509_cert_url": "bar",
},
)
print(dialogflow_connection.data)返回: (字符串), (字符串), (字符串), (字符串), (字符串)
connection_idconversation_profile_idenvironmentrecord_typeservice_accountUpdate stored Dialogflow Connection
更新存储的Dialogflow连接
Updates a stored Dialogflow Connection.
PUT /dialogflow_connections/{connection_id}python
dialogflow_connection = client.dialogflow_connections.update(
connection_id="550e8400-e29b-41d4-a716-446655440000",
service_account={
"type": "bar",
"project_id": "bar",
"private_key_id": "bar",
"private_key": "bar",
"client_email": "bar",
"client_id": "bar",
"auth_uri": "bar",
"token_uri": "bar",
"auth_provider_x509_cert_url": "bar",
"client_x509_cert_url": "bar",
},
)
print(dialogflow_connection.data)Returns: (string), (string), (string), (string), (string)
connection_idconversation_profile_idenvironmentrecord_typeservice_account更新已存储的Dialogflow连接。
PUT /dialogflow_connections/{connection_id}python
dialogflow_connection = client.dialogflow_connections.update(
connection_id="550e8400-e29b-41d4-a716-446655440000",
service_account={
"type": "bar",
"project_id": "bar",
"private_key_id": "bar",
"private_key": "bar",
"client_email": "bar",
"client_id": "bar",
"auth_uri": "bar",
"token_uri": "bar",
"auth_provider_x509_cert_url": "bar",
"client_x509_cert_url": "bar",
},
)
print(dialogflow_connection.data)返回: (字符串), (字符串), (字符串), (字符串), (字符串)
connection_idconversation_profile_idenvironmentrecord_typeservice_accountDelete stored Dialogflow Connection
删除存储的Dialogflow连接
Deletes a stored Dialogflow Connection.
DELETE /dialogflow_connections/{connection_id}python
client.dialogflow_connections.delete(
"connection_id",
)删除已存储的Dialogflow连接。
DELETE /dialogflow_connections/{connection_id}python
client.dialogflow_connections.delete(
"connection_id",
)List all External Connections
获取所有外部连接列表
This endpoint returns a list of your External Connections inside the 'data' attribute of the response. External Connections are used by Telnyx customers to seamless configure SIP trunking integrations with Telnyx Partners, through External Voice Integrations in Mission Control Portal.
GET /external_connectionspython
page = client.external_connections.list()
page = page.data[0]
print(page.id)Returns: (boolean), (string), (boolean), (enum: zoom, operator_connect), (string), (object), (object), (string), (array[string]), (string), (enum: 1, 2), (uri), (uri), (integer | null)
activecreated_atcredential_activeexternal_sip_connectionidinboundoutboundrecord_typetagsupdated_atwebhook_api_versionwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secs该接口返回你的外部连接列表,存放在响应的属性中。Telnyx用户可以通过Mission Control Portal中的外部语音集成功能,使用外部连接无缝配置与Telnyx合作伙伴的SIP中继集成。
dataGET /external_connectionspython
page = client.external_connections.list()
page = page.data[0]
print(page.id)返回: (布尔值), (字符串), (布尔值), (枚举: zoom, operator_connect), (字符串), (对象), (对象), (字符串), (字符串数组), (字符串), (枚举: 1, 2), (uri), (uri), (整数 | 空)
activecreated_atcredential_activeexternal_sip_connectionidinboundoutboundrecord_typetagsupdated_atwebhook_api_versionwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsCreates an External Connection
创建外部连接
Creates a new External Connection based on the parameters sent in the request. The external_sip_connection and outbound voice profile id are required. Once created, you can assign phone numbers to your application using the endpoint.
/phone_numbersPOST /external_connectionsexternal_sip_connectionoutboundOptional: (boolean), (object), (array[string]), (uri), (uri), (integer | null)
activeinboundtagswebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secspython
external_connection = client.external_connections.create(
external_sip_connection="zoom",
outbound={},
)
print(external_connection.data)Returns: (boolean), (string), (boolean), (enum: zoom, operator_connect), (string), (object), (object), (string), (array[string]), (string), (enum: 1, 2), (uri), (uri), (integer | null)
activecreated_atcredential_activeexternal_sip_connectionidinboundoutboundrecord_typetagsupdated_atwebhook_api_versionwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secs根据请求参数创建新的外部连接。和outbound语音配置ID为必填项。创建完成后,你可以使用接口为你的应用分配电话号码。
external_sip_connection/phone_numbersPOST /external_connectionsexternal_sip_connectionoutbound可选参数: (布尔值), (对象), (字符串数组), (uri), (uri), (整数 | 空)
activeinboundtagswebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secspython
external_connection = client.external_connections.create(
external_sip_connection="zoom",
outbound={},
)
print(external_connection.data)返回: (布尔值), (字符串), (布尔值), (枚举: zoom, operator_connect), (字符串), (对象), (对象), (字符串), (字符串数组), (字符串), (枚举: 1, 2), (uri), (uri), (整数 | 空)
activecreated_atcredential_activeexternal_sip_connectionidinboundoutboundrecord_typetagsupdated_atwebhook_api_versionwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsList all log messages
获取所有日志消息
Retrieve a list of log messages for all external connections associated with your account.
GET /external_connections/log_messagespython
page = client.external_connections.log_messages.list()
page = page.log_messages[0]
print(page.code)Returns: (array[object]), (object)
log_messagesmeta获取你账户下所有外部连接的日志消息列表。
GET /external_connections/log_messagespython
page = client.external_connections.log_messages.list()
page = page.log_messages[0]
print(page.code)返回: (对象数组), (对象)
log_messagesmetaRetrieve a log message
获取单条日志消息
Retrieve a log message for an external connection associated with your account.
GET /external_connections/log_messages/{id}python
log_message = client.external_connections.log_messages.retrieve(
"1293384261075731499",
)
print(log_message.log_messages)Returns: (array[object])
log_messages获取你账户下指定外部连接的单条日志消息。
GET /external_connections/log_messages/{id}python
log_message = client.external_connections.log_messages.retrieve(
"1293384261075731499",
)
print(log_message.log_messages)返回: (对象数组)
log_messagesDismiss a log message
标记日志消息为已处理
Dismiss a log message for an external connection associated with your account.
DELETE /external_connections/log_messages/{id}python
response = client.external_connections.log_messages.dismiss(
"1293384261075731499",
)
print(response.success)Returns: (boolean)
success将你账户下指定外部连接的单条日志消息标记为已处理。
DELETE /external_connections/log_messages/{id}python
response = client.external_connections.log_messages.dismiss(
"1293384261075731499",
)
print(response.success)返回: (布尔值)
successRetrieve an External Connection
获取单条外部连接
Return the details of an existing External Connection inside the 'data' attribute of the response.
GET /external_connections/{id}python
external_connection = client.external_connections.retrieve(
"1293384261075731499",
)
print(external_connection.data)Returns: (boolean), (string), (boolean), (enum: zoom, operator_connect), (string), (object), (object), (string), (array[string]), (string), (enum: 1, 2), (uri), (uri), (integer | null)
activecreated_atcredential_activeexternal_sip_connectionidinboundoutboundrecord_typetagsupdated_atwebhook_api_versionwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secs返回现有外部连接的详情,存放在响应的属性中。
dataGET /external_connections/{id}python
external_connection = client.external_connections.retrieve(
"1293384261075731499",
)
print(external_connection.data)返回: (布尔值), (字符串), (布尔值), (枚举: zoom, operator_connect), (字符串), (对象), (对象), (字符串), (字符串数组), (字符串), (枚举: 1, 2), (uri), (uri), (整数 | 空)
activecreated_atcredential_activeexternal_sip_connectionidinboundoutboundrecord_typetagsupdated_atwebhook_api_versionwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsUpdate an External Connection
更新外部连接
Updates settings of an existing External Connection based on the parameters of the request.
PATCH /external_connections/{id}outboundOptional: (boolean), (object), (array[string]), (uri), (uri), (integer | null)
activeinboundtagswebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secspython
external_connection = client.external_connections.update(
id="1293384261075731499",
outbound={
"outbound_voice_profile_id": "1911630617284445511"
},
)
print(external_connection.data)Returns: (boolean), (string), (boolean), (enum: zoom, operator_connect), (string), (object), (object), (string), (array[string]), (string), (enum: 1, 2), (uri), (uri), (integer | null)
activecreated_atcredential_activeexternal_sip_connectionidinboundoutboundrecord_typetagsupdated_atwebhook_api_versionwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secs根据请求参数更新现有外部连接的配置。
PATCH /external_connections/{id}outbound可选参数: (布尔值), (对象), (字符串数组), (uri), (uri), (整数 | 空)
activeinboundtagswebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secspython
external_connection = client.external_connections.update(
id="1293384261075731499",
outbound={
"outbound_voice_profile_id": "1911630617284445511"
},
)
print(external_connection.data)返回: (布尔值), (字符串), (布尔值), (枚举: zoom, operator_connect), (字符串), (对象), (对象), (字符串), (字符串数组), (字符串), (枚举: 1, 2), (uri), (uri), (整数 | 空)
activecreated_atcredential_activeexternal_sip_connectionidinboundoutboundrecord_typetagsupdated_atwebhook_api_versionwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsDeletes an External Connection
删除外部连接
Permanently deletes an External Connection. Deletion may be prevented if the application is in use by phone numbers, is active, or if it is an Operator Connect connection. To remove an Operator Connect integration please contact Telnyx support.
DELETE /external_connections/{id}python
external_connection = client.external_connections.delete(
"1293384261075731499",
)
print(external_connection.data)Returns: (boolean), (string), (boolean), (enum: zoom, operator_connect), (string), (object), (object), (string), (array[string]), (string), (enum: 1, 2), (uri), (uri), (integer | null)
activecreated_atcredential_activeexternal_sip_connectionidinboundoutboundrecord_typetagsupdated_atwebhook_api_versionwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secs永久删除外部连接。如果应用正被电话号码使用、处于激活状态,或者是Operator Connect连接,则可能无法删除。如需移除Operator Connect集成,请联系Telnyx支持团队。
DELETE /external_connections/{id}python
external_connection = client.external_connections.delete(
"1293384261075731499",
)
print(external_connection.data)返回: (布尔值), (字符串), (布尔值), (枚举: zoom, operator_connect), (字符串), (对象), (对象), (字符串), (字符串数组), (字符串), (枚举: 1, 2), (uri), (uri), (整数 | 空)
activecreated_atcredential_activeexternal_sip_connectionidinboundoutboundrecord_typetagsupdated_atwebhook_api_versionwebhook_event_failover_urlwebhook_event_urlwebhook_timeout_secsList all civic addresses and locations
获取所有市政地址和位置
Returns the civic addresses and locations from Microsoft Teams.
GET /external_connections/{id}/civic_addressespython
civic_addresses = client.external_connections.civic_addresses.list(
id="1293384261075731499",
)
print(civic_addresses.data)Returns: (string), (string), (string), (string), (string), (uuid), (string), (string), (string), (uuid), (array[object]), (string), (string), (string), (string), (string)
city_or_towncity_or_town_aliascompany_namecountrycountry_or_districtdefault_location_iddescriptionhouse_numberhouse_number_suffixidlocationspostal_or_zip_coderecord_typestate_or_provincestreet_namestreet_suffix返回Microsoft Teams中的市政地址和位置列表。
GET /external_connections/{id}/civic_addressespython
civic_addresses = client.external_connections.civic_addresses.list(
id="1293384261075731499",
)
print(civic_addresses.data)返回: (字符串), (字符串), (字符串), (字符串), (字符串), (uuid), (字符串), (字符串), (字符串), (uuid), (对象数组), (字符串), (字符串), (字符串), (字符串), (字符串)
city_or_towncity_or_town_aliascompany_namecountrycountry_or_districtdefault_location_iddescriptionhouse_numberhouse_number_suffixidlocationspostal_or_zip_coderecord_typestate_or_provincestreet_namestreet_suffixRetrieve a Civic Address
获取单条市政地址
Return the details of an existing Civic Address with its Locations inside the 'data' attribute of the response.
GET /external_connections/{id}/civic_addresses/{address_id}python
civic_address = client.external_connections.civic_addresses.retrieve(
address_id="318fb664-d341-44d2-8405-e6bfb9ced6d9",
id="1293384261075731499",
)
print(civic_address.data)Returns: (string), (string), (string), (string), (string), (uuid), (string), (string), (string), (uuid), (array[object]), (string), (string), (string), (string), (string)
city_or_towncity_or_town_aliascompany_namecountrycountry_or_districtdefault_location_iddescriptionhouse_numberhouse_number_suffixidlocationspostal_or_zip_coderecord_typestate_or_provincestreet_namestreet_suffix返回现有市政地址及其位置的详情,存放在响应的属性中。
dataGET /external_connections/{id}/civic_addresses/{address_id}python
civic_address = client.external_connections.civic_addresses.retrieve(
address_id="318fb664-d341-44d2-8405-e6bfb9ced6d9",
id="1293384261075731499",
)
print(civic_address.data)返回: (字符串), (字符串), (字符串), (字符串), (字符串), (uuid), (字符串), (字符串), (字符串), (uuid), (对象数组), (字符串), (字符串), (字符串), (字符串), (字符串)
city_or_towncity_or_town_aliascompany_namecountrycountry_or_districtdefault_location_iddescriptionhouse_numberhouse_number_suffixidlocationspostal_or_zip_coderecord_typestate_or_provincestreet_namestreet_suffixUpdate a location's static emergency address
更新位置的静态紧急地址
PATCH /external_connections/{id}/locations/{location_id}static_emergency_address_idpython
response = client.external_connections.update_location(
location_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
static_emergency_address_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(response.data)Returns: (boolean), (uuid), (uuid)
accepted_address_suggestionslocation_idstatic_emergency_address_idPATCH /external_connections/{id}/locations/{location_id}static_emergency_address_idpython
response = client.external_connections.update_location(
location_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
static_emergency_address_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
print(response.data)返回: (布尔值), (uuid), (uuid)
accepted_address_suggestionslocation_idstatic_emergency_address_idList all phone numbers
获取所有电话号码
Returns a list of all active phone numbers associated with the given external connection.
GET /external_connections/{id}/phone_numberspython
page = client.external_connections.phone_numbers.list(
id="1293384261075731499",
)
page = page.data[0]
print(page.civic_address_id)Returns: (array[string]), (uuid), (string), (uuid), (string), (string), (uuid)
acquired_capabilitiescivic_address_iddisplayed_country_codelocation_idnumber_idtelephone_numberticket_id返回与指定外部连接关联的所有活跃电话号码列表。
GET /external_connections/{id}/phone_numberspython
page = client.external_connections.phone_numbers.list(
id="1293384261075731499",
)
page = page.data[0]
print(page.civic_address_id)返回: (字符串数组), (uuid), (字符串), (uuid), (字符串), (字符串), (uuid)
acquired_capabilitiescivic_address_iddisplayed_country_codelocation_idnumber_idtelephone_numberticket_idRetrieve a phone number
获取单条电话号码
Return the details of a phone number associated with the given external connection.
GET /external_connections/{id}/phone_numbers/{phone_number_id}python
phone_number = client.external_connections.phone_numbers.retrieve(
phone_number_id="1234567889",
id="1293384261075731499",
)
print(phone_number.data)Returns: (array[string]), (uuid), (string), (uuid), (string), (string), (uuid)
acquired_capabilitiescivic_address_iddisplayed_country_codelocation_idnumber_idtelephone_numberticket_id返回与指定外部连接关联的单条电话号码的详情。
GET /external_connections/{id}/phone_numbers/{phone_number_id}python
phone_number = client.external_connections.phone_numbers.retrieve(
phone_number_id="1234567889",
id="1293384261075731499",
)
print(phone_number.data)返回: (字符串数组), (uuid), (字符串), (uuid), (字符串), (字符串), (uuid)
acquired_capabilitiescivic_address_iddisplayed_country_codelocation_idnumber_idtelephone_numberticket_idUpdate a phone number
更新电话号码
Asynchronously update settings of the phone number associated with the given external connection.
PATCH /external_connections/{id}/phone_numbers/{phone_number_id}Optional: (uuid)
location_idpython
phone_number = client.external_connections.phone_numbers.update(
phone_number_id="1234567889",
id="1293384261075731499",
)
print(phone_number.data)Returns: (array[string]), (uuid), (string), (uuid), (string), (string), (uuid)
acquired_capabilitiescivic_address_iddisplayed_country_codelocation_idnumber_idtelephone_numberticket_id异步更新与指定外部连接关联的电话号码配置。
PATCH /external_connections/{id}/phone_numbers/{phone_number_id}可选参数: (uuid)
location_idpython
phone_number = client.external_connections.phone_numbers.update(
phone_number_id="1234567889",
id="1293384261075731499",
)
print(phone_number.data)返回: (字符串数组), (uuid), (字符串), (uuid), (字符串), (字符串), (uuid)
acquired_capabilitiescivic_address_iddisplayed_country_codelocation_idnumber_idtelephone_numberticket_idList all Releases
获取所有释放请求
Returns a list of your Releases for the given external connection. These are automatically created when you change the of a phone number that is currently on Microsoft Teams.
connection_idGET /external_connections/{id}/releasespython
page = client.external_connections.releases.list(
id="1293384261075731499",
)
page = page.data[0]
print(page.tenant_id)Returns: (string), (string), (enum: pending_upload, pending, in_progress, complete, failed, expired, unknown), (array[object]), (uuid), (uuid)
created_aterror_messagestatustelephone_numberstenant_idticket_id返回指定外部连接的所有释放请求列表。当你修改当前绑定在Microsoft Teams上的电话号码的时,会自动创建这些请求。
connection_idGET /external_connections/{id}/releasespython
page = client.external_connections.releases.list(
id="1293384261075731499",
)
page = page.data[0]
print(page.tenant_id)返回: (字符串), (字符串), (枚举: pending_upload, pending, in_progress, complete, failed, expired, unknown), (对象数组), (uuid), (uuid)
created_aterror_messagestatustelephone_numberstenant_idticket_idRetrieve a Release request
获取单条释放请求
Return the details of a Release request and its phone numbers.
GET /external_connections/{id}/releases/{release_id}python
release = client.external_connections.releases.retrieve(
release_id="7b6a6449-b055-45a6-81f6-f6f0dffa4cc6",
id="1293384261075731499",
)
print(release.data)Returns: (string), (string), (enum: pending_upload, pending, in_progress, complete, failed, expired, unknown), (array[object]), (uuid), (uuid)
created_aterror_messagestatustelephone_numberstenant_idticket_id返回释放请求及其关联电话号码的详情。
GET /external_connections/{id}/releases/{release_id}python
release = client.external_connections.releases.retrieve(
release_id="7b6a6449-b055-45a6-81f6-f6f0dffa4cc6",
id="1293384261075731499",
)
print(release.data)返回: (字符串), (字符串), (枚举: pending_upload, pending, in_progress, complete, failed, expired, unknown), (对象数组), (uuid), (uuid)
created_aterror_messagestatustelephone_numberstenant_idticket_idList all Upload requests
获取所有上传请求
Returns a list of your Upload requests for the given external connection.
GET /external_connections/{id}/uploadspython
page = client.external_connections.uploads.list(
id="1293384261075731499",
)
page = page.data[0]
print(page.location_id)Returns: (array[string]), (string), (string), (uuid), (enum: pending_upload, pending, in_progress, partial_success, success, error), (uuid), (uuid), (array[object])
available_usageserror_codeerror_messagelocation_idstatustenant_idticket_idtn_upload_entries返回指定外部连接的所有上传请求列表。
GET /external_connections/{id}/uploadspython
page = client.external_connections.uploads.list(
id="1293384261075731499",
)
page = page.data[0]
print(page.location_id)返回: (字符串数组), (字符串), (字符串), (uuid), (枚举: pending_upload, pending, in_progress, partial_success, success, error), (uuid), (uuid), (对象数组)
available_usageserror_codeerror_messagelocation_idstatustenant_idticket_idtn_upload_entriesCreates an Upload request
创建上传请求
Creates a new Upload request to Microsoft teams with the included phone numbers. Only one of civic_address_id or location_id must be provided, not both. The maximum allowed phone numbers for the numbers_ids array is 1000.
POST /external_connections/{id}/uploadsnumber_idsOptional: (array[string]), (uuid), (uuid), (enum: calling_user_assignment, first_party_app_assignment)
additional_usagescivic_address_idlocation_idusagepython
upload = client.external_connections.uploads.create(
id="1293384261075731499",
number_ids=["3920457616934164700", "3920457616934164701", "3920457616934164702", "3920457616934164703"],
)
print(upload.ticket_id)Returns: (boolean), (uuid)
successticket_id创建新的上传请求,将包含的电话号码上传到Microsoft Teams。必须提供或中的一个,不可同时提供。数组最多允许包含1000个电话号码。
civic_address_idlocation_idnumber_idsPOST /external_connections/{id}/uploadsnumber_ids可选参数: (字符串数组), (uuid), (uuid), (枚举: calling_user_assignment, first_party_app_assignment)
additional_usagescivic_address_idlocation_idusagepython
upload = client.external_connections.uploads.create(
id="1293384261075731499",
number_ids=["3920457616934164700", "3920457616934164701", "3920457616934164702", "3920457616934164703"],
)
print(upload.ticket_id)返回: (布尔值), (uuid)
successticket_idRefresh the status of all Upload requests
刷新所有上传请求的状态
Forces a recheck of the status of all pending Upload requests for the given external connection in the background.
POST /external_connections/{id}/uploads/refreshpython
response = client.external_connections.uploads.refresh_status(
"1293384261075731499",
)
print(response.success)Returns: (boolean)
success后台强制重新检查指定外部连接下所有待处理上传请求的状态。
POST /external_connections/{id}/uploads/refreshpython
response = client.external_connections.uploads.refresh_status(
"1293384261075731499",
)
print(response.success)返回: (布尔值)
successGet the count of pending upload requests
获取待处理上传请求的数量
Returns the count of all pending upload requests for the given external connection.
GET /external_connections/{id}/uploads/statuspython
response = client.external_connections.uploads.pending_count(
"1293384261075731499",
)
print(response.data)Returns: (integer), (integer)
pending_numbers_countpending_orders_count返回指定外部连接下所有待处理上传请求的数量。
GET /external_connections/{id}/uploads/statuspython
response = client.external_connections.uploads.pending_count(
"1293384261075731499",
)
print(response.data)返回: (整数), (整数)
pending_numbers_countpending_orders_countRetrieve an Upload request
获取单条上传请求
Return the details of an Upload request and its phone numbers.
GET /external_connections/{id}/uploads/{ticket_id}python
upload = client.external_connections.uploads.retrieve(
ticket_id="7b6a6449-b055-45a6-81f6-f6f0dffa4cc6",
id="1293384261075731499",
)
print(upload.data)Returns: (array[string]), (string), (string), (uuid), (enum: pending_upload, pending, in_progress, partial_success, success, error), (uuid), (uuid), (array[object])
available_usageserror_codeerror_messagelocation_idstatustenant_idticket_idtn_upload_entries返回上传请求及其关联电话号码的详情。
GET /external_connections/{id}/uploads/{ticket_id}python
upload = client.external_connections.uploads.retrieve(
ticket_id="7b6a6449-b055-45a6-81f6-f6f0dffa4cc6",
id="1293384261075731499",
)
print(upload.data)返回: (字符串数组), (字符串), (字符串), (uuid), (枚举: pending_upload, pending, in_progress, partial_success, success, error), (uuid), (uuid), (对象数组)
available_usageserror_codeerror_messagelocation_idstatustenant_idticket_idtn_upload_entriesRetry an Upload request
重试上传请求
If there were any errors during the upload process, this endpoint will retry the upload request. In some cases this will reattempt the existing upload request, in other cases it may create a new upload request. Please check the ticket_id in the response to determine if a new upload request was created.
POST /external_connections/{id}/uploads/{ticket_id}/retrypython
response = client.external_connections.uploads.retry(
ticket_id="7b6a6449-b055-45a6-81f6-f6f0dffa4cc6",
id="1293384261075731499",
)
print(response.data)Returns: (array[string]), (string), (string), (uuid), (enum: pending_upload, pending, in_progress, partial_success, success, error), (uuid), (uuid), (array[object])
available_usageserror_codeerror_messagelocation_idstatustenant_idticket_idtn_upload_entries如果上传过程中出现错误,可以调用该接口重试上传请求。部分场景下会重试现有上传请求,其他场景下可能会创建新的上传请求。请查看响应中的确认是否创建了新的上传请求。
ticket_idPOST /external_connections/{id}/uploads/{ticket_id}/retrypython
response = client.external_connections.uploads.retry(
ticket_id="7b6a6449-b055-45a6-81f6-f6f0dffa4cc6",
id="1293384261075731499",
)
print(response.data)返回: (字符串数组), (字符串), (字符串), (uuid), (枚举: pending_upload, pending, in_progress, partial_success, success, error), (uuid), (uuid), (对象数组)
available_usageserror_codeerror_messagelocation_idstatustenant_idticket_idtn_upload_entriesList uploaded media
获取已上传媒体列表
Returns a list of stored media files.
GET /mediapython
media = client.media.list()
print(media.data)Returns: (string), (string), (string), (string), (string)
content_typecreated_atexpires_atmedia_nameupdated_at返回已存储的媒体文件列表。
GET /mediapython
media = client.media.list()
print(media.data)返回: (字符串), (字符串), (字符串), (字符串), (字符串)
content_typecreated_atexpires_atmedia_nameupdated_atUpload media
上传媒体
Upload media file to Telnyx so it can be used with other Telnyx services
POST /mediamedia_urlOptional: (string), (integer)
media_namettl_secspython
response = client.media.upload(
media_url="http://www.example.com/audio.mp3",
)
print(response.data)Returns: (string), (string), (string), (string), (string)
content_typecreated_atexpires_atmedia_nameupdated_at将媒体文件上传到Telnyx,以便与其他Telnyx服务配合使用。
POST /mediamedia_url可选参数: (字符串), (整数)
media_namettl_secspython
response = client.media.upload(
media_url="http://www.example.com/audio.mp3",
)
print(response.data)返回: (字符串), (字符串), (字符串), (字符串), (字符串)
content_typecreated_atexpires_atmedia_nameupdated_atRetrieve stored media
获取已存储媒体
Returns the information about a stored media file.
GET /media/{media_name}python
media = client.media.retrieve(
"media_name",
)
print(media.data)Returns: (string), (string), (string), (string), (string)
content_typecreated_atexpires_atmedia_nameupdated_at返回已存储媒体文件的相关信息。
GET /media/{media_name}python
media = client.media.retrieve(
"media_name",
)
print(media.data)返回: (字符串), (字符串), (字符串), (字符串), (字符串)
content_typecreated_atexpires_atmedia_nameupdated_atUpdate stored media
更新已存储媒体
Updates a stored media file.
PUT /media/{media_name}Optional: (string), (integer)
media_urlttl_secspython
media = client.media.update(
media_name="media_name",
)
print(media.data)Returns: (string), (string), (string), (string), (string)
content_typecreated_atexpires_atmedia_nameupdated_at更新已存储的媒体文件。
PUT /media/{media_name}可选参数: (字符串), (整数)
media_urlttl_secspython
media = client.media.update(
media_name="media_name",
)
print(media.data)返回: (字符串), (字符串), (字符串), (字符串), (字符串)
content_typecreated_atexpires_atmedia_nameupdated_atDeletes stored media
删除已存储媒体
Deletes a stored media file.
DELETE /media/{media_name}python
client.media.delete(
"media_name",
)删除已存储的媒体文件。
DELETE /media/{media_name}python
client.media.delete(
"media_name",
)Download stored media
下载已存储媒体
Downloads a stored media file.
GET /media/{media_name}/downloadpython
response = client.media.download(
"media_name",
)
print(response)
content = response.read()
print(content)下载已存储的媒体文件。
GET /media/{media_name}/downloadpython
response = client.media.download(
"media_name",
)
print(response)
content = response.read()
print(content)Refresh Operator Connect integration
刷新Operator Connect集成
This endpoint will make an asynchronous request to refresh the Operator Connect integration with Microsoft Teams for the current user. This will create new external connections on the user's account if needed, and/or report the integration results as log messages.
POST /operator_connect/actions/refreshpython
response = client.operator_connect.actions.refresh()
print(response.message)Returns: (string), (boolean)
messagesuccess该接口会发起异步请求,为当前用户刷新与Microsoft Teams的Operator Connect集成。如有需要,会在用户账户下创建新的外部连接,或者将集成结果记录为日志消息。
POST /operator_connect/actions/refreshpython
response = client.operator_connect.actions.refresh()
print(response.message)返回: (字符串), (布尔值)
messagesuccessList all recording transcriptions
获取所有录音转写
Returns a list of your recording transcriptions.
GET /recording_transcriptionspython
page = client.recording_transcriptions.list()
page = page.data[0]
print(page.id)Returns: (string), (int32), (string), (enum: recording_transcription), (string), (enum: in-progress, completed), (string), (string)
created_atduration_millisidrecord_typerecording_idstatustranscription_textupdated_at返回你的录音转写列表。
GET /recording_transcriptionspython
page = client.recording_transcriptions.list()
page = page.data[0]
print(page.id)返回: (字符串), (int32), (字符串), (枚举: recording_transcription), (字符串), (枚举: in-progress, completed), (字符串), (字符串)
created_atduration_millisidrecord_typerecording_idstatustranscription_textupdated_atRetrieve a recording transcription
获取单条录音转写
Retrieves the details of an existing recording transcription.
GET /recording_transcriptions/{recording_transcription_id}python
recording_transcription = client.recording_transcriptions.retrieve(
"6a09cdc3-8948-47f0-aa62-74ac943d6c58",
)
print(recording_transcription.data)Returns: (string), (int32), (string), (enum: recording_transcription), (string), (enum: in-progress, completed), (string), (string)
created_atduration_millisidrecord_typerecording_idstatustranscription_textupdated_at获取现有录音转写的详情。
GET /recording_transcriptions/{recording_transcription_id}python
recording_transcription = client.recording_transcriptions.retrieve(
"6a09cdc3-8948-47f0-aa62-74ac943d6c58",
)
print(recording_transcription.data)返回: (字符串), (int32), (字符串), (枚举: recording_transcription), (字符串), (枚举: in-progress, completed), (字符串), (字符串)
created_atduration_millisidrecord_typerecording_idstatustranscription_textupdated_atDelete a recording transcription
删除录音转写
Permanently deletes a recording transcription.
DELETE /recording_transcriptions/{recording_transcription_id}python
recording_transcription = client.recording_transcriptions.delete(
"6a09cdc3-8948-47f0-aa62-74ac943d6c58",
)
print(recording_transcription.data)Returns: (string), (int32), (string), (enum: recording_transcription), (string), (enum: in-progress, completed), (string), (string)
created_atduration_millisidrecord_typerecording_idstatustranscription_textupdated_at永久删除录音转写。
DELETE /recording_transcriptions/{recording_transcription_id}python
recording_transcription = client.recording_transcriptions.delete(
"6a09cdc3-8948-47f0-aa62-74ac943d6c58",
)
print(recording_transcription.data)返回: (字符串), (int32), (字符串), (枚举: recording_transcription), (字符串), (枚举: in-progress, completed), (字符串), (字符串)
created_atduration_millisidrecord_typerecording_idstatustranscription_textupdated_atList all call recordings
获取所有通话录音
Returns a list of your call recordings.
GET /recordingspython
page = client.recordings.list()
page = page.data[0]
print(page.id)Returns: (string), (string), (string), (enum: single, dual), (string), (string), (string), (object), (int32), (string), (string), (string), (enum: recording), (string), (string), (enum: conference, call), (enum: completed), (string), (string)
call_control_idcall_leg_idcall_session_idchannelsconference_idconnection_idcreated_atdownload_urlsduration_millisfromidinitiated_byrecord_typerecording_ended_atrecording_started_atsourcestatustoupdated_at返回你的通话录音列表。
GET /recordingspython
page = client.recordings.list()
page = page.data[0]
print(page.id)返回: (字符串), (字符串), (字符串), (枚举: single, dual), (字符串), (字符串), (字符串), (对象), (int32), (字符串), (字符串), (字符串), (枚举: recording), (字符串), (字符串), (枚举: conference, call), (枚举: completed), (字符串), (字符串)
call_control_idcall_leg_idcall_session_idchannelsconference_idconnection_idcreated_atdownload_urlsduration_millisfromidinitiated_byrecord_typerecording_ended_atrecording_started_atsourcestatustoupdated_atDelete a list of call recordings
批量删除通话录音
Permanently deletes a list of call recordings.
POST /recordings/actions/deletepython
action = client.recordings.actions.delete(
ids=["428c31b6-7af4-4bcb-b7f5-5013ef9657c1", "428c31b6-7af4-4bcb-b7f5-5013ef9657c2"],
)
print(action.status)Returns: (enum: ok)
status永久删除批量通话录音。
POST /recordings/actions/deletepython
action = client.recordings.actions.delete(
ids=["428c31b6-7af4-4bcb-b7f5-5013ef9657c1", "428c31b6-7af4-4bcb-b7f5-5013ef9657c2"],
)
print(action.status)返回: (枚举: ok)
statusRetrieve a call recording
获取单条通话录音
Retrieves the details of an existing call recording.
GET /recordings/{recording_id}python
recording = client.recordings.retrieve(
"recording_id",
)
print(recording.data)Returns: (string), (string), (string), (enum: single, dual), (string), (string), (string), (object), (int32), (string), (string), (string), (enum: recording), (string), (string), (enum: conference, call), (enum: completed), (string), (string)
call_control_idcall_leg_idcall_session_idchannelsconference_idconnection_idcreated_atdownload_urlsduration_millisfromidinitiated_byrecord_typerecording_ended_atrecording_started_atsourcestatustoupdated_at获取现有通话录音的详情。
GET /recordings/{recording_id}python
recording = client.recordings.retrieve(
"recording_id",
)
print(recording.data)返回: (字符串), (字符串), (字符串), (枚举: single, dual), (字符串), (字符串), (字符串), (对象), (int32), (字符串), (字符串), (字符串), (枚举: recording), (字符串), (字符串), (枚举: conference, call), (枚举: completed), (字符串), (字符串)
call_control_idcall_leg_idcall_session_idchannelsconference_idconnection_idcreated_atdownload_urlsduration_millisfromidinitiated_byrecord_typerecording_ended_atrecording_started_atsourcestatustoupdated_atDelete a call recording
删除通话录音
Permanently deletes a call recording.
DELETE /recordings/{recording_id}python
recording = client.recordings.delete(
"recording_id",
)
print(recording.data)Returns: (string), (string), (string), (enum: single, dual), (string), (string), (string), (object), (int32), (string), (string), (string), (enum: recording), (string), (string), (enum: conference, call), (enum: completed), (string), (string)
call_control_idcall_leg_idcall_session_idchannelsconference_idconnection_idcreated_atdownload_urlsduration_millisfromidinitiated_byrecord_typerecording_ended_atrecording_started_atsourcestatustoupdated_at永久删除通话录音。
DELETE /recordings/{recording_id}python
recording = client.recordings.delete(
"recording_id",
)
print(recording.data)返回: (字符串), (字符串), (字符串), (枚举: single, dual), (字符串), (字符串), (字符串), (对象), (int32), (字符串), (字符串), (字符串), (枚举: recording), (字符串), (字符串), (枚举: conference, call), (枚举: completed), (字符串), (字符串)
call_control_idcall_leg_idcall_session_idchannelsconference_idconnection_idcreated_atdownload_urlsduration_millisfromidinitiated_byrecord_typerecording_ended_atrecording_started_atsourcestatustoupdated_atCreate a SIPREC connector
创建SIPREC连接器
Creates a new SIPREC connector configuration.
POST /siprec_connectorspython
siprec_connector = client.siprec_connectors.create(
host="siprec.telnyx.com",
name="my-siprec-connector",
port=5060,
)
print(siprec_connector.data)Returns: (string), (string), (string), (string), (integer), (string), (string)
app_subdomaincreated_athostnameportrecord_typeupdated_at创建新的SIPREC连接器配置。
POST /siprec_connectorspython
siprec_connector = client.siprec_connectors.create(
host="siprec.telnyx.com",
name="my-siprec-connector",
port=5060,
)
print(siprec_connector.data)返回: (字符串), (字符串), (字符串), (字符串), (整数), (字符串), (字符串)
app_subdomaincreated_athostnameportrecord_typeupdated_atRetrieve a SIPREC connector
获取SIPREC连接器
Returns details of a stored SIPREC connector.
GET /siprec_connectors/{connector_name}python
siprec_connector = client.siprec_connectors.retrieve(
"connector_name",
)
print(siprec_connector.data)Returns: (string), (string), (string), (string), (integer), (string), (string)
app_subdomaincreated_athostnameportrecord_typeupdated_at返回已存储的SIPREC连接器详情。
GET /siprec_connectors/{connector_name}python
siprec_connector = client.siprec_connectors.retrieve(
"connector_name",
)
print(siprec_connector.data)返回: (字符串), (字符串), (字符串), (字符串), (整数), (字符串), (字符串)
app_subdomaincreated_athostnameportrecord_typeupdated_atUpdate a SIPREC connector
更新SIPREC连接器
Updates a stored SIPREC connector configuration.
PUT /siprec_connectors/{connector_name}python
siprec_connector = client.siprec_connectors.update(
connector_name="connector_name",
host="siprec.telnyx.com",
name="my-siprec-connector",
port=5060,
)
print(siprec_connector.data)Returns: (string), (string), (string), (string), (integer), (string), (string)
app_subdomaincreated_athostnameportrecord_typeupdated_at更新已存储的SIPREC连接器配置。
PUT /siprec_connectors/{connector_name}python
siprec_connector = client.siprec_connectors.update(
connector_name="connector_name",
host="siprec.telnyx.com",
name="my-siprec-connector",
port=5060,
)
print(siprec_connector.data)返回: (字符串), (字符串), (字符串), (字符串), (整数), (字符串), (字符串)
app_subdomaincreated_athostnameportrecord_typeupdated_atDelete a SIPREC connector
删除SIPREC连接器
Deletes a stored SIPREC connector.
DELETE /siprec_connectors/{connector_name}python
client.siprec_connectors.delete(
"connector_name",
)删除已存储的SIPREC连接器。
DELETE /siprec_connectors/{connector_name}python
client.siprec_connectors.delete(
"connector_name",
)