用途:该技能面向构建浏览器端或移动端软电话(softphone)应用的开发者,用于管理 WebRTC 相关的电话凭据及移动推送通知凭据。
主要能力:
- 移动推送凭据管理:支持列出(GET /mobile_push_credentials)、创建(POST /mobile_push_credentials,必填 type、certificate、private_key、alias)、检索(GET /mobile_push_credentials/{push_credential_id})和删除(DELETE /mobile_push_credentials/{push_credential_id})。返回字段包括 alias、certificate、private_key、created_at、id、record_type、type、updated_at 等。创建示例中 type 可为 ios。
- 电话凭据(On-demand Credentials)管理:支持列出(GET /telephony_credentials)、创建(POST /telephony_credentials,必填 connection_id,可选 expires_at、name、tag)、检索(GET /telephony_credentials/{id})、更新(PATCH /telephony_credentials/{id},可选 connection_id、expires_at、name、tag)和删除(DELETE /telephony_credentials/{id})。返回字段包括 sip_username、sip_password、expired、expires_at、resource_id、user_id 等。
使用方式: 安装:pip install telnyx 初始化: import os from telnyx import Telnyx client = Telnyx(api_key=os.environ.get("TELNYX_API_KEY")) 凭据均以客户端方法调用,例如 client.mobile_push_credentials.list()、client.telephony_credentials.create(connection_id="1234567890")。
分页:列表方法返回自动分页迭代器,可用 for item in page_result: 遍历所有页。
错误处理:所有 API 调用可能因网络、限流(429)、校验(422)或认证(401)失败。应捕获 telnyx.APIConnectionError、telnyx.RateLimitError、telnyx.APIStatusError。常见错误码:401 无效 API 密钥,403 权限不足,404 资源不存在,422 校验错误,429 限流(建议指数退避重试,参考 Retry-After 响应头)。
适用场景:需要在 Python 项目中集成 Telnyx WebRTC 电话凭据与移动推送设置的软电话或通信应用开发。
限制:资料未提供具体的价格、计费方式、SLA、速率上限数值或平台兼容性细节,这些暂未提供;实际使用时需自行配置有效的 TELNYX_API_KEY 并遵守 Telnyx 官方 API 的权限与配额约束。