telnyx-numbers-compliance-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 Compliance - JavaScript

Telnyx 号码合规 - JavaScript

Installation

安装

bash
npm install telnyx
bash
npm install telnyx

Setup

初始化

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
client
is already initialized as shown above.
javascript
import Telnyx from 'telnyx';

const client = new Telnyx({
  apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
以下所有示例均假设
client
已按照上述方式完成初始化。

Error 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:
401
invalid API key,
403
insufficient permissions,
404
resource not found,
422
validation error (check field formats),
429
rate limited (retry with exponential backoff).
所有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');
    }
  }
}
常见错误码:
401
API密钥无效,
403
权限不足,
404
资源未找到,
422
验证错误(检查字段格式),
429
请求受限(使用指数退避策略重试)。

Important Notes

重要注意事项

  • Phone numbers must be in E.164 format (e.g.,
    +13125550001
    ). Include the
    +
    prefix and country code. No spaces, dashes, or parentheses.
  • Pagination: List methods return an auto-paginating iterator. Use
    for await (const item of result) { ... }
    to iterate through all pages automatically.
  • 电话号码必须采用E.164格式(例如:
    +13125550001
    )。需包含
    +
    前缀和国家代码,不能有空格、短横线或括号。
  • 分页处理:列表类方法会返回自动分页的迭代器。使用
    for await (const item of result) { ... }
    可自动遍历所有页面。

Retrieve Bundles

获取所有套餐

Get all allowed bundles.
GET /bundle_pricing/billing_bundles
javascript
// Automatically fetches more pages as needed.
for await (const billingBundleSummary of client.bundlePricing.billingBundles.list()) {
  console.log(billingBundleSummary.id);
}
Returns:
cost_code
(string),
created_at
(date),
currency
(string),
id
(uuid),
is_public
(boolean),
mrc_price
(float),
name
(string),
slug
(string),
specs
(array[string])
获取所有可用套餐。
GET /bundle_pricing/billing_bundles
javascript
// Automatically fetches more pages as needed.
for await (const billingBundleSummary of client.bundlePricing.billingBundles.list()) {
  console.log(billingBundleSummary.id);
}
返回字段:
cost_code
(字符串)、
created_at
(日期)、
currency
(字符串)、
id
(UUID)、
is_public
(布尔值)、
mrc_price
(浮点数)、
name
(字符串)、
slug
(字符串)、
specs
(字符串数组)

Get Bundle By Id

通过ID获取套餐

Get a single bundle by ID.
GET /bundle_pricing/billing_bundles/{bundle_id}
javascript
const billingBundle = await client.bundlePricing.billingBundles.retrieve(
  '8661948c-a386-4385-837f-af00f40f111a',
);

console.log(billingBundle.data);
Returns:
active
(boolean),
bundle_limits
(array[object]),
cost_code
(string),
created_at
(date),
id
(uuid),
is_public
(boolean),
name
(string),
slug
(string)
通过ID获取单个套餐详情。
GET /bundle_pricing/billing_bundles/{bundle_id}
javascript
const billingBundle = await client.bundlePricing.billingBundles.retrieve(
  '8661948c-a386-4385-837f-af00f40f111a',
);

console.log(billingBundle.data);
返回字段:
active
(布尔值)、
bundle_limits
(对象数组)、
cost_code
(字符串)、
created_at
(日期)、
id
(UUID)、
is_public
(布尔值)、
name
(字符串)、
slug
(字符串)

Get User Bundles

获取用户套餐

Get a paginated list of user bundles.
GET /bundle_pricing/user_bundles
javascript
// Automatically fetches more pages as needed.
for await (const userBundle of client.bundlePricing.userBundles.list()) {
  console.log(userBundle.id);
}
Returns:
active
(boolean),
billing_bundle
(object),
created_at
(date),
id
(uuid),
resources
(array[object]),
updated_at
(date),
user_id
(uuid)
获取用户套餐的分页列表。
GET /bundle_pricing/user_bundles
javascript
// Automatically fetches more pages as needed.
for await (const userBundle of client.bundlePricing.userBundles.list()) {
  console.log(userBundle.id);
}
返回字段:
active
(布尔值)、
billing_bundle
(对象)、
created_at
(日期)、
id
(UUID)、
resources
(对象数组)、
updated_at
(日期)、
user_id
(UUID)

Create User Bundles

创建用户套餐

Creates multiple user bundles for the user.
POST /bundle_pricing/user_bundles/bulk
Optional:
idempotency_key
(uuid),
items
(array[object])
javascript
const userBundle = await client.bundlePricing.userBundles.create();

console.log(userBundle.data);
Returns:
active
(boolean),
billing_bundle
(object),
created_at
(date),
id
(uuid),
resources
(array[object]),
updated_at
(date),
user_id
(uuid)
为用户批量创建多个用户套餐。
POST /bundle_pricing/user_bundles/bulk
可选参数:
idempotency_key
(UUID)、
items
(对象数组)
javascript
const userBundle = await client.bundlePricing.userBundles.create();

console.log(userBundle.data);
返回字段:
active
(布尔值)、
billing_bundle
(对象)、
created_at
(日期)、
id
(UUID)、
resources
(对象数组)、
updated_at
(日期)、
user_id
(UUID)

Get Unused User Bundles

获取未使用的用户套餐

Returns all user bundles that aren't in use.
GET /bundle_pricing/user_bundles/unused
javascript
const response = await client.bundlePricing.userBundles.listUnused();

console.log(response.data);
Returns:
billing_bundle
(object),
user_bundle_ids
(array[string])
返回所有未被使用的用户套餐。
GET /bundle_pricing/user_bundles/unused
javascript
const response = await client.bundlePricing.userBundles.listUnused();

console.log(response.data);
返回字段:
billing_bundle
(对象)、
user_bundle_ids
(字符串数组)

Get User Bundle by Id

通过ID获取用户套餐

Retrieves a user bundle by its ID.
GET /bundle_pricing/user_bundles/{user_bundle_id}
javascript
const userBundle = await client.bundlePricing.userBundles.retrieve(
  'ca1d2263-d1f1-43ac-ba53-248e7a4bb26a',
);

console.log(userBundle.data);
Returns:
active
(boolean),
billing_bundle
(object),
created_at
(date),
id
(uuid),
resources
(array[object]),
updated_at
(date),
user_id
(uuid)
通过ID获取用户套餐详情。
GET /bundle_pricing/user_bundles/{user_bundle_id}
javascript
const userBundle = await client.bundlePricing.userBundles.retrieve(
  'ca1d2263-d1f1-43ac-ba53-248e7a4bb26a',
);

console.log(userBundle.data);
返回字段:
active
(布尔值)、
billing_bundle
(对象)、
created_at
(日期)、
id
(UUID)、
resources
(对象数组)、
updated_at
(日期)、
user_id
(UUID)

Deactivate User Bundle

停用用户套餐

Deactivates a user bundle by its ID.
DELETE /bundle_pricing/user_bundles/{user_bundle_id}
javascript
const response = await client.bundlePricing.userBundles.deactivate(
  'ca1d2263-d1f1-43ac-ba53-248e7a4bb26a',
);

console.log(response.data);
Returns:
active
(boolean),
billing_bundle
(object),
created_at
(date),
id
(uuid),
resources
(array[object]),
updated_at
(date),
user_id
(uuid)
通过ID停用用户套餐。
DELETE /bundle_pricing/user_bundles/{user_bundle_id}
javascript
const response = await client.bundlePricing.userBundles.deactivate(
  'ca1d2263-d1f1-43ac-ba53-248e7a4bb26a',
);

console.log(response.data);
返回字段:
active
(布尔值)、
billing_bundle
(对象)、
created_at
(日期)、
id
(UUID)、
resources
(对象数组)、
updated_at
(日期)、
user_id
(UUID)

Get User Bundle Resources

获取用户套餐资源

Retrieves the resources of a user bundle by its ID.
GET /bundle_pricing/user_bundles/{user_bundle_id}/resources
javascript
const response = await client.bundlePricing.userBundles.listResources(
  'ca1d2263-d1f1-43ac-ba53-248e7a4bb26a',
);

console.log(response.data);
Returns:
created_at
(date),
id
(uuid),
resource
(string),
resource_type
(string),
updated_at
(date)
通过ID获取用户套餐的资源详情。
GET /bundle_pricing/user_bundles/{user_bundle_id}/resources
javascript
const response = await client.bundlePricing.userBundles.listResources(
  'ca1d2263-d1f1-43ac-ba53-248e7a4bb26a',
);

console.log(response.data);
返回字段:
created_at
(日期)、
id
(UUID)、
resource
(字符串)、
resource_type
(字符串)、
updated_at
(日期)

List all document links

列出所有文档链接

List all documents links ordered by created_at descending.
GET /document_links
javascript
// Automatically fetches more pages as needed.
for await (const documentLinkListResponse of client.documentLinks.list()) {
  console.log(documentLinkListResponse.id);
}
Returns:
created_at
(string),
document_id
(uuid),
id
(uuid),
linked_record_type
(string),
linked_resource_id
(string),
record_type
(string),
updated_at
(string)
按创建时间降序列出所有文档链接。
GET /document_links
javascript
// Automatically fetches more pages as needed.
for await (const documentLinkListResponse of client.documentLinks.list()) {
  console.log(documentLinkListResponse.id);
}
返回字段:
created_at
(字符串)、
document_id
(UUID)、
id
(UUID)、
linked_record_type
(字符串)、
linked_resource_id
(字符串)、
record_type
(字符串)、
updated_at
(字符串)

List all documents

列出所有文档

List all documents ordered by created_at descending.
GET /documents
javascript
// Automatically fetches more pages as needed.
for await (const docServiceDocument of client.documents.list()) {
  console.log(docServiceDocument.id);
}
Returns:
av_scan_status
(enum: scanned, infected, pending_scan, not_scanned),
content_type
(string),
created_at
(string),
customer_reference
(string),
filename
(string),
id
(uuid),
record_type
(string),
sha256
(string),
size
(object),
status
(enum: pending, verified, denied),
updated_at
(string)
按创建时间降序列出所有文档。
GET /documents
javascript
// Automatically fetches more pages as needed.
for await (const docServiceDocument of client.documents.list()) {
  console.log(docServiceDocument.id);
}
返回字段:
av_scan_status
(枚举值:scanned, infected, pending_scan, not_scanned)、
content_type
(字符串)、
created_at
(字符串)、
customer_reference
(字符串)、
filename
(字符串)、
id
(UUID)、
record_type
(字符串)、
sha256
(字符串)、
size
(对象)、
status
(枚举值:pending, verified, denied)、
updated_at
(字符串)

Upload a document

上传文档

Upload a document. Uploaded files must be linked to a service within 30 minutes or they will be automatically deleted.
POST /documents
Optional:
customer_reference
(string),
file
(byte),
filename
(string),
url
(string)
javascript
const response = await client.documents.uploadJson({ document: {} });

console.log(response.data);
Returns:
av_scan_status
(enum: scanned, infected, pending_scan, not_scanned),
content_type
(string),
created_at
(string),
customer_reference
(string),
filename
(string),
id
(uuid),
record_type
(string),
sha256
(string),
size
(object),
status
(enum: pending, verified, denied),
updated_at
(string)
上传文档。上传的文件必须在30分钟内关联到服务,否则将被自动删除。
POST /documents
可选参数:
customer_reference
(字符串)、
file
(字节)、
filename
(字符串)、
url
(字符串)
javascript
const response = await client.documents.uploadJson({ document: {} });

console.log(response.data);
返回字段:
av_scan_status
(枚举值:scanned, infected, pending_scan, not_scanned)、
content_type
(字符串)、
created_at
(字符串)、
customer_reference
(字符串)、
filename
(字符串)、
id
(UUID)、
record_type
(字符串)、
sha256
(字符串)、
size
(对象)、
status
(枚举值:pending, verified, denied)、
updated_at
(字符串)

Retrieve a document

获取文档详情

Retrieve a document.
GET /documents/{id}
javascript
const document = await client.documents.retrieve('6a09cdc3-8948-47f0-aa62-74ac943d6c58');

console.log(document.data);
Returns:
av_scan_status
(enum: scanned, infected, pending_scan, not_scanned),
content_type
(string),
created_at
(string),
customer_reference
(string),
filename
(string),
id
(uuid),
record_type
(string),
sha256
(string),
size
(object),
status
(enum: pending, verified, denied),
updated_at
(string)
获取指定文档的详情。
GET /documents/{id}
javascript
const document = await client.documents.retrieve('6a09cdc3-8948-47f0-aa62-74ac943d6c58');

console.log(document.data);
返回字段:
av_scan_status
(枚举值:scanned, infected, pending_scan, not_scanned)、
content_type
(字符串)、
created_at
(字符串)、
customer_reference
(字符串)、
filename
(字符串)、
id
(UUID)、
record_type
(字符串)、
sha256
(字符串)、
size
(对象)、
status
(枚举值:pending, verified, denied)、
updated_at
(字符串)

Update a document

更新文档

Update a document.
PATCH /documents/{id}
Optional:
av_scan_status
(enum: scanned, infected, pending_scan, not_scanned),
content_type
(string),
created_at
(string),
customer_reference
(string),
filename
(string),
id
(uuid),
record_type
(string),
sha256
(string),
size
(object),
status
(enum: pending, verified, denied),
updated_at
(string)
javascript
const document = await client.documents.update('6a09cdc3-8948-47f0-aa62-74ac943d6c58');

console.log(document.data);
Returns:
av_scan_status
(enum: scanned, infected, pending_scan, not_scanned),
content_type
(string),
created_at
(string),
customer_reference
(string),
filename
(string),
id
(uuid),
record_type
(string),
sha256
(string),
size
(object),
status
(enum: pending, verified, denied),
updated_at
(string)
更新指定文档的信息。
PATCH /documents/{id}
可选参数:
av_scan_status
(枚举值:scanned, infected, pending_scan, not_scanned)、
content_type
(字符串)、
created_at
(字符串)、
customer_reference
(字符串)、
filename
(字符串)、
id
(UUID)、
record_type
(字符串)、
sha256
(字符串)、
size
(对象)、
status
(枚举值:pending, verified, denied)、
updated_at
(字符串)
javascript
const document = await client.documents.update('6a09cdc3-8948-47f0-aa62-74ac943d6c58');

console.log(document.data);
返回字段:
av_scan_status
(枚举值:scanned, infected, pending_scan, not_scanned)、
content_type
(字符串)、
created_at
(字符串)、
customer_reference
(字符串)、
filename
(字符串)、
id
(UUID)、
record_type
(字符串)、
sha256
(字符串)、
size
(对象)、
status
(枚举值:pending, verified, denied)、
updated_at
(字符串)

Delete a document

删除文档

Delete a document. A document can only be deleted if it's not linked to a service. If it is linked to a service, it must be unlinked prior to deleting.
DELETE /documents/{id}
javascript
const document = await client.documents.delete('6a09cdc3-8948-47f0-aa62-74ac943d6c58');

console.log(document.data);
Returns:
av_scan_status
(enum: scanned, infected, pending_scan, not_scanned),
content_type
(string),
created_at
(string),
customer_reference
(string),
filename
(string),
id
(uuid),
record_type
(string),
sha256
(string),
size
(object),
status
(enum: pending, verified, denied),
updated_at
(string)
删除指定文档。只有未关联到服务的文档才能被删除,如果已关联服务,必须先解除关联再删除。
DELETE /documents/{id}
javascript
const document = await client.documents.delete('6a09cdc3-8948-47f0-aa62-74ac943d6c58');

console.log(document.data);
返回字段:
av_scan_status
(枚举值:scanned, infected, pending_scan, not_scanned)、
content_type
(字符串)、
created_at
(字符串)、
customer_reference
(字符串)、
filename
(字符串)、
id
(UUID)、
record_type
(字符串)、
sha256
(字符串)、
size
(对象)、
status
(枚举值:pending, verified, denied)、
updated_at
(字符串)

Download a document

下载文档

Download a document.
GET /documents/{id}/download
javascript
const response = await client.documents.download('6a09cdc3-8948-47f0-aa62-74ac943d6c58');

console.log(response);

const content = await response.blob();
console.log(content);
下载指定文档。
GET /documents/{id}/download
javascript
const response = await client.documents.download('6a09cdc3-8948-47f0-aa62-74ac943d6c58');

console.log(response);

const content = await response.blob();
console.log(content);

Generate a temporary download link for a document

生成文档临时下载链接

Generates a temporary pre-signed URL that can be used to download the document directly from the storage backend without authentication.
GET /documents/{id}/download_link
javascript
const response = await client.documents.generateDownloadLink(
  '550e8400-e29b-41d4-a716-446655440000',
);

console.log(response.data);
Returns:
url
(uri)
生成一个临时预签名URL,无需认证即可直接从存储后端下载文档。
GET /documents/{id}/download_link
javascript
const response = await client.documents.generateDownloadLink(
  '550e8400-e29b-41d4-a716-446655440000',
);

console.log(response.data);
返回字段:
url
(URI)

Update requirement group for a phone number order

更新电话号码订单的需求组

POST /number_order_phone_numbers/{id}/requirement_group
— Required:
requirement_group_id
javascript
const response = await client.numberOrderPhoneNumbers.updateRequirementGroup(
  '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
  { requirement_group_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e' },
);

console.log(response.data);
Returns:
bundle_id
(uuid),
country_code
(string),
deadline
(date-time),
id
(uuid),
is_block_number
(boolean),
locality
(string),
order_request_id
(uuid),
phone_number
(string),
phone_number_type
(string),
record_type
(string),
regulatory_requirements
(array[object]),
requirements_met
(boolean),
requirements_status
(string),
status
(string),
sub_number_order_id
(uuid)
POST /number_order_phone_numbers/{id}/requirement_group
— 必填参数:
requirement_group_id
javascript
const response = await client.numberOrderPhoneNumbers.updateRequirementGroup(
  '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
  { requirement_group_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e' },
);

console.log(response.data);
返回字段:
bundle_id
(UUID)、
country_code
(字符串)、
deadline
(日期时间)、
id
(UUID)、
is_block_number
(布尔值)、
locality
(字符串)、
order_request_id
(UUID)、
phone_number
(字符串)、
phone_number_type
(字符串)、
record_type
(字符串)、
regulatory_requirements
(对象数组)、
requirements_met
(布尔值)、
requirements_status
(字符串)、
status
(字符串)、
sub_number_order_id
(UUID)

Retrieve regulatory requirements for a list of phone numbers

获取电话号码列表的监管要求

GET /phone_numbers_regulatory_requirements
javascript
const phoneNumbersRegulatoryRequirement =
  await client.phoneNumbersRegulatoryRequirements.retrieve();

console.log(phoneNumbersRegulatoryRequirement.data);
Returns:
phone_number
(string),
phone_number_type
(string),
record_type
(string),
region_information
(array[object]),
regulatory_requirements
(array[object])
GET /phone_numbers_regulatory_requirements
javascript
const phoneNumbersRegulatoryRequirement =
  await client.phoneNumbersRegulatoryRequirements.retrieve();

console.log(phoneNumbersRegulatoryRequirement.data);
返回字段:
phone_number
(字符串)、
phone_number_type
(字符串)、
record_type
(字符串)、
region_information
(对象数组)、
regulatory_requirements
(对象数组)

Retrieve regulatory requirements

获取监管要求

GET /regulatory_requirements
javascript
const regulatoryRequirement = await client.regulatoryRequirements.retrieve();

console.log(regulatoryRequirement.data);
Returns:
action
(string),
country_code
(string),
phone_number_type
(string),
regulatory_requirements
(array[object])
GET /regulatory_requirements
javascript
const regulatoryRequirement = await client.regulatoryRequirements.retrieve();

console.log(regulatoryRequirement.data);
返回字段:
action
(字符串)、
country_code
(字符串)、
phone_number_type
(字符串)、
regulatory_requirements
(对象数组)

List requirement groups

列出需求组

GET /requirement_groups
javascript
const requirementGroups = await client.requirementGroups.list();

console.log(requirementGroups);
GET /requirement_groups
javascript
const requirementGroups = await client.requirementGroups.list();

console.log(requirementGroups);

Create a new requirement group

创建新需求组

POST /requirement_groups
— Required:
country_code
,
phone_number_type
,
action
Optional:
customer_reference
(string),
regulatory_requirements
(array[object])
javascript
const requirementGroup = await client.requirementGroups.create({
  action: 'ordering',
  country_code: 'US',
  phone_number_type: 'local',
});

console.log(requirementGroup.id);
Returns:
action
(string),
country_code
(string),
created_at
(date-time),
customer_reference
(string),
id
(string),
phone_number_type
(string),
record_type
(string),
regulatory_requirements
(array[object]),
status
(enum: approved, unapproved, pending-approval, declined, expired),
updated_at
(date-time)
POST /requirement_groups
— 必填参数:
country_code
,
phone_number_type
,
action
可选参数:
customer_reference
(字符串)、
regulatory_requirements
(对象数组)
javascript
const requirementGroup = await client.requirementGroups.create({
  action: 'ordering',
  country_code: 'US',
  phone_number_type: 'local',
});

console.log(requirementGroup.id);
返回字段:
action
(字符串)、
country_code
(字符串)、
created_at
(日期时间)、
customer_reference
(字符串)、
id
(字符串)、
phone_number_type
(字符串)、
record_type
(字符串)、
regulatory_requirements
(对象数组)、
status
(枚举值:approved, unapproved, pending-approval, declined, expired)、
updated_at
(日期时间)

Get a single requirement group by ID

通过ID获取单个需求组

GET /requirement_groups/{id}
javascript
const requirementGroup = await client.requirementGroups.retrieve('550e8400-e29b-41d4-a716-446655440000');

console.log(requirementGroup.id);
Returns:
action
(string),
country_code
(string),
created_at
(date-time),
customer_reference
(string),
id
(string),
phone_number_type
(string),
record_type
(string),
regulatory_requirements
(array[object]),
status
(enum: approved, unapproved, pending-approval, declined, expired),
updated_at
(date-time)
GET /requirement_groups/{id}
javascript
const requirementGroup = await client.requirementGroups.retrieve('550e8400-e29b-41d4-a716-446655440000');

console.log(requirementGroup.id);
返回字段:
action
(字符串)、
country_code
(字符串)、
created_at
(日期时间)、
customer_reference
(字符串)、
id
(字符串)、
phone_number_type
(字符串)、
record_type
(字符串)、
regulatory_requirements
(对象数组)、
status
(枚举值:approved, unapproved, pending-approval, declined, expired)、
updated_at
(日期时间)

Update requirement values in requirement group

更新需求组中的需求值

PATCH /requirement_groups/{id}
Optional:
customer_reference
(string),
regulatory_requirements
(array[object])
javascript
const requirementGroup = await client.requirementGroups.update('550e8400-e29b-41d4-a716-446655440000');

console.log(requirementGroup.id);
Returns:
action
(string),
country_code
(string),
created_at
(date-time),
customer_reference
(string),
id
(string),
phone_number_type
(string),
record_type
(string),
regulatory_requirements
(array[object]),
status
(enum: approved, unapproved, pending-approval, declined, expired),
updated_at
(date-time)
PATCH /requirement_groups/{id}
可选参数:
customer_reference
(字符串)、
regulatory_requirements
(对象数组)
javascript
const requirementGroup = await client.requirementGroups.update('550e8400-e29b-41d4-a716-446655440000');

console.log(requirementGroup.id);
返回字段:
action
(字符串)、
country_code
(字符串)、
created_at
(日期时间)、
customer_reference
(字符串)、
id
(字符串)、
phone_number_type
(字符串)、
record_type
(字符串)、
regulatory_requirements
(对象数组)、
status
(枚举值:approved, unapproved, pending-approval, declined, expired)、
updated_at
(日期时间)

Delete a requirement group by ID

通过ID删除需求组

DELETE /requirement_groups/{id}
javascript
const requirementGroup = await client.requirementGroups.delete('550e8400-e29b-41d4-a716-446655440000');

console.log(requirementGroup.id);
Returns:
action
(string),
country_code
(string),
created_at
(date-time),
customer_reference
(string),
id
(string),
phone_number_type
(string),
record_type
(string),
regulatory_requirements
(array[object]),
status
(enum: approved, unapproved, pending-approval, declined, expired),
updated_at
(date-time)
DELETE /requirement_groups/{id}
javascript
const requirementGroup = await client.requirementGroups.delete('550e8400-e29b-41d4-a716-446655440000');

console.log(requirementGroup.id);
返回字段:
action
(字符串)、
country_code
(字符串)、
created_at
(日期时间)、
customer_reference
(字符串)、
id
(字符串)、
phone_number_type
(字符串)、
record_type
(字符串)、
regulatory_requirements
(对象数组)、
status
(枚举值:approved, unapproved, pending-approval, declined, expired)、
updated_at
(日期时间)

Submit a Requirement Group for Approval

提交需求组审核

POST /requirement_groups/{id}/submit_for_approval
javascript
const requirementGroup = await client.requirementGroups.submitForApproval('550e8400-e29b-41d4-a716-446655440000');

console.log(requirementGroup.id);
Returns:
action
(string),
country_code
(string),
created_at
(date-time),
customer_reference
(string),
id
(string),
phone_number_type
(string),
record_type
(string),
regulatory_requirements
(array[object]),
status
(enum: approved, unapproved, pending-approval, declined, expired),
updated_at
(date-time)
POST /requirement_groups/{id}/submit_for_approval
javascript
const requirementGroup = await client.requirementGroups.submitForApproval('550e8400-e29b-41d4-a716-446655440000');

console.log(requirementGroup.id);
返回字段:
action
(字符串)、
country_code
(字符串)、
created_at
(日期时间)、
customer_reference
(字符串)、
id
(字符串)、
phone_number_type
(字符串)、
record_type
(字符串)、
regulatory_requirements
(对象数组)、
status
(枚举值:approved, unapproved, pending-approval, declined, expired)、
updated_at
(日期时间)

List all requirement types

列出所有需求类型

List all requirement types ordered by created_at descending
GET /requirement_types
javascript
const requirementTypes = await client.requirementTypes.list();

console.log(requirementTypes.data);
Returns:
acceptance_criteria
(object),
created_at
(string),
description
(string),
example
(string),
id
(uuid),
name
(string),
record_type
(string),
type
(enum: document, address, textual),
updated_at
(string)
按创建时间降序列出所有需求类型
GET /requirement_types
javascript
const requirementTypes = await client.requirementTypes.list();

console.log(requirementTypes.data);
返回字段:
acceptance_criteria
(对象)、
created_at
(字符串)、
description
(字符串)、
example
(字符串)、
id
(UUID)、
name
(字符串)、
record_type
(字符串)、
type
(枚举值:document, address, textual)、
updated_at
(字符串)

Retrieve a requirement types

获取需求类型详情

Retrieve a requirement type by id
GET /requirement_types/{id}
javascript
const requirementType = await client.requirementTypes.retrieve(
  'a38c217a-8019-48f8-bff6-0fdd9939075b',
);

console.log(requirementType.data);
Returns:
acceptance_criteria
(object),
created_at
(string),
description
(string),
example
(string),
id
(uuid),
name
(string),
record_type
(string),
type
(enum: document, address, textual),
updated_at
(string)
通过ID获取需求类型详情
GET /requirement_types/{id}
javascript
const requirementType = await client.requirementTypes.retrieve(
  'a38c217a-8019-48f8-bff6-0fdd9939075b',
);

console.log(requirementType.data);
返回字段:
acceptance_criteria
(对象)、
created_at
(字符串)、
description
(字符串)、
example
(字符串)、
id
(UUID)、
name
(字符串)、
record_type
(字符串)、
type
(枚举值:document, address, textual)、
updated_at
(字符串)

List all requirements

列出所有需求

List all requirements with filtering, sorting, and pagination
GET /requirements
javascript
// Automatically fetches more pages as needed.
for await (const requirementListResponse of client.requirements.list()) {
  console.log(requirementListResponse.id);
}
Returns:
action
(enum: both, branded_calling, ordering, porting),
country_code
(string),
created_at
(string),
id
(uuid),
locality
(string),
phone_number_type
(enum: local, national, toll_free),
record_type
(string),
requirements_types
(array[object]),
updated_at
(string)
通过筛选、排序和分页列出所有需求
GET /requirements
javascript
// Automatically fetches more pages as needed.
for await (const requirementListResponse of client.requirements.list()) {
  console.log(requirementListResponse.id);
}
返回字段:
action
(枚举值:both, branded_calling, ordering, porting)、
country_code
(字符串)、
created_at
(字符串)、
id
(UUID)、
locality
(字符串)、
phone_number_type
(枚举值:local, national, toll_free)、
record_type
(字符串)、
requirements_types
(对象数组)、
updated_at
(字符串)

Retrieve a document requirement

获取文档需求详情

Retrieve a document requirement record
GET /requirements/{id}
javascript
const requirement = await client.requirements.retrieve('a9dad8d5-fdbd-49d7-aa23-39bb08a5ebaa');

console.log(requirement.data);
Returns:
action
(enum: both, branded_calling, ordering, porting),
country_code
(string),
created_at
(string),
id
(uuid),
locality
(string),
phone_number_type
(enum: local, national, toll_free),
record_type
(string),
requirements_types
(array[object]),
updated_at
(string)
获取文档需求记录详情
GET /requirements/{id}
javascript
const requirement = await client.requirements.retrieve('a9dad8d5-fdbd-49d7-aa23-39bb08a5ebaa');

console.log(requirement.data);
返回字段:
action
(枚举值:both, branded_calling, ordering, porting)、
country_code
(字符串)、
created_at
(字符串)、
id
(UUID)、
locality
(字符串)、
phone_number_type
(枚举值:local, national, toll_free)、
record_type
(字符串)、
requirements_types
(对象数组)、
updated_at
(字符串)

Update requirement group for a sub number order

更新子号码订单的需求组

POST /sub_number_orders/{id}/requirement_group
— Required:
requirement_group_id
javascript
const response = await client.subNumberOrders.updateRequirementGroup(
  '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
  { requirement_group_id: 'a4b201f9-8646-4e54-a7d2-b2e403eeaf8c' },
);

console.log(response.data);
Returns:
country_code
(string),
created_at
(date-time),
customer_reference
(string),
id
(uuid),
is_block_sub_number_order
(boolean),
order_request_id
(uuid),
phone_number_type
(string),
phone_numbers
(array[object]),
phone_numbers_count
(integer),
record_type
(string),
regulatory_requirements
(array[object]),
requirements_met
(boolean),
status
(string),
updated_at
(date-time)
POST /sub_number_orders/{id}/requirement_group
— 必填参数:
requirement_group_id
javascript
const response = await client.subNumberOrders.updateRequirementGroup(
  '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
  { requirement_group_id: 'a4b201f9-8646-4e54-a7d2-b2e403eeaf8c' },
);

console.log(response.data);
返回字段:
country_code
(字符串)、
created_at
(日期时间)、
customer_reference
(字符串)、
id
(UUID)、
is_block_sub_number_order
(布尔值)、
order_request_id
(UUID)、
phone_number_type
(字符串)、
phone_numbers
(对象数组)、
phone_numbers_count
(整数)、
record_type
(字符串)、
regulatory_requirements
(对象数组)、
requirements_met
(布尔值)、
status
(字符串)、
updated_at
(日期时间)

List all user addresses

列出所有用户地址

Returns a list of your user addresses.
GET /user_addresses
javascript
// Automatically fetches more pages as needed.
for await (const userAddress of client.userAddresses.list()) {
  console.log(userAddress.id);
}
Returns:
administrative_area
(string),
borough
(string),
business_name
(string),
country_code
(string),
created_at
(string),
customer_reference
(string),
extended_address
(string),
first_name
(string),
id
(uuid),
last_name
(string),
locality
(string),
neighborhood
(string),
phone_number
(string),
postal_code
(string),
record_type
(string),
street_address
(string),
updated_at
(string)
返回用户地址列表。
GET /user_addresses
javascript
// Automatically fetches more pages as needed.
for await (const userAddress of client.userAddresses.list()) {
  console.log(userAddress.id);
}
返回字段:
administrative_area
(字符串)、
borough
(字符串)、
business_name
(字符串)、
country_code
(字符串)、
created_at
(字符串)、
customer_reference
(字符串)、
extended_address
(字符串)、
first_name
(字符串)、
id
(UUID)、
last_name
(字符串)、
locality
(字符串)、
neighborhood
(字符串)、
phone_number
(字符串)、
postal_code
(字符串)、
record_type
(字符串)、
street_address
(字符串)、
updated_at
(字符串)

Creates a user address

创建用户地址

Creates a user address.
POST /user_addresses
— Required:
first_name
,
last_name
,
business_name
,
street_address
,
locality
,
country_code
Optional:
administrative_area
(string),
borough
(string),
customer_reference
(string),
extended_address
(string),
neighborhood
(string),
phone_number
(string),
postal_code
(string),
skip_address_verification
(boolean)
javascript
const userAddress = await client.userAddresses.create({
  business_name: "Toy-O'Kon",
  country_code: 'US',
  first_name: 'Alfred',
  last_name: 'Foster',
  locality: 'Austin',
  street_address: '600 Congress Avenue',
});

console.log(userAddress.data);
Returns:
administrative_area
(string),
borough
(string),
business_name
(string),
country_code
(string),
created_at
(string),
customer_reference
(string),
extended_address
(string),
first_name
(string),
id
(uuid),
last_name
(string),
locality
(string),
neighborhood
(string),
phone_number
(string),
postal_code
(string),
record_type
(string),
street_address
(string),
updated_at
(string)
创建用户地址。
POST /user_addresses
— 必填参数:
first_name
,
last_name
,
business_name
,
street_address
,
locality
,
country_code
可选参数:
administrative_area
(字符串)、
borough
(字符串)、
customer_reference
(字符串)、
extended_address
(字符串)、
neighborhood
(字符串)、
phone_number
(字符串)、
postal_code
(字符串)、
skip_address_verification
(布尔值)
javascript
const userAddress = await client.userAddresses.create({
  business_name: "Toy-O'Kon",
  country_code: 'US',
  first_name: 'Alfred',
  last_name: 'Foster',
  locality: 'Austin',
  street_address: '600 Congress Avenue',
});

console.log(userAddress.data);
返回字段:
administrative_area
(字符串)、
borough
(字符串)、
business_name
(字符串)、
country_code
(字符串)、
created_at
(字符串)、
customer_reference
(字符串)、
extended_address
(字符串)、
first_name
(字符串)、
id
(UUID)、
last_name
(字符串)、
locality
(字符串)、
neighborhood
(字符串)、
phone_number
(字符串)、
postal_code
(字符串)、
record_type
(字符串)、
street_address
(字符串)、
updated_at
(字符串)

Retrieve a user address

获取用户地址详情

Retrieves the details of an existing user address.
GET /user_addresses/{id}
javascript
const userAddress = await client.userAddresses.retrieve('550e8400-e29b-41d4-a716-446655440000');

console.log(userAddress.data);
Returns:
administrative_area
(string),
borough
(string),
business_name
(string),
country_code
(string),
created_at
(string),
customer_reference
(string),
extended_address
(string),
first_name
(string),
id
(uuid),
last_name
(string),
locality
(string),
neighborhood
(string),
phone_number
(string),
postal_code
(string),
record_type
(string),
street_address
(string),
updated_at
(string)
获取已有用户地址的详情。
GET /user_addresses/{id}
javascript
const userAddress = await client.userAddresses.retrieve('550e8400-e29b-41d4-a716-446655440000');

console.log(userAddress.data);
返回字段:
administrative_area
(字符串)、
borough
(字符串)、
business_name
(字符串)、
country_code
(字符串)、
created_at
(字符串)、
customer_reference
(字符串)、
extended_address
(字符串)、
first_name
(字符串)、
id
(UUID)、
last_name
(字符串)、
locality
(字符串)、
neighborhood
(字符串)、
phone_number
(字符串)、
postal_code
(字符串)、
record_type
(字符串)、
street_address
(字符串)、
updated_at
(字符串)

List all Verified Numbers

列出所有已验证号码

Gets a paginated list of Verified Numbers.
GET /verified_numbers
javascript
// Automatically fetches more pages as needed.
for await (const verifiedNumber of client.verifiedNumbers.list()) {
  console.log(verifiedNumber.phone_number);
}
Returns:
phone_number
(string),
record_type
(enum: verified_number),
verified_at
(string)
获取已验证号码的分页列表。
GET /verified_numbers
javascript
// Automatically fetches more pages as needed.
for await (const verifiedNumber of client.verifiedNumbers.list()) {
  console.log(verifiedNumber.phone_number);
}
返回字段:
phone_number
(字符串)、
record_type
(枚举值:verified_number)、
verified_at
(字符串)

Request phone number verification

请求电话号码验证

Initiates phone number verification procedure. Supports DTMF extension dialing for voice calls to numbers behind IVR systems.
POST /verified_numbers
— Required:
phone_number
,
verification_method
Optional:
extension
(string)
javascript
const verifiedNumber = await client.verifiedNumbers.create({
  phone_number: '+15551234567',
  verification_method: 'sms',
});

console.log(verifiedNumber.phone_number);
Returns:
phone_number
(string),
verification_method
(string)
启动电话号码验证流程。支持通过DTMF分机拨号向IVR系统后的号码发起语音呼叫验证。
POST /verified_numbers
— 必填参数:
phone_number
,
verification_method
可选参数:
extension
(字符串)
javascript
const verifiedNumber = await client.verifiedNumbers.create({
  phone_number: '+15551234567',
  verification_method: 'sms',
});

console.log(verifiedNumber.phone_number);
返回字段:
phone_number
(字符串)、
verification_method
(字符串)

Retrieve a verified number

获取已验证号码详情

GET /verified_numbers/{phone_number}
javascript
const verifiedNumberDataWrapper = await client.verifiedNumbers.retrieve('+15551234567');

console.log(verifiedNumberDataWrapper.data);
Returns:
phone_number
(string),
record_type
(enum: verified_number),
verified_at
(string)
GET /verified_numbers/{phone_number}
javascript
const verifiedNumberDataWrapper = await client.verifiedNumbers.retrieve('+15551234567');

console.log(verifiedNumberDataWrapper.data);
返回字段:
phone_number
(字符串)、
record_type
(枚举值:verified_number)、
verified_at
(字符串)

Delete a verified number

删除已验证号码

DELETE /verified_numbers/{phone_number}
javascript
const verifiedNumberDataWrapper = await client.verifiedNumbers.delete('+15551234567');

console.log(verifiedNumberDataWrapper.data);
Returns:
phone_number
(string),
record_type
(enum: verified_number),
verified_at
(string)
DELETE /verified_numbers/{phone_number}
javascript
const verifiedNumberDataWrapper = await client.verifiedNumbers.delete('+15551234567');

console.log(verifiedNumberDataWrapper.data);
返回字段:
phone_number
(字符串)、
record_type
(枚举值:verified_number)、
verified_at
(字符串)

Submit verification code

提交验证码

POST /verified_numbers/{phone_number}/actions/verify
— Required:
verification_code
javascript
const verifiedNumberDataWrapper = await client.verifiedNumbers.actions.submitVerificationCode(
  '+15551234567',
  { verification_code: '123456' },
);

console.log(verifiedNumberDataWrapper.data);
Returns:
phone_number
(string),
record_type
(enum: verified_number),
verified_at
(string)
POST /verified_numbers/{phone_number}/actions/verify
— 必填参数:
verification_code
javascript
const verifiedNumberDataWrapper = await client.verifiedNumbers.actions.submitVerificationCode(
  '+15551234567',
  { verification_code: '123456' },
);

console.log(verifiedNumberDataWrapper.data);
返回字段:
phone_number
(字符串)、
record_type
(枚举值:verified_number)、
verified_at
(字符串)