用途
Telnyx Porting Out - JavaScript 是一个面向 JavaScript 开发者的技能,用于管理号码从 Telnyx 转出(port-out)的请求。当用户号码被转出 Telnyx 时,可通过该技能提供的 JavaScript SDK 示例来列出、查看和更新 port-out 状态。
主要能力
该技能覆盖以下 port-out 管理操作:
- 列出 port-out 请求(GET /portouts),支持自动分页迭代。
- 查看单个 port-out 请求详情(GET /portouts/{id})。
- 列出所有 port-out 事件(GET /portouts/events)。
- 查看特定 port-out 事件(GET /portouts/events/{id})。
- 重新发布特定 port-out 事件(POST /portouts/events/{id}/republish)。
- 列出特定订单符合条件的 port-out 拒绝代码(GET /portouts/rejections/{portout_id})。
- 列出 port-out 相关报告(GET /portouts/reports)。
- 创建 port-out 相关报告(POST /portouts/reports),报告类型为 export_portouts_csv。
- 检索特定报告(GET /portouts/reports/{id})。
- 列出 port-out 请求的所有评论(GET /portouts/{id}/comments)。
- 在 port-out 请求上创建评论(POST /portouts/{id}/comments)。
- 列出 port-out 请求上的支持文档(GET /portouts/{id}/supporting_documents)。
- 在 port-out 请求上创建支持文档列表(POST /portouts/{id}/supporting_documents),文档类型包括 loa、invoice。
- 授权或拒绝 port-out 请求(PATCH /portouts/{id}/{status}),需要提供 reason,可选 host_messaging。
使用方式
安装:
npm install telnyx
初始化:
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
所有示例均假设 client 已按上述方式初始化。
错误处理:所有 API 调用可能因网络错误、速率限制(429)、验证错误(422)或认证错误(401)而失败。生产代码中应始终处理错误。常见错误码:401 无效 API Key,403 权限不足,404 资源未找到,422 验证错误(检查字段格式),429 速率限制(使用指数退避重试)。
分页:列表方法返回自动分页迭代器,可使用 for await (const item of result) { ... } 自动遍历所有页面。
适用场景
- 需要自动化处理号码从 Telnyx 转出的流程。
- 需要监控 port-out 状态变化与事件。
- 需要生成 port-out 操作报告(CSV 导出)。
- 需要在 port-out 请求上添加评论或支持文档。
- 需要授权或拒绝 port-out 请求。
限制
该技能仅提供 JavaScript SDK 示例,未提供其他语言示例。具体 API 行为、速率限制阈值、报告生成时间等细节暂未提供。使用前需具备 Telnyx API Key 和相应权限。