telnyx-account-access-javascript

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
<!-- Auto-generated from Telnyx OpenAPI specs. Do not edit. -->
<!-- 自动生成自Telnyx OpenAPI规范,请勿编辑。 -->

Telnyx Account Access - 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

重要说明

  • Pagination: List methods return an auto-paginating iterator. Use
    for await (const item of result) { ... }
    to iterate through all pages automatically.
  • 分页: 列表类方法返回一个支持自动分页的迭代器,使用
    for await (const item of result) { ... }
    即可自动遍历所有分页内容。

List all Access IP Addresses

查询所有访问IP地址

GET /access_ip_address
javascript
// Automatically fetches more pages as needed.
for await (const accessIPAddressResponse of client.accessIPAddress.list()) {
  console.log(accessIPAddressResponse.id);
}
Returns:
created_at
(date-time),
description
(string),
id
(string),
ip_address
(string),
source
(string),
status
(enum: pending, added),
updated_at
(date-time),
user_id
(string)
GET /access_ip_address
javascript
// Automatically fetches more pages as needed.
for await (const accessIPAddressResponse of client.accessIPAddress.list()) {
  console.log(accessIPAddressResponse.id);
}
返回参数:
created_at
(日期时间)、
description
(字符串)、
id
(字符串)、
ip_address
(字符串)、
source
(字符串)、
status
(枚举值:pending 待处理、added 已添加)、
updated_at
(日期时间)、
user_id
(字符串)

Create new Access IP Address

新建访问IP地址

POST /access_ip_address
— Required:
ip_address
Optional:
description
(string)
javascript
const accessIPAddressResponse = await client.accessIPAddress.create({ ip_address: 'ip_address' });

console.log(accessIPAddressResponse.id);
Returns:
created_at
(date-time),
description
(string),
id
(string),
ip_address
(string),
source
(string),
status
(enum: pending, added),
updated_at
(date-time),
user_id
(string)
POST /access_ip_address
— 必填参数:
ip_address
可选参数:
description
(字符串)
javascript
const accessIPAddressResponse = await client.accessIPAddress.create({ ip_address: 'ip_address' });

console.log(accessIPAddressResponse.id);
返回参数:
created_at
(日期时间)、
description
(字符串)、
id
(字符串)、
ip_address
(字符串)、
source
(字符串)、
status
(枚举值:pending 待处理、added 已添加)、
updated_at
(日期时间)、
user_id
(字符串)

Retrieve an access IP address

查询单个访问IP地址

GET /access_ip_address/{access_ip_address_id}
javascript
const accessIPAddressResponse = await client.accessIPAddress.retrieve('access_ip_address_id');

console.log(accessIPAddressResponse.id);
Returns:
created_at
(date-time),
description
(string),
id
(string),
ip_address
(string),
source
(string),
status
(enum: pending, added),
updated_at
(date-time),
user_id
(string)
GET /access_ip_address/{access_ip_address_id}
javascript
const accessIPAddressResponse = await client.accessIPAddress.retrieve('access_ip_address_id');

console.log(accessIPAddressResponse.id);
返回参数:
created_at
(日期时间)、
description
(字符串)、
id
(字符串)、
ip_address
(字符串)、
source
(字符串)、
status
(枚举值:pending 待处理、added 已添加)、
updated_at
(日期时间)、
user_id
(字符串)

Delete access IP address

删除访问IP地址

DELETE /access_ip_address/{access_ip_address_id}
javascript
const accessIPAddressResponse = await client.accessIPAddress.delete('access_ip_address_id');

console.log(accessIPAddressResponse.id);
Returns:
created_at
(date-time),
description
(string),
id
(string),
ip_address
(string),
source
(string),
status
(enum: pending, added),
updated_at
(date-time),
user_id
(string)
DELETE /access_ip_address/{access_ip_address_id}
javascript
const accessIPAddressResponse = await client.accessIPAddress.delete('access_ip_address_id');

console.log(accessIPAddressResponse.id);
返回参数:
created_at
(日期时间)、
description
(字符串)、
id
(字符串)、
ip_address
(字符串)、
source
(字符串)、
status
(枚举值:pending 待处理、added 已添加)、
updated_at
(日期时间)、
user_id
(字符串)

List all addresses

查询所有地址

Returns a list of your addresses.
GET /addresses
javascript
// Automatically fetches more pages as needed.
for await (const address of client.addresses.list()) {
  console.log(address.id);
}
Returns:
address_book
(boolean),
administrative_area
(string),
borough
(string),
business_name
(string),
country_code
(string),
created_at
(string),
customer_reference
(string),
extended_address
(string),
first_name
(string),
id
(string),
last_name
(string),
locality
(string),
neighborhood
(string),
phone_number
(string),
postal_code
(string),
record_type
(string),
street_address
(string),
updated_at
(string),
validate_address
(boolean)
返回你名下的所有地址列表。
GET /addresses
javascript
// Automatically fetches more pages as needed.
for await (const address of client.addresses.list()) {
  console.log(address.id);
}
返回参数:
address_book
(布尔值)、
administrative_area
(字符串)、
borough
(字符串)、
business_name
(字符串)、
country_code
(字符串)、
created_at
(字符串)、
customer_reference
(字符串)、
extended_address
(字符串)、
first_name
(字符串)、
id
(字符串)、
last_name
(字符串)、
locality
(字符串)、
neighborhood
(字符串)、
phone_number
(字符串)、
postal_code
(字符串)、
record_type
(字符串)、
street_address
(字符串)、
updated_at
(字符串)、
validate_address
(布尔值)

Creates an address

新建地址

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

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

console.log(address.data);
返回参数:
address_book
(布尔值)、
administrative_area
(字符串)、
borough
(字符串)、
business_name
(字符串)、
country_code
(字符串)、
created_at
(字符串)、
customer_reference
(字符串)、
extended_address
(字符串)、
first_name
(字符串)、
id
(字符串)、
last_name
(字符串)、
locality
(字符串)、
neighborhood
(字符串)、
phone_number
(字符串)、
postal_code
(字符串)、
record_type
(字符串)、
street_address
(字符串)、
updated_at
(字符串)、
validate_address
(布尔值)

Validate an address

校验地址

Validates an address for emergency services.
POST /addresses/actions/validate
— Required:
country_code
,
street_address
,
postal_code
Optional:
administrative_area
(string),
extended_address
(string),
locality
(string)
javascript
const response = await client.addresses.actions.validate({
  country_code: 'US',
  postal_code: '78701',
  street_address: '600 Congress Avenue',
});

console.log(response.data);
Returns:
errors
(array[object]),
record_type
(string),
result
(enum: valid, invalid),
suggested
(object)
校验地址是否符合应急服务使用要求。
POST /addresses/actions/validate
— 必填参数:
country_code
street_address
postal_code
可选参数:
administrative_area
(字符串)、
extended_address
(字符串)、
locality
(字符串)
javascript
const response = await client.addresses.actions.validate({
  country_code: 'US',
  postal_code: '78701',
  street_address: '600 Congress Avenue',
});

console.log(response.data);
返回参数:
errors
(对象数组)、
record_type
(字符串)、
result
(枚举值:valid 有效、invalid 无效)、
suggested
(对象)

Retrieve an address

查询单个地址

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

console.log(address.data);
Returns:
address_book
(boolean),
administrative_area
(string),
borough
(string),
business_name
(string),
country_code
(string),
created_at
(string),
customer_reference
(string),
extended_address
(string),
first_name
(string),
id
(string),
last_name
(string),
locality
(string),
neighborhood
(string),
phone_number
(string),
postal_code
(string),
record_type
(string),
street_address
(string),
updated_at
(string),
validate_address
(boolean)
获取现有地址的详细信息。
GET /addresses/{id}
javascript
const address = await client.addresses.retrieve('550e8400-e29b-41d4-a716-446655440000');

console.log(address.data);
返回参数:
address_book
(布尔值)、
administrative_area
(字符串)、
borough
(字符串)、
business_name
(字符串)、
country_code
(字符串)、
created_at
(字符串)、
customer_reference
(字符串)、
extended_address
(字符串)、
first_name
(字符串)、
id
(字符串)、
last_name
(字符串)、
locality
(字符串)、
neighborhood
(字符串)、
phone_number
(字符串)、
postal_code
(字符串)、
record_type
(字符串)、
street_address
(字符串)、
updated_at
(字符串)、
validate_address
(布尔值)

Deletes an address

删除地址

Deletes an existing address.
DELETE /addresses/{id}
javascript
const address = await client.addresses.delete('550e8400-e29b-41d4-a716-446655440000');

console.log(address.data);
Returns:
address_book
(boolean),
administrative_area
(string),
borough
(string),
business_name
(string),
country_code
(string),
created_at
(string),
customer_reference
(string),
extended_address
(string),
first_name
(string),
id
(string),
last_name
(string),
locality
(string),
neighborhood
(string),
phone_number
(string),
postal_code
(string),
record_type
(string),
street_address
(string),
updated_at
(string),
validate_address
(boolean)
删除现有地址。
DELETE /addresses/{id}
javascript
const address = await client.addresses.delete('550e8400-e29b-41d4-a716-446655440000');

console.log(address.data);
返回参数:
address_book
(布尔值)、
administrative_area
(字符串)、
borough
(字符串)、
business_name
(字符串)、
country_code
(字符串)、
created_at
(字符串)、
customer_reference
(字符串)、
extended_address
(字符串)、
first_name
(字符串)、
id
(字符串)、
last_name
(字符串)、
locality
(字符串)、
neighborhood
(字符串)、
phone_number
(字符串)、
postal_code
(字符串)、
record_type
(字符串)、
street_address
(字符串)、
updated_at
(字符串)、
validate_address
(布尔值)

Accepts this address suggestion as a new emergency address for Operator Connect and finishes the uploads of the numbers associated with it to Microsoft.

采纳地址建议并同步到微软Operator Connect

POST /addresses/{id}/actions/accept_suggestions
Optional:
id
(string)
javascript
const response = await client.addresses.actions.acceptSuggestions(
  '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
);

console.log(response.data);
Returns:
accepted
(boolean),
id
(uuid),
record_type
(enum: address_suggestion)
采纳该地址建议作为新的应急地址,完成关联号码到微软平台的上传流程。
POST /addresses/{id}/actions/accept_suggestions
可选参数:
id
(字符串)
javascript
const response = await client.addresses.actions.acceptSuggestions(
  '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
);

console.log(response.data);
返回参数:
accepted
(布尔值)、
id
(uuid)、
record_type
(枚举值:address_suggestion 地址建议)

List all SSO authentication providers

查询所有SSO身份认证提供商

Returns a list of your SSO authentication providers.
GET /authentication_providers
javascript
// Automatically fetches more pages as needed.
for await (const authenticationProvider of client.authenticationProviders.list()) {
  console.log(authenticationProvider.id);
}
Returns:
activated_at
(date-time),
active
(boolean),
created_at
(date-time),
id
(uuid),
name
(string),
organization_id
(uuid),
record_type
(string),
settings
(object),
short_name
(string),
updated_at
(date-time)
返回你名下的所有SSO身份认证提供商列表。
GET /authentication_providers
javascript
// Automatically fetches more pages as needed.
for await (const authenticationProvider of client.authenticationProviders.list()) {
  console.log(authenticationProvider.id);
}
返回参数:
activated_at
(日期时间)、
active
(布尔值)、
created_at
(日期时间)、
id
(uuid)、
name
(字符串)、
organization_id
(uuid)、
record_type
(字符串)、
settings
(对象)、
short_name
(字符串)、
updated_at
(日期时间)

Creates an authentication provider

新建身份认证提供商

Creates an authentication provider.
POST /authentication_providers
— Required:
name
,
short_name
,
settings
Optional:
active
(boolean),
settings_url
(uri)
javascript
const authenticationProvider = await client.authenticationProviders.create({
  name: 'Okta',
  settings: {
    idp_cert_fingerprint: '13:38:C7:BB:C9:FF:4A:70:38:3A:E3:D9:5C:CD:DB:2E:50:1E:80:A7',
    idp_entity_id: 'https://myorg.myidp.com/saml/metadata',
    idp_sso_target_url: 'https://myorg.myidp.com/trust/saml2/http-post/sso',
  },
  short_name: 'myorg',
});

console.log(authenticationProvider.data);
Returns:
activated_at
(date-time),
active
(boolean),
created_at
(date-time),
id
(uuid),
name
(string),
organization_id
(uuid),
record_type
(string),
settings
(object),
short_name
(string),
updated_at
(date-time)
创建一个新的身份认证提供商。
POST /authentication_providers
— 必填参数:
name
short_name
settings
可选参数:
active
(布尔值)、
settings_url
(uri)
javascript
const authenticationProvider = await client.authenticationProviders.create({
  name: 'Okta',
  settings: {
    idp_cert_fingerprint: '13:38:C7:BB:C9:FF:4A:70:38:3A:E3:D9:5C:CD:DB:2E:50:1E:80:A7',
    idp_entity_id: 'https://myorg.myidp.com/saml/metadata',
    idp_sso_target_url: 'https://myorg.myidp.com/trust/saml2/http-post/sso',
  },
  short_name: 'myorg',
});

console.log(authenticationProvider.data);
返回参数:
activated_at
(日期时间)、
active
(布尔值)、
created_at
(日期时间)、
id
(uuid)、
name
(字符串)、
organization_id
(uuid)、
record_type
(字符串)、
settings
(对象)、
short_name
(字符串)、
updated_at
(日期时间)

Retrieve an authentication provider

查询单个身份认证提供商

Retrieves the details of an existing authentication provider.
GET /authentication_providers/{id}
javascript
const authenticationProvider = await client.authenticationProviders.retrieve('550e8400-e29b-41d4-a716-446655440000');

console.log(authenticationProvider.data);
Returns:
activated_at
(date-time),
active
(boolean),
created_at
(date-time),
id
(uuid),
name
(string),
organization_id
(uuid),
record_type
(string),
settings
(object),
short_name
(string),
updated_at
(date-time)
获取现有身份认证提供商的详细信息。
GET /authentication_providers/{id}
javascript
const authenticationProvider = await client.authenticationProviders.retrieve('550e8400-e29b-41d4-a716-446655440000');

console.log(authenticationProvider.data);
返回参数:
activated_at
(日期时间)、
active
(布尔值)、
created_at
(日期时间)、
id
(uuid)、
name
(字符串)、
organization_id
(uuid)、
record_type
(字符串)、
settings
(对象)、
short_name
(字符串)、
updated_at
(日期时间)

Update an authentication provider

更新身份认证提供商

Updates settings of an existing authentication provider.
PATCH /authentication_providers/{id}
Optional:
active
(boolean),
name
(string),
settings
(object),
settings_url
(uri),
short_name
(string)
javascript
const authenticationProvider = await client.authenticationProviders.update('id', {
  active: true,
  name: 'Okta',
  settings: {
    idp_entity_id: 'https://myorg.myidp.com/saml/metadata',
    idp_sso_target_url: 'https://myorg.myidp.com/trust/saml2/http-post/sso',
    idp_cert_fingerprint: '13:38:C7:BB:C9:FF:4A:70:38:3A:E3:D9:5C:CD:DB:2E:50:1E:80:A7',
    idp_cert_fingerprint_algorithm: 'sha1',
  },
  short_name: 'myorg',
});

console.log(authenticationProvider.data);
Returns:
activated_at
(date-time),
active
(boolean),
created_at
(date-time),
id
(uuid),
name
(string),
organization_id
(uuid),
record_type
(string),
settings
(object),
short_name
(string),
updated_at
(date-time)
更新现有身份认证提供商的配置。
PATCH /authentication_providers/{id}
可选参数:
active
(布尔值)、
name
(字符串)、
settings
(对象)、
settings_url
(uri)、
short_name
(字符串)
javascript
const authenticationProvider = await client.authenticationProviders.update('id', {
  active: true,
  name: 'Okta',
  settings: {
    idp_entity_id: 'https://myorg.myidp.com/saml/metadata',
    idp_sso_target_url: 'https://myorg.myidp.com/trust/saml2/http-post/sso',
    idp_cert_fingerprint: '13:38:C7:BB:C9:FF:4A:70:38:3A:E3:D9:5C:CD:DB:2E:50:1E:80:A7',
    idp_cert_fingerprint_algorithm: 'sha1',
  },
  short_name: 'myorg',
});

console.log(authenticationProvider.data);
返回参数:
activated_at
(日期时间)、
active
(布尔值)、
created_at
(日期时间)、
id
(uuid)、
name
(字符串)、
organization_id
(uuid)、
record_type
(字符串)、
settings
(对象)、
short_name
(字符串)、
updated_at
(日期时间)

Deletes an authentication provider

删除身份认证提供商

Deletes an existing authentication provider.
DELETE /authentication_providers/{id}
javascript
const authenticationProvider = await client.authenticationProviders.delete('550e8400-e29b-41d4-a716-446655440000');

console.log(authenticationProvider.data);
Returns:
activated_at
(date-time),
active
(boolean),
created_at
(date-time),
id
(uuid),
name
(string),
organization_id
(uuid),
record_type
(string),
settings
(object),
short_name
(string),
updated_at
(date-time)
删除现有身份认证提供商。
DELETE /authentication_providers/{id}
javascript
const authenticationProvider = await client.authenticationProviders.delete('550e8400-e29b-41d4-a716-446655440000');

console.log(authenticationProvider.data);
返回参数:
activated_at
(日期时间)、
active
(布尔值)、
created_at
(日期时间)、
id
(uuid)、
name
(字符串)、
organization_id
(uuid)、
record_type
(字符串)、
settings
(对象)、
short_name
(字符串)、
updated_at
(日期时间)

List all billing groups

查询所有账单组

GET /billing_groups
javascript
// Automatically fetches more pages as needed.
for await (const billingGroup of client.billingGroups.list()) {
  console.log(billingGroup.id);
}
Returns:
created_at
(date-time),
deleted_at
(date-time),
id
(uuid),
name
(string),
organization_id
(uuid),
record_type
(enum: billing_group),
updated_at
(date-time)
GET /billing_groups
javascript
// Automatically fetches more pages as needed.
for await (const billingGroup of client.billingGroups.list()) {
  console.log(billingGroup.id);
}
返回参数:
created_at
(日期时间)、
deleted_at
(日期时间)、
id
(uuid)、
name
(字符串)、
organization_id
(uuid)、
record_type
(枚举值:billing_group 账单组)、
updated_at
(日期时间)

Create a billing group

新建账单组

POST /billing_groups
Optional:
name
(string)
javascript
const billingGroup = await client.billingGroups.create({ name: 'my-resource' });

console.log(billingGroup.data);
Returns:
created_at
(date-time),
deleted_at
(date-time),
id
(uuid),
name
(string),
organization_id
(uuid),
record_type
(enum: billing_group),
updated_at
(date-time)
POST /billing_groups
可选参数:
name
(字符串)
javascript
const billingGroup = await client.billingGroups.create({ name: 'my-resource' });

console.log(billingGroup.data);
返回参数:
created_at
(日期时间)、
deleted_at
(日期时间)、
id
(uuid)、
name
(字符串)、
organization_id
(uuid)、
record_type
(枚举值:billing_group 账单组)、
updated_at
(日期时间)

Get a billing group

查询单个账单组

GET /billing_groups/{id}
javascript
const billingGroup = await client.billingGroups.retrieve('f5586561-8ff0-4291-a0ac-84fe544797bd');

console.log(billingGroup.data);
Returns:
created_at
(date-time),
deleted_at
(date-time),
id
(uuid),
name
(string),
organization_id
(uuid),
record_type
(enum: billing_group),
updated_at
(date-time)
GET /billing_groups/{id}
javascript
const billingGroup = await client.billingGroups.retrieve('f5586561-8ff0-4291-a0ac-84fe544797bd');

console.log(billingGroup.data);
返回参数:
created_at
(日期时间)、
deleted_at
(日期时间)、
id
(uuid)、
name
(字符串)、
organization_id
(uuid)、
record_type
(枚举值:billing_group 账单组)、
updated_at
(日期时间)

Update a billing group

更新账单组

PATCH /billing_groups/{id}
Optional:
name
(string)
javascript
const billingGroup = await client.billingGroups.update('f5586561-8ff0-4291-a0ac-84fe544797bd', {
  name: 'my-resource',
});

console.log(billingGroup.data);
Returns:
created_at
(date-time),
deleted_at
(date-time),
id
(uuid),
name
(string),
organization_id
(uuid),
record_type
(enum: billing_group),
updated_at
(date-time)
PATCH /billing_groups/{id}
可选参数:
name
(字符串)
javascript
const billingGroup = await client.billingGroups.update('f5586561-8ff0-4291-a0ac-84fe544797bd', {
  name: 'my-resource',
});

console.log(billingGroup.data);
返回参数:
created_at
(日期时间)、
deleted_at
(日期时间)、
id
(uuid)、
name
(字符串)、
organization_id
(uuid)、
record_type
(枚举值:billing_group 账单组)、
updated_at
(日期时间)

Delete a billing group

删除账单组

DELETE /billing_groups/{id}
javascript
const billingGroup = await client.billingGroups.delete('f5586561-8ff0-4291-a0ac-84fe544797bd');

console.log(billingGroup.data);
Returns:
created_at
(date-time),
deleted_at
(date-time),
id
(uuid),
name
(string),
organization_id
(uuid),
record_type
(enum: billing_group),
updated_at
(date-time)
DELETE /billing_groups/{id}
javascript
const billingGroup = await client.billingGroups.delete('f5586561-8ff0-4291-a0ac-84fe544797bd');

console.log(billingGroup.data);
返回参数:
created_at
(日期时间)、
deleted_at
(日期时间)、
id
(uuid)、
name
(字符串)、
organization_id
(uuid)、
record_type
(枚举值:billing_group 账单组)、
updated_at
(日期时间)

List integration secrets

查询所有集成密钥

Retrieve a list of all integration secrets configured by the user.
GET /integration_secrets
javascript
// Automatically fetches more pages as needed.
for await (const integrationSecret of client.integrationSecrets.list()) {
  console.log(integrationSecret.id);
}
Returns:
created_at
(date-time),
id
(string),
identifier
(string),
record_type
(string),
updated_at
(date-time)
获取用户配置的所有集成密钥列表。
GET /integration_secrets
javascript
// Automatically fetches more pages as needed.
for await (const integrationSecret of client.integrationSecrets.list()) {
  console.log(integrationSecret.id);
}
返回参数:
created_at
(日期时间)、
id
(字符串)、
identifier
(字符串)、
record_type
(字符串)、
updated_at
(日期时间)

Create a secret

新建集成密钥

Create a new secret with an associated identifier that can be used to securely integrate with other services.
POST /integration_secrets
— Required:
identifier
,
type
Optional:
password
(string),
token
(string),
username
(string)
javascript
const integrationSecret = await client.integrationSecrets.create({
  identifier: 'my_secret',
  type: 'bearer',
  token: 'my_secret_value',
});

console.log(integrationSecret.data);
Returns:
created_at
(date-time),
id
(string),
identifier
(string),
record_type
(string),
updated_at
(date-time)
创建一个新的集成密钥,关联的标识符可用于安全对接其他服务。
POST /integration_secrets
— 必填参数:
identifier
type
可选参数:
password
(字符串)、
token
(字符串)、
username
(字符串)
javascript
const integrationSecret = await client.integrationSecrets.create({
  identifier: 'my_secret',
  type: 'bearer',
  token: 'my_secret_value',
});

console.log(integrationSecret.data);
返回参数:
created_at
(日期时间)、
id
(字符串)、
identifier
(字符串)、
record_type
(字符串)、
updated_at
(日期时间)

Delete an integration secret

删除集成密钥

Delete an integration secret given its ID.
DELETE /integration_secrets/{id}
javascript
await client.integrationSecrets.delete('550e8400-e29b-41d4-a716-446655440000');
根据ID删除指定的集成密钥。
DELETE /integration_secrets/{id}
javascript
await client.integrationSecrets.delete('550e8400-e29b-41d4-a716-446655440000');

Create an Access Token.

生成访问令牌

Create an Access Token (JWT) for the credential.
POST /telephony_credentials/{id}/token
javascript
const response = await client.telephonyCredentials.createToken('550e8400-e29b-41d4-a716-446655440000');

console.log(response);
为凭证生成访问令牌(JWT)。
POST /telephony_credentials/{id}/token
javascript
const response = await client.telephonyCredentials.createToken('550e8400-e29b-41d4-a716-446655440000');

console.log(response);