用途:通过 curl 调用 Telnyx Verify 相关 API,查询电话号码信息(运营商、类型、主叫名称等),并通过短信、语音通话或闪信发送一次性验证码(OTP)验证用户,可用于电话验证与数据补充。
使用方式:curl 在 macOS、Linux 和 Windows 10+ 上已预装。设置环境变量 export TELNYX_API_KEY="YOUR_API_KEY_HERE",所有请求使用 Authorization: Bearer $TELNYX_API_KEY 头。电话号码必须为 E.164 格式(如 +13125550001),带 + 和国家代码,不含空格、连字符或括号。
主要端点:GET /number_lookup/{phone_number} 查询号码信息,返回 caller_name、carrier、country_code、fraud、national_format、portability 等字段;GET /verifications/by_phone_number/{phone_number} 按号码列出验证;POST /verifications/by_phone_number/{phone_number}/actions/verify 校验验证码(必填 code、verify_profile_id);POST /verifications/sms、/verifications/call、/verifications/flashcall 分别触发短信、语音、闪信验证(必填 phone_number、verify_profile_id,可选 custom_code、timeout_secs 等);GET /verifications/{verification_id} 获取验证详情,POST /verifications/{verification_id}/actions/verify 按 ID 校验;另有 /verify_profiles 及 /verify_profiles/templates 的增删改查,用于管理验证配置和消息模板。列表端点分页,可用 page[number] 和 page[size],响应 meta.total_pages 表示总页数。
错误处理:请求可能遇到网络错误、限流(429)、校验错误(422)或认证错误(401)等。建议在生产代码中检查 HTTP 状态码,401 表示 API 密钥无效,403 表示权限不足,404 表示资源不存在,422 表示字段格式校验失败,429 表示被限流需退避重试。
限制:必须拥有 Telnyx API 密钥,验证流程依赖已配置的 verify_profile_id。关于费用、价格、速率上限、地域支持等具体信息暂未提供。