telnyx-numbers-config-javascript
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 Numbers Config - JavaScript
Telnyx 号码配置 - JavaScript
Installation
安装
bash
npm install telnyxbash
npm install telnyxSetup
设置
javascript
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});All examples below assume is already initialized as shown above.
clientjavascript
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});以下所有示例均假设已按上述方式初始化完成。
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:
javascript
try {
const result = await client.messages.send({ to: '+13125550001', from: '+13125550002', text: 'Hello' });
} catch (err) {
if (err instanceof Telnyx.APIConnectionError) {
console.error('Network error — check connectivity and retry');
} else if (err instanceof Telnyx.RateLimitError) {
// 429: rate limited — wait and retry with exponential backoff
const retryAfter = err.headers?.['retry-after'] || 1;
await new Promise(r => setTimeout(r, retryAfter * 1000));
} else if (err instanceof Telnyx.APIError) {
console.error(`API error ${err.status}: ${err.message}`);
if (err.status === 422) {
console.error('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)而失败。在生产代码中务必处理错误:
javascript
try {
const result = await client.messages.send({ to: '+13125550001', from: '+13125550002', text: 'Hello' });
} catch (err) {
if (err instanceof Telnyx.APIConnectionError) {
console.error('Network error — check connectivity and retry');
} else if (err instanceof Telnyx.RateLimitError) {
// 429: rate limited — wait and retry with exponential backoff
const retryAfter = err.headers?.['retry-after'] || 1;
await new Promise(r => setTimeout(r, retryAfter * 1000));
} else if (err instanceof Telnyx.APIError) {
console.error(`API error ${err.status}: ${err.message}`);
if (err.status === 422) {
console.error('Validation error — check required fields and formats');
}
}
}常见错误码:无效API密钥,权限不足,资源未找到,验证错误(检查字段格式),速率受限(使用指数退避策略重试)。
401403404422429Important Notes
重要注意事项
- Phone numbers must be in E.164 format (e.g., ). Include the
+13125550001prefix and country code. No spaces, dashes, or parentheses.+ - Pagination: List methods return an auto-paginating iterator. Use to iterate through all pages automatically.
for await (const item of result) { ... }
- 电话号码必须采用E.164格式(例如:)。包含
+13125550001前缀和国家代码,不能有空格、连字符或括号。+ - 分页:列表方法返回自动分页的迭代器。使用自动遍历所有页面。
for await (const item of result) { ... }
Bulk update phone number profiles
批量更新电话号码配置
POST /messaging_numbers_bulk_updatesmessaging_profile_idnumbersOptional: (boolean)
assign_onlyjavascript
const messagingNumbersBulkUpdate = await client.messagingNumbersBulkUpdates.create({
messaging_profile_id: '00000000-0000-0000-0000-000000000000',
numbers: ['+18880000000', '+18880000001', '+18880000002'],
});
console.log(messagingNumbersBulkUpdate.data);Returns: (array[string]), (uuid), (array[string]), (enum: messaging_numbers_bulk_update), (array[string])
failedorder_idpendingrecord_typesuccessPOST /messaging_numbers_bulk_updatesmessaging_profile_idnumbers可选参数:(布尔值)
assign_onlyjavascript
const messagingNumbersBulkUpdate = await client.messagingNumbersBulkUpdates.create({
messaging_profile_id: '00000000-0000-0000-0000-000000000000',
numbers: ['+18880000000', '+18880000001', '+18880000002'],
});
console.log(messagingNumbersBulkUpdate.data);返回:(字符串数组),(UUID),(字符串数组),(枚举:messaging_numbers_bulk_update),(字符串数组)
failedorder_idpendingrecord_typesuccessRetrieve bulk update status
查询批量更新状态
GET /messaging_numbers_bulk_updates/{order_id}javascript
const messagingNumbersBulkUpdate = await client.messagingNumbersBulkUpdates.retrieve('order_id');
console.log(messagingNumbersBulkUpdate.data);Returns: (array[string]), (uuid), (array[string]), (enum: messaging_numbers_bulk_update), (array[string])
failedorder_idpendingrecord_typesuccessGET /messaging_numbers_bulk_updates/{order_id}javascript
const messagingNumbersBulkUpdate = await client.messagingNumbersBulkUpdates.retrieve('order_id');
console.log(messagingNumbersBulkUpdate.data);返回:(字符串数组),(UUID),(字符串数组),(枚举:messaging_numbers_bulk_update),(字符串数组)
failedorder_idpendingrecord_typesuccessList mobile phone numbers with messaging settings
列出带消息设置的手机号码
GET /mobile_phone_numbers/messagingjavascript
// Automatically fetches more pages as needed.
for await (const messagingListResponse of client.mobilePhoneNumbers.messaging.list()) {
console.log(messagingListResponse.id);
}Returns: (string), (date-time), (object), (string), (string), (string | null), (string), (string), (enum: messaging_phone_number, messaging_settings), (array[string]), (string), (enum: longcode), (date-time)
country_codecreated_atfeaturesidmessaging_productmessaging_profile_idorganization_idphone_numberrecord_typetagstraffic_typetypeupdated_atGET /mobile_phone_numbers/messagingjavascript
// Automatically fetches more pages as needed.
for await (const messagingListResponse of client.mobilePhoneNumbers.messaging.list()) {
console.log(messagingListResponse.id);
}返回:(字符串),(日期时间),(对象),(字符串),(字符串),(字符串 | null),(字符串),(字符串),(枚举:messaging_phone_number, messaging_settings),(字符串数组),(字符串),(枚举:longcode),(日期时间)
country_codecreated_atfeaturesidmessaging_productmessaging_profile_idorganization_idphone_numberrecord_typetagstraffic_typetypeupdated_atRetrieve a mobile phone number with messaging settings
查询单个带消息设置的手机号码
GET /mobile_phone_numbers/{id}/messagingjavascript
const messaging = await client.mobilePhoneNumbers.messaging.retrieve('550e8400-e29b-41d4-a716-446655440000');
console.log(messaging.data);Returns: (string), (date-time), (object), (string), (string), (string | null), (string), (string), (enum: messaging_phone_number, messaging_settings), (array[string]), (string), (enum: longcode), (date-time)
country_codecreated_atfeaturesidmessaging_productmessaging_profile_idorganization_idphone_numberrecord_typetagstraffic_typetypeupdated_atGET /mobile_phone_numbers/{id}/messagingjavascript
const messaging = await client.mobilePhoneNumbers.messaging.retrieve('550e8400-e29b-41d4-a716-446655440000');
console.log(messaging.data);返回:(字符串),(日期时间),(对象),(字符串),(字符串),(字符串 | null),(字符串),(字符串),(枚举:messaging_phone_number, messaging_settings),(字符串数组),(字符串),(枚举:longcode),(日期时间)
country_codecreated_atfeaturesidmessaging_productmessaging_profile_idorganization_idphone_numberrecord_typetagstraffic_typetypeupdated_atList phone numbers
列出电话号码
GET /phone_numbersjavascript
// Automatically fetches more pages as needed.
for await (const phoneNumberDetailed of client.phoneNumbers.list()) {
console.log(phoneNumberDetailed.id);
}Returns: (string | null), (boolean), (boolean), (boolean), (boolean), (string | null), (string | null), (string), (date-time), (string | null), (boolean), (string | null), (boolean), (enum: active, deprovisioning, disabled, provisioning, provisioning-failed), (string | null), (boolean), (string), (enum: disabled, reject_calls, flag_calls), (string | null), (string | null), (string), (enum: local, toll_free, mobile, national, shared_cost, landline, tollfree, shortcode, longcode), (string), (string), (object), (enum: purchase-pending, purchase-failed, port-pending, port-failed, active, deleted, emergency-only, ported-out, port-out-pending, requirement-info-pending, requirement-info-under-review, requirement-info-exception, provision-pending), (boolean), (array[string]), (string)
billing_group_idcall_forwarding_enabledcall_recording_enabledcaller_id_name_enabledcnam_listing_enabledconnection_idconnection_namecountry_iso_alpha2created_atcustomer_referencedeletion_lock_enabledemergency_address_idemergency_enabledemergency_statusexternal_pinhd_voice_enabledidinbound_call_screeningmessaging_profile_idmessaging_profile_namephone_numberphone_number_typepurchased_atrecord_typesource_typestatust38_fax_gateway_enabledtagsupdated_atGET /phone_numbersjavascript
// Automatically fetches more pages as needed.
for await (const phoneNumberDetailed of client.phoneNumbers.list()) {
console.log(phoneNumberDetailed.id);
}返回:(字符串 | null),(布尔值),(布尔值),(布尔值),(布尔值),(字符串 | null),(字符串 | null),(字符串),(日期时间),(字符串 | null),(布尔值),(字符串 | null),(布尔值),(枚举:active, deprovisioning, disabled, provisioning, provisioning-failed),(字符串 | null),(布尔值),(字符串),(枚举:disabled, reject_calls, flag_calls),(字符串 | null),(字符串 | null),(字符串),(枚举:local, toll_free, mobile, national, shared_cost, landline, tollfree, shortcode, longcode),(字符串),(字符串),(对象),(枚举:purchase-pending, purchase-failed, port-pending, port-failed, active, deleted, emergency-only, ported-out, port-out-pending, requirement-info-pending, requirement-info-under-review, requirement-info-exception, provision-pending),(布尔值),(字符串数组),(字符串)
billing_group_idcall_forwarding_enabledcall_recording_enabledcaller_id_name_enabledcnam_listing_enabledconnection_idconnection_namecountry_iso_alpha2created_atcustomer_referencedeletion_lock_enabledemergency_address_idemergency_enabledemergency_statusexternal_pinhd_voice_enabledidinbound_call_screeningmessaging_profile_idmessaging_profile_namephone_numberphone_number_typepurchased_atrecord_typesource_typestatust38_fax_gateway_enabledtagsupdated_atVerify ownership of phone numbers
验证电话号码所有权
Verifies ownership of the provided phone numbers and returns a mapping of numbers to their IDs, plus a list of numbers not found in the account.
POST /phone_numbers/actions/verify_ownershipphone_numbersjavascript
const response = await client.phoneNumbers.actions.verifyOwnership({
phone_numbers: ['+15551234567'],
});
console.log(response.data);Returns: (array[object]), (array[string]), (string)
foundnot_foundrecord_type验证提供的电话号码所有权,返回号码与ID的映射关系,以及账户中未找到的号码列表。
POST /phone_numbers/actions/verify_ownershipphone_numbersjavascript
const response = await client.phoneNumbers.actions.verifyOwnership({
phone_numbers: ['+15551234567'],
});
console.log(response.data);返回:(对象数组),(字符串数组),(字符串)
foundnot_foundrecord_typeLists the phone numbers jobs
列出电话号码任务
GET /phone_numbers/jobsjavascript
// Automatically fetches more pages as needed.
for await (const phoneNumbersJob of client.phoneNumbers.jobs.list()) {
console.log(phoneNumbersJob.id);
}Returns: (string), (date-time), (array[object]), (uuid), (array[object]), (array[object]), (string), (enum: pending, in_progress, completed, failed, expired), (array[object]), (enum: update_emergency_settings, delete_phone_numbers, update_phone_numbers), (string)
created_atetcfailed_operationsidpending_operationsphone_numbersrecord_typestatussuccessful_operationstypeupdated_atGET /phone_numbers/jobsjavascript
// Automatically fetches more pages as needed.
for await (const phoneNumbersJob of client.phoneNumbers.jobs.list()) {
console.log(phoneNumbersJob.id);
}返回:(字符串),(日期时间),(对象数组),(UUID),(对象数组),(对象数组),(字符串),(枚举:pending, in_progress, completed, failed, expired),(对象数组),(枚举:update_emergency_settings, delete_phone_numbers, update_phone_numbers),(字符串)
created_atetcfailed_operationsidpending_operationsphone_numbersrecord_typestatussuccessful_operationstypeupdated_atDelete a batch of numbers
批量删除号码
Creates a new background job to delete a batch of numbers. At most one thousand numbers can be updated per API call.
POST /phone_numbers/jobs/delete_phone_numbersphone_numbersjavascript
const response = await client.phoneNumbers.jobs.deleteBatch({
phone_numbers: ['+19705555098', '+19715555098', '32873127836'],
});
console.log(response.data);Returns: (string), (date-time), (array[object]), (uuid), (array[object]), (array[object]), (string), (enum: pending, in_progress, completed, failed, expired), (array[object]), (enum: update_emergency_settings, delete_phone_numbers, update_phone_numbers), (string)
created_atetcfailed_operationsidpending_operationsphone_numbersrecord_typestatussuccessful_operationstypeupdated_at创建新的后台任务来批量删除号码。每次API调用最多可更新一千个号码。
POST /phone_numbers/jobs/delete_phone_numbersphone_numbersjavascript
const response = await client.phoneNumbers.jobs.deleteBatch({
phone_numbers: ['+19705555098', '+19715555098', '32873127836'],
});
console.log(response.data);返回:(字符串),(日期时间),(对象数组),(UUID),(对象数组),(对象数组),(字符串),(枚举:pending, in_progress, completed, failed, expired),(对象数组),(枚举:update_emergency_settings, delete_phone_numbers, update_phone_numbers),(字符串)
created_atetcfailed_operationsidpending_operationsphone_numbersrecord_typestatussuccessful_operationstypeupdated_atUpdate the emergency settings from a batch of numbers
批量更新号码紧急设置
Creates a background job to update the emergency settings of a collection of phone numbers. At most one thousand numbers can be updated per API call.
POST /phone_numbers/jobs/update_emergency_settingsemergency_enabledphone_numbersOptional: (string | null)
emergency_address_idjavascript
const response = await client.phoneNumbers.jobs.updateEmergencySettingsBatch({
emergency_enabled: true,
phone_numbers: ['+19705555098', '+19715555098', '32873127836'],
});
console.log(response.data);Returns: (string), (date-time), (array[object]), (uuid), (array[object]), (array[object]), (string), (enum: pending, in_progress, completed, failed, expired), (array[object]), (enum: update_emergency_settings, delete_phone_numbers, update_phone_numbers), (string)
created_atetcfailed_operationsidpending_operationsphone_numbersrecord_typestatussuccessful_operationstypeupdated_at创建后台任务来更新一组电话号码的紧急设置。每次API调用最多可更新一千个号码。
POST /phone_numbers/jobs/update_emergency_settingsemergency_enabledphone_numbers可选参数:(字符串 | null)
emergency_address_idjavascript
const response = await client.phoneNumbers.jobs.updateEmergencySettingsBatch({
emergency_enabled: true,
phone_numbers: ['+19705555098', '+19715555098', '32873127836'],
});
console.log(response.data);返回:(字符串),(日期时间),(对象数组),(UUID),(对象数组),(对象数组),(字符串),(枚举:pending, in_progress, completed, failed, expired),(对象数组),(枚举:update_emergency_settings, delete_phone_numbers, update_phone_numbers),(字符串)
created_atetcfailed_operationsidpending_operationsphone_numbersrecord_typestatussuccessful_operationstypeupdated_atUpdate a batch of numbers
批量更新号码
Creates a new background job to update a batch of numbers. At most one thousand numbers can be updated per API call. At least one of the updateable fields must be submitted.
POST /phone_numbers/jobs/update_phone_numbersphone_numbersOptional: (string), (string), (string), (boolean), (string), (boolean), (array[string]), (object)
billing_group_idconnection_idcustomer_referencedeletion_lock_enabledexternal_pinhd_voice_enabledtagsvoicejavascript
const response = await client.phoneNumbers.jobs.updateBatch({
phone_numbers: ['1583466971586889004', '+13127367254'],
});
console.log(response.data);Returns: (string), (date-time), (array[object]), (uuid), (array[object]), (array[object]), (string), (enum: pending, in_progress, completed, failed, expired), (array[object]), (enum: update_emergency_settings, delete_phone_numbers, update_phone_numbers), (string)
created_atetcfailed_operationsidpending_operationsphone_numbersrecord_typestatussuccessful_operationstypeupdated_at创建新的后台任务来批量更新号码。每次API调用最多可更新一千个号码,且必须提交至少一个可更新字段。
POST /phone_numbers/jobs/update_phone_numbersphone_numbers可选参数:(字符串),(字符串),(字符串),(布尔值),(字符串),(布尔值),(字符串数组),(对象)
billing_group_idconnection_idcustomer_referencedeletion_lock_enabledexternal_pinhd_voice_enabledtagsvoicejavascript
const response = await client.phoneNumbers.jobs.updateBatch({
phone_numbers: ['1583466971586889004', '+13127367254'],
});
console.log(response.data);返回:(字符串),(日期时间),(对象数组),(UUID),(对象数组),(对象数组),(字符串),(枚举:pending, in_progress, completed, failed, expired),(对象数组),(枚举:update_emergency_settings, delete_phone_numbers, update_phone_numbers),(字符串)
created_atetcfailed_operationsidpending_operationsphone_numbersrecord_typestatussuccessful_operationstypeupdated_atRetrieve a phone numbers job
查询单个电话号码任务
GET /phone_numbers/jobs/{id}javascript
const job = await client.phoneNumbers.jobs.retrieve('550e8400-e29b-41d4-a716-446655440000');
console.log(job.data);Returns: (string), (date-time), (array[object]), (uuid), (array[object]), (array[object]), (string), (enum: pending, in_progress, completed, failed, expired), (array[object]), (enum: update_emergency_settings, delete_phone_numbers, update_phone_numbers), (string)
created_atetcfailed_operationsidpending_operationsphone_numbersrecord_typestatussuccessful_operationstypeupdated_atGET /phone_numbers/jobs/{id}javascript
const job = await client.phoneNumbers.jobs.retrieve('550e8400-e29b-41d4-a716-446655440000');
console.log(job.data);返回:(字符串),(日期时间),(对象数组),(UUID),(对象数组),(对象数组),(字符串),(枚举:pending, in_progress, completed, failed, expired),(对象数组),(枚举:update_emergency_settings, delete_phone_numbers, update_phone_numbers),(字符串)
created_atetcfailed_operationsidpending_operationsphone_numbersrecord_typestatussuccessful_operationstypeupdated_atList phone numbers with messaging settings
列出带消息设置的电话号码
GET /phone_numbers/messagingjavascript
// Automatically fetches more pages as needed.
for await (const phoneNumberWithMessagingSettings of client.phoneNumbers.messaging.list()) {
console.log(phoneNumberWithMessagingSettings.id);
}Returns: (string), (date-time), (array[string]), (object), (object), (string), (string), (string | null), (string), (string), (enum: messaging_phone_number, messaging_settings), (array[string]), (string), (enum: long-code, toll-free, short-code, longcode, tollfree, shortcode), (date-time)
country_codecreated_ateligible_messaging_productsfeatureshealthidmessaging_productmessaging_profile_idorganization_idphone_numberrecord_typetagstraffic_typetypeupdated_atGET /phone_numbers/messagingjavascript
// Automatically fetches more pages as needed.
for await (const phoneNumberWithMessagingSettings of client.phoneNumbers.messaging.list()) {
console.log(phoneNumberWithMessagingSettings.id);
}返回:(字符串),(日期时间),(字符串数组),(对象),(对象),(字符串),(字符串),(字符串 | null),(字符串),(字符串),(枚举:messaging_phone_number, messaging_settings),(字符串数组),(字符串),(枚举:long-code, toll-free, short-code, longcode, tollfree, shortcode),(日期时间)
country_codecreated_ateligible_messaging_productsfeatureshealthidmessaging_productmessaging_profile_idorganization_idphone_numberrecord_typetagstraffic_typetypeupdated_atSlim List phone numbers
精简版电话号码列表
List phone numbers, This endpoint is a lighter version of the /phone_numbers endpoint having higher performance and rate limit.
GET /phone_numbers/slimjavascript
// Automatically fetches more pages as needed.
for await (const phoneNumberSlimListResponse of client.phoneNumbers.slimList()) {
console.log(phoneNumberSlimListResponse.id);
}Returns: (string), (boolean), (boolean), (boolean), (boolean), (string), (string), (string), (string), (string), (boolean), (enum: active, deprovisioning, disabled, provisioning, provisioning-failed), (string), (boolean), (string), (enum: disabled, reject_calls, flag_calls), (string), (enum: local, toll_free, mobile, national, shared_cost, landline, tollfree, shortcode, longcode), (string), (string), (enum: purchase-pending, purchase-failed, port-pending, port-failed, active, deleted, emergency-only, ported-out, port-out-pending, requirement-info-pending, requirement-info-under-review, requirement-info-exception, provision-pending), (boolean), (string)
billing_group_idcall_forwarding_enabledcall_recording_enabledcaller_id_name_enabledcnam_listing_enabledconnection_idcountry_iso_alpha2created_atcustomer_referenceemergency_address_idemergency_enabledemergency_statusexternal_pinhd_voice_enabledidinbound_call_screeningphone_numberphone_number_typepurchased_atrecord_typestatust38_fax_gateway_enabledupdated_at列出电话号码,该端点是端点的轻量版本,具有更高的性能和速率限制。
/phone_numbersGET /phone_numbers/slimjavascript
// Automatically fetches more pages as needed.
for await (const phoneNumberSlimListResponse of client.phoneNumbers.slimList()) {
console.log(phoneNumberSlimListResponse.id);
}返回:(字符串),(布尔值),(布尔值),(布尔值),(布尔值),(字符串),(字符串),(字符串),(字符串),(字符串),(布尔值),(枚举:active, deprovisioning, disabled, provisioning, provisioning-failed),(字符串),(布尔值),(字符串),(枚举:disabled, reject_calls, flag_calls),(字符串),(枚举:local, toll_free, mobile, national, shared_cost, landline, tollfree, shortcode, longcode),(字符串),(字符串),(枚举:purchase-pending, purchase-failed, port-pending, port-failed, active, deleted, emergency-only, ported-out, port-out-pending, requirement-info-pending, requirement-info-under-review, requirement-info-exception, provision-pending),(布尔值),(字符串)
billing_group_idcall_forwarding_enabledcall_recording_enabledcaller_id_name_enabledcnam_listing_enabledconnection_idcountry_iso_alpha2created_atcustomer_referenceemergency_address_idemergency_enabledemergency_statusexternal_pinhd_voice_enabledidinbound_call_screeningphone_numberphone_number_typepurchased_atrecord_typestatust38_fax_gateway_enabledupdated_atList phone numbers with voice settings
列出带语音设置的电话号码
GET /phone_numbers/voicejavascript
// Automatically fetches more pages as needed.
for await (const phoneNumberWithVoiceSettings of client.phoneNumbers.voice.list()) {
console.log(phoneNumberWithVoiceSettings.id);
}Returns: (object), (object), (object), (string), (string), (object), (string), (enum: disabled, reject_calls, flag_calls), (object), (string), (string), (boolean), (string), (enum: pay-per-minute, channel)
call_forwardingcall_recordingcnam_listingconnection_idcustomer_referenceemergencyidinbound_call_screeningmedia_featuresphone_numberrecord_typetech_prefix_enabledtranslated_numberusage_payment_methodGET /phone_numbers/voicejavascript
// Automatically fetches more pages as needed.
for await (const phoneNumberWithVoiceSettings of client.phoneNumbers.voice.list()) {
console.log(phoneNumberWithVoiceSettings.id);
}返回:(对象),(对象),(对象),(字符串),(字符串),(对象),(字符串),(枚举:disabled, reject_calls, flag_calls),(对象),(字符串),(字符串),(布尔值),(字符串),(枚举:pay-per-minute, channel)
call_forwardingcall_recordingcnam_listingconnection_idcustomer_referenceemergencyidinbound_call_screeningmedia_featuresphone_numberrecord_typetech_prefix_enabledtranslated_numberusage_payment_methodRetrieve a phone number
查询单个电话号码
GET /phone_numbers/{id}javascript
const phoneNumber = await client.phoneNumbers.retrieve('1293384261075731499');
console.log(phoneNumber.data);Returns: (string | null), (boolean), (boolean), (boolean), (boolean), (string | null), (string | null), (string), (date-time), (string | null), (boolean), (string | null), (boolean), (enum: active, deprovisioning, disabled, provisioning, provisioning-failed), (string | null), (boolean), (string), (enum: disabled, reject_calls, flag_calls), (string | null), (string | null), (string), (enum: local, toll_free, mobile, national, shared_cost, landline, tollfree, shortcode, longcode), (string), (string), (object), (enum: purchase-pending, purchase-failed, port-pending, port-failed, active, deleted, emergency-only, ported-out, port-out-pending, requirement-info-pending, requirement-info-under-review, requirement-info-exception, provision-pending), (boolean), (array[string]), (string)
billing_group_idcall_forwarding_enabledcall_recording_enabledcaller_id_name_enabledcnam_listing_enabledconnection_idconnection_namecountry_iso_alpha2created_atcustomer_referencedeletion_lock_enabledemergency_address_idemergency_enabledemergency_statusexternal_pinhd_voice_enabledidinbound_call_screeningmessaging_profile_idmessaging_profile_namephone_numberphone_number_typepurchased_atrecord_typesource_typestatust38_fax_gateway_enabledtagsupdated_atGET /phone_numbers/{id}javascript
const phoneNumber = await client.phoneNumbers.retrieve('1293384261075731499');
console.log(phoneNumber.data);返回:(字符串 | null),(布尔值),(布尔值),(布尔值),(布尔值),(字符串 | null),(字符串 | null),(字符串),(日期时间),(字符串 | null),(布尔值),(字符串 | null),(布尔值),(枚举:active, deprovisioning, disabled, provisioning, provisioning-failed),(字符串 | null),(布尔值),(字符串),(枚举:disabled, reject_calls, flag_calls),(字符串 | null),(字符串 | null),(字符串),(枚举:local, toll_free, mobile, national, shared_cost, landline, tollfree, shortcode, longcode),(字符串),(字符串),(对象),(枚举:purchase-pending, purchase-failed, port-pending, port-failed, active, deleted, emergency-only, ported-out, port-out-pending, requirement-info-pending, requirement-info-under-review, requirement-info-exception, provision-pending),(布尔值),(字符串数组),(字符串)
billing_group_idcall_forwarding_enabledcall_recording_enabledcaller_id_name_enabledcnam_listing_enabledconnection_idconnection_namecountry_iso_alpha2created_atcustomer_referencedeletion_lock_enabledemergency_address_idemergency_enabledemergency_statusexternal_pinhd_voice_enabledidinbound_call_screeningmessaging_profile_idmessaging_profile_namephone_numberphone_number_typepurchased_atrecord_typesource_typestatust38_fax_gateway_enabledtagsupdated_atUpdate a phone number
更新单个电话号码
PATCH /phone_numbers/{id}Optional: (string), (string), (string), (string), (string), (boolean), (string), (array[string])
address_idbilling_group_idconnection_idcustomer_referenceexternal_pinhd_voice_enabledidtagsjavascript
const phoneNumber = await client.phoneNumbers.update('1293384261075731499');
console.log(phoneNumber.data);Returns: (string | null), (boolean), (boolean), (boolean), (boolean), (string | null), (string | null), (string), (date-time), (string | null), (boolean), (string | null), (boolean), (enum: active, deprovisioning, disabled, provisioning, provisioning-failed), (string | null), (boolean), (string), (enum: disabled, reject_calls, flag_calls), (string | null), (string | null), (string), (enum: local, toll_free, mobile, national, shared_cost, landline, tollfree, shortcode, longcode), (string), (string), (object), (enum: purchase-pending, purchase-failed, port-pending, port-failed, active, deleted, emergency-only, ported-out, port-out-pending, requirement-info-pending, requirement-info-under-review, requirement-info-exception, provision-pending), (boolean), (array[string]), (string)
billing_group_idcall_forwarding_enabledcall_recording_enabledcaller_id_name_enabledcnam_listing_enabledconnection_idconnection_namecountry_iso_alpha2created_atcustomer_referencedeletion_lock_enabledemergency_address_idemergency_enabledemergency_statusexternal_pinhd_voice_enabledidinbound_call_screeningmessaging_profile_idmessaging_profile_namephone_numberphone_number_typepurchased_atrecord_typesource_typestatust38_fax_gateway_enabledtagsupdated_atPATCH /phone_numbers/{id}可选参数:(字符串),(字符串),(字符串),(字符串),(字符串),(布尔值),(字符串),(字符串数组)
address_idbilling_group_idconnection_idcustomer_referenceexternal_pinhd_voice_enabledidtagsjavascript
const phoneNumber = await client.phoneNumbers.update('1293384261075731499');
console.log(phoneNumber.data);返回:(字符串 | null),(布尔值),(布尔值),(布尔值),(布尔值),(字符串 | null),(字符串 | null),(字符串),(日期时间),(字符串 | null),(布尔值),(字符串 | null),(布尔值),(枚举:active, deprovisioning, disabled, provisioning, provisioning-failed),(字符串 | null),(布尔值),(字符串),(枚举:disabled, reject_calls, flag_calls),(字符串 | null),(字符串 | null),(字符串),(枚举:local, toll_free, mobile, national, shared_cost, landline, tollfree, shortcode, longcode),(字符串),(字符串),(对象),(枚举:purchase-pending, purchase-failed, port-pending, port-failed, active, deleted, emergency-only, ported-out, port-out-pending, requirement-info-pending, requirement-info-under-review, requirement-info-exception, provision-pending),(布尔值),(字符串数组),(字符串)
billing_group_idcall_forwarding_enabledcall_recording_enabledcaller_id_name_enabledcnam_listing_enabledconnection_idconnection_namecountry_iso_alpha2created_atcustomer_referencedeletion_lock_enabledemergency_address_idemergency_enabledemergency_statusexternal_pinhd_voice_enabledidinbound_call_screeningmessaging_profile_idmessaging_profile_namephone_numberphone_number_typepurchased_atrecord_typesource_typestatust38_fax_gateway_enabledtagsupdated_atDelete a phone number
删除单个电话号码
DELETE /phone_numbers/{id}javascript
const phoneNumber = await client.phoneNumbers.delete('1293384261075731499');
console.log(phoneNumber.data);Returns: (string), (boolean), (boolean), (boolean), (boolean), (string), (string), (string), (string), (boolean), (string), (boolean), (string), (boolean), (string), (string), (string), (string), (enum: local, toll_free, mobile, national, shared_cost, landline), (string), (string), (enum: purchase-pending, purchase-failed, port-pending, port-failed, active, deleted, emergency-only, ported-out, port-out-pending), (boolean), (array[string]), (string)
billing_group_idcall_forwarding_enabledcall_recording_enabledcaller_id_name_enabledcnam_listing_enabledconnection_idconnection_namecreated_atcustomer_referencedeletion_lock_enabledemergency_address_idemergency_enabledexternal_pinhd_voice_enabledidmessaging_profile_idmessaging_profile_namephone_numberphone_number_typepurchased_atrecord_typestatust38_fax_gateway_enabledtagsupdated_atDELETE /phone_numbers/{id}javascript
const phoneNumber = await client.phoneNumbers.delete('1293384261075731499');
console.log(phoneNumber.data);返回:(字符串),(布尔值),(布尔值),(布尔值),(布尔值),(字符串),(字符串),(字符串),(字符串),(布尔值),(字符串),(布尔值),(字符串),(布尔值),(字符串),(字符串),(字符串),(字符串),(枚举:local, toll_free, mobile, national, shared_cost, landline),(字符串),(字符串),(枚举:purchase-pending, purchase-failed, port-pending, port-failed, active, deleted, emergency-only, ported-out, port-out-pending),(布尔值),(字符串数组),(字符串)
billing_group_idcall_forwarding_enabledcall_recording_enabledcaller_id_name_enabledcnam_listing_enabledconnection_idconnection_namecreated_atcustomer_referencedeletion_lock_enabledemergency_address_idemergency_enabledexternal_pinhd_voice_enabledidmessaging_profile_idmessaging_profile_namephone_numberphone_number_typepurchased_atrecord_typestatust38_fax_gateway_enabledtagsupdated_atChange the bundle status for a phone number (set to being in a bundle or remove from a bundle)
修改电话号码的套餐状态(加入套餐或移出套餐)
PATCH /phone_numbers/{id}/actions/bundle_status_changebundle_idjavascript
const response = await client.phoneNumbers.actions.changeBundleStatus('1293384261075731499', {
bundle_id: '5194d8fc-87e6-4188-baa9-1c434bbe861b',
});
console.log(response.data);Returns: (object), (object), (object), (string), (string), (object), (string), (enum: disabled, reject_calls, flag_calls), (object), (string), (string), (boolean), (string), (enum: pay-per-minute, channel)
call_forwardingcall_recordingcnam_listingconnection_idcustomer_referenceemergencyidinbound_call_screeningmedia_featuresphone_numberrecord_typetech_prefix_enabledtranslated_numberusage_payment_methodPATCH /phone_numbers/{id}/actions/bundle_status_changebundle_idjavascript
const response = await client.phoneNumbers.actions.changeBundleStatus('1293384261075731499', {
bundle_id: '5194d8fc-87e6-4188-baa9-1c434bbe861b',
});
console.log(response.data);返回:(对象),(对象),(对象),(字符串),(字符串),(对象),(字符串),(枚举:disabled, reject_calls, flag_calls),(对象),(字符串),(字符串),(布尔值),(字符串),(枚举:pay-per-minute, channel)
call_forwardingcall_recordingcnam_listingconnection_idcustomer_referenceemergencyidinbound_call_screeningmedia_featuresphone_numberrecord_typetech_prefix_enabledtranslated_numberusage_payment_methodEnable emergency for a phone number
启用电话号码的紧急呼叫功能
POST /phone_numbers/{id}/actions/enable_emergencyemergency_enabledemergency_address_idjavascript
const response = await client.phoneNumbers.actions.enableEmergency('1293384261075731499', {
emergency_address_id: '53829456729313',
emergency_enabled: true,
});
console.log(response.data);Returns: (object), (object), (object), (string), (string), (object), (string), (enum: disabled, reject_calls, flag_calls), (object), (string), (string), (boolean), (string), (enum: pay-per-minute, channel)
call_forwardingcall_recordingcnam_listingconnection_idcustomer_referenceemergencyidinbound_call_screeningmedia_featuresphone_numberrecord_typetech_prefix_enabledtranslated_numberusage_payment_methodPOST /phone_numbers/{id}/actions/enable_emergencyemergency_enabledemergency_address_idjavascript
const response = await client.phoneNumbers.actions.enableEmergency('1293384261075731499', {
emergency_address_id: '53829456729313',
emergency_enabled: true,
});
console.log(response.data);返回:(对象),(对象),(对象),(字符串),(字符串),(对象),(字符串),(枚举:disabled, reject_calls, flag_calls),(对象),(字符串),(字符串),(布尔值),(字符串),(枚举:pay-per-minute, channel)
call_forwardingcall_recordingcnam_listingconnection_idcustomer_referenceemergencyidinbound_call_screeningmedia_featuresphone_numberrecord_typetech_prefix_enabledtranslated_numberusage_payment_methodRetrieve a phone number with messaging settings
查询单个带消息设置的电话号码
GET /phone_numbers/{id}/messagingjavascript
const messaging = await client.phoneNumbers.messaging.retrieve('550e8400-e29b-41d4-a716-446655440000');
console.log(messaging.data);Returns: (string), (date-time), (array[string]), (object), (object), (string), (string), (string | null), (string), (string), (enum: messaging_phone_number, messaging_settings), (array[string]), (string), (enum: long-code, toll-free, short-code, longcode, tollfree, shortcode), (date-time)
country_codecreated_ateligible_messaging_productsfeatureshealthidmessaging_productmessaging_profile_idorganization_idphone_numberrecord_typetagstraffic_typetypeupdated_atGET /phone_numbers/{id}/messagingjavascript
const messaging = await client.phoneNumbers.messaging.retrieve('550e8400-e29b-41d4-a716-446655440000');
console.log(messaging.data);返回:(字符串),(日期时间),(字符串数组),(对象),(对象),(字符串),(字符串),(字符串 | null),(字符串),(字符串),(枚举:messaging_phone_number, messaging_settings),(字符串数组),(字符串),(枚举:long-code, toll-free, short-code, longcode, tollfree, shortcode),(日期时间)
country_codecreated_ateligible_messaging_productsfeatureshealthidmessaging_productmessaging_profile_idorganization_idphone_numberrecord_typetagstraffic_typetypeupdated_atUpdate the messaging profile and/or messaging product of a phone number
更新电话号码的消息配置和/或消息产品
PATCH /phone_numbers/{id}/messagingOptional: (string), (string), (array[string])
messaging_productmessaging_profile_idtagsjavascript
const messaging = await client.phoneNumbers.messaging.update('550e8400-e29b-41d4-a716-446655440000');
console.log(messaging.data);Returns: (string), (date-time), (array[string]), (object), (object), (string), (string), (string | null), (string), (string), (enum: messaging_phone_number, messaging_settings), (array[string]), (string), (enum: long-code, toll-free, short-code, longcode, tollfree, shortcode), (date-time)
country_codecreated_ateligible_messaging_productsfeatureshealthidmessaging_productmessaging_profile_idorganization_idphone_numberrecord_typetagstraffic_typetypeupdated_atPATCH /phone_numbers/{id}/messaging可选参数:(字符串),(字符串),(字符串数组)
messaging_productmessaging_profile_idtagsjavascript
const messaging = await client.phoneNumbers.messaging.update('550e8400-e29b-41d4-a716-446655440000');
console.log(messaging.data);返回:(字符串),(日期时间),(字符串数组),(对象),(对象),(字符串),(字符串),(字符串 | null),(字符串),(字符串),(枚举:messaging_phone_number, messaging_settings),(字符串数组),(字符串),(枚举:long-code, toll-free, short-code, longcode, tollfree, shortcode),(日期时间)
country_codecreated_ateligible_messaging_productsfeatureshealthidmessaging_productmessaging_profile_idorganization_idphone_numberrecord_typetagstraffic_typetypeupdated_atRetrieve a phone number with voice settings
查询单个带语音设置的电话号码
GET /phone_numbers/{id}/voicejavascript
const voice = await client.phoneNumbers.voice.retrieve('1293384261075731499');
console.log(voice.data);Returns: (object), (object), (object), (string), (string), (object), (string), (enum: disabled, reject_calls, flag_calls), (object), (string), (string), (boolean), (string), (enum: pay-per-minute, channel)
call_forwardingcall_recordingcnam_listingconnection_idcustomer_referenceemergencyidinbound_call_screeningmedia_featuresphone_numberrecord_typetech_prefix_enabledtranslated_numberusage_payment_methodGET /phone_numbers/{id}/voicejavascript
const voice = await client.phoneNumbers.voice.retrieve('1293384261075731499');
console.log(voice.data);返回:(对象),(对象),(对象),(字符串),(字符串),(对象),(字符串),(枚举:disabled, reject_calls, flag_calls),(对象),(字符串),(字符串),(布尔值),(字符串),(枚举:pay-per-minute, channel)
call_forwardingcall_recordingcnam_listingconnection_idcustomer_referenceemergencyidinbound_call_screeningmedia_featuresphone_numberrecord_typetech_prefix_enabledtranslated_numberusage_payment_methodUpdate a phone number with voice settings
更新单个带语音设置的电话号码
PATCH /phone_numbers/{id}/voiceOptional: (object), (object), (boolean), (object), (enum: disabled, reject_calls, flag_calls), (object), (boolean), (string), (enum: pay-per-minute, channel)
call_forwardingcall_recordingcaller_id_name_enabledcnam_listinginbound_call_screeningmedia_featurestech_prefix_enabledtranslated_numberusage_payment_methodjavascript
const voice = await client.phoneNumbers.voice.update('1293384261075731499');
console.log(voice.data);Returns: (object), (object), (object), (string), (string), (object), (string), (enum: disabled, reject_calls, flag_calls), (object), (string), (string), (boolean), (string), (enum: pay-per-minute, channel)
call_forwardingcall_recordingcnam_listingconnection_idcustomer_referenceemergencyidinbound_call_screeningmedia_featuresphone_numberrecord_typetech_prefix_enabledtranslated_numberusage_payment_methodPATCH /phone_numbers/{id}/voice可选参数:(对象),(对象),(布尔值),(对象),(枚举:disabled, reject_calls, flag_calls),(对象),(布尔值),(字符串),(枚举:pay-per-minute, channel)
call_forwardingcall_recordingcaller_id_name_enabledcnam_listinginbound_call_screeningmedia_featurestech_prefix_enabledtranslated_numberusage_payment_methodjavascript
const voice = await client.phoneNumbers.voice.update('1293384261075731499');
console.log(voice.data);返回:(对象),(对象),(对象),(字符串),(字符串),(对象),(字符串),(枚举:disabled, reject_calls, flag_calls),(对象),(字符串),(字符串),(布尔值),(字符串),(枚举:pay-per-minute, channel)
call_forwardingcall_recordingcnam_listingconnection_idcustomer_referenceemergencyidinbound_call_screeningmedia_featuresphone_numberrecord_typetech_prefix_enabledtranslated_numberusage_payment_methodList Mobile Phone Numbers
列出手机号码
GET /v2/mobile_phone_numbersjavascript
// Automatically fetches more pages as needed.
for await (const mobilePhoneNumber of client.mobilePhoneNumbers.list()) {
console.log(mobilePhoneNumber.id);
}Returns: (object), (object), (boolean), (object), (string | null), (string | null), (string | null), (string), (date-time), (string | null), (string), (object), (enum: disabled, reject_calls, flag_calls), (boolean), (enum: inbound, outbound, both, disabled), (object), (string), (string), (uuid), (string), (array[string]), (date-time)
call_forwardingcall_recordingcaller_id_name_enabledcnam_listingconnection_idconnection_nameconnection_typecountry_iso_alpha2created_atcustomer_referenceidinboundinbound_call_screeningmobile_voice_enablednoise_suppressionoutboundphone_numberrecord_typesim_card_idstatustagsupdated_atGET /v2/mobile_phone_numbersjavascript
// Automatically fetches more pages as needed.
for await (const mobilePhoneNumber of client.mobilePhoneNumbers.list()) {
console.log(mobilePhoneNumber.id);
}返回:(对象),(对象),(布尔值),(对象),(字符串 | null),(字符串 | null),(字符串 | null),(字符串),(日期时间),(字符串 | null),(字符串),(对象),(枚举:disabled, reject_calls, flag_calls),(布尔值),(枚举:inbound, outbound, both, disabled),(对象),(字符串),(字符串),(UUID),(字符串),(字符串数组),(日期时间)
call_forwardingcall_recordingcaller_id_name_enabledcnam_listingconnection_idconnection_nameconnection_typecountry_iso_alpha2created_atcustomer_referenceidinboundinbound_call_screeningmobile_voice_enablednoise_suppressionoutboundphone_numberrecord_typesim_card_idstatustagsupdated_atRetrieve a Mobile Phone Number
查询单个手机号码
GET /v2/mobile_phone_numbers/{id}javascript
const mobilePhoneNumber = await client.mobilePhoneNumbers.retrieve('550e8400-e29b-41d4-a716-446655440000');
console.log(mobilePhoneNumber.data);Returns: (object), (object), (boolean), (object), (string | null), (string | null), (string | null), (string), (date-time), (string | null), (string), (object), (enum: disabled, reject_calls, flag_calls), (boolean), (enum: inbound, outbound, both, disabled), (object), (string), (string), (uuid), (string), (array[string]), (date-time)
call_forwardingcall_recordingcaller_id_name_enabledcnam_listingconnection_idconnection_nameconnection_typecountry_iso_alpha2created_atcustomer_referenceidinboundinbound_call_screeningmobile_voice_enablednoise_suppressionoutboundphone_numberrecord_typesim_card_idstatustagsupdated_atGET /v2/mobile_phone_numbers/{id}javascript
const mobilePhoneNumber = await client.mobilePhoneNumbers.retrieve('550e8400-e29b-41d4-a716-446655440000');
console.log(mobilePhoneNumber.data);返回:(对象),(对象),(布尔值),(对象),(字符串 | null),(字符串 | null),(字符串 | null),(字符串),(日期时间),(字符串 | null),(字符串),(对象),(枚举:disabled, reject_calls, flag_calls),(布尔值),(枚举:inbound, outbound, both, disabled),(对象),(字符串),(字符串),(UUID),(字符串),(字符串数组),(日期时间)
call_forwardingcall_recordingcaller_id_name_enabledcnam_listingconnection_idconnection_nameconnection_typecountry_iso_alpha2created_atcustomer_referenceidinboundinbound_call_screeningmobile_voice_enablednoise_suppressionoutboundphone_numberrecord_typesim_card_idstatustagsupdated_atUpdate a Mobile Phone Number
更新单个手机号码
PATCH /v2/mobile_phone_numbers/{id}Optional: (object), (object), (boolean), (object), (string | null), (string | null), (object), (enum: disabled, reject_calls, flag_calls), (boolean), (object), (array[string])
call_forwardingcall_recordingcaller_id_name_enabledcnam_listingconnection_idcustomer_referenceinboundinbound_call_screeningnoise_suppressionoutboundtagsjavascript
const mobilePhoneNumber = await client.mobilePhoneNumbers.update('550e8400-e29b-41d4-a716-446655440000');
console.log(mobilePhoneNumber.data);Returns: (object), (object), (boolean), (object), (string | null), (string | null), (string | null), (string), (date-time), (string | null), (string), (object), (enum: disabled, reject_calls, flag_calls), (boolean), (enum: inbound, outbound, both, disabled), (object), (string), (string), (uuid), (string), (array[string]), (date-time)
call_forwardingcall_recordingcaller_id_name_enabledcnam_listingconnection_idconnection_nameconnection_typecountry_iso_alpha2created_atcustomer_referenceidinboundinbound_call_screeningmobile_voice_enablednoise_suppressionoutboundphone_numberrecord_typesim_card_idstatustagsupdated_atPATCH /v2/mobile_phone_numbers/{id}可选参数:(对象),(对象),(布尔值),(对象),(字符串 | null),(字符串 | null),(对象),(枚举:disabled, reject_calls, flag_calls),(布尔值),(对象),(字符串数组)
call_forwardingcall_recordingcaller_id_name_enabledcnam_listingconnection_idcustomer_referenceinboundinbound_call_screeningnoise_suppressionoutboundtagsjavascript
const mobilePhoneNumber = await client.mobilePhoneNumbers.update('550e8400-e29b-41d4-a716-446655440000');
console.log(mobilePhoneNumber.data);返回:(对象),(对象),(布尔值),(对象),(字符串 | null),(字符串 | null),(字符串 | null),(字符串),(日期时间),(字符串 | null),(字符串),(对象),(枚举:disabled, reject_calls, flag_calls),(布尔值),(枚举:inbound, outbound, both, disabled),(对象),(字符串),(字符串),(UUID),(字符串),(字符串数组),(日期时间)
call_forwardingcall_recordingcaller_id_name_enabledcnam_listingconnection_idconnection_nameconnection_typecountry_iso_alpha2created_atcustomer_referenceidinboundinbound_call_screeningmobile_voice_enablednoise_suppressionoutboundphone_numberrecord_typesim_card_idstatustagsupdated_at