telnyx-verify-javascript

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

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

Telnyx Verify - JavaScript

Telnyx Verify - 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'], // 这是默认配置,可省略
});
以下所有示例均假设
client
已按上述方式初始化。

Lookup phone number data

查询电话号码数据

Returns information about the provided phone number.
GET /number_lookup/{phone_number}
javascript
const numberLookup = await client.numberLookup.retrieve('+18665552368');

console.log(numberLookup.data);
返回指定电话号码的相关信息。
GET /number_lookup/{phone_number}
javascript
const numberLookup = await client.numberLookup.retrieve('+18665552368');

console.log(numberLookup.data);

Trigger Call verification

触发电话验证

POST /verifications/call
— Required:
phone_number
,
verify_profile_id
javascript
const createVerificationResponse = await client.verifications.triggerCall({
  phone_number: '+13035551234',
  verify_profile_id: '12ade33a-21c0-473b-b055-b3c836e1c292',
});

console.log(createVerificationResponse.data);
POST /verifications/call
— 必填参数:
phone_number
,
verify_profile_id
javascript
const createVerificationResponse = await client.verifications.triggerCall({
  phone_number: '+13035551234',
  verify_profile_id: '12ade33a-21c0-473b-b055-b3c836e1c292',
});

console.log(createVerificationResponse.data);

Trigger Flash call verification

触发闪验电话验证

POST /verifications/flashcall
— Required:
phone_number
,
verify_profile_id
javascript
const createVerificationResponse = await client.verifications.triggerFlashcall({
  phone_number: '+13035551234',
  verify_profile_id: '12ade33a-21c0-473b-b055-b3c836e1c292',
});

console.log(createVerificationResponse.data);
POST /verifications/flashcall
— 必填参数:
phone_number
,
verify_profile_id
javascript
const createVerificationResponse = await client.verifications.triggerFlashcall({
  phone_number: '+13035551234',
  verify_profile_id: '12ade33a-21c0-473b-b055-b3c836e1c292',
});

console.log(createVerificationResponse.data);

Trigger SMS verification

触发短信验证

POST /verifications/sms
— Required:
phone_number
,
verify_profile_id
javascript
const createVerificationResponse = await client.verifications.triggerSMS({
  phone_number: '+13035551234',
  verify_profile_id: '12ade33a-21c0-473b-b055-b3c836e1c292',
});

console.log(createVerificationResponse.data);
POST /verifications/sms
— 必填参数:
phone_number
,
verify_profile_id
javascript
const createVerificationResponse = await client.verifications.triggerSMS({
  phone_number: '+13035551234',
  verify_profile_id: '12ade33a-21c0-473b-b055-b3c836e1c292',
});

console.log(createVerificationResponse.data);

Retrieve verification

获取验证记录

GET /verifications/{verification_id}
javascript
const verification = await client.verifications.retrieve('12ade33a-21c0-473b-b055-b3c836e1c292');

console.log(verification.data);
GET /verifications/{verification_id}
javascript
const verification = await client.verifications.retrieve('12ade33a-21c0-473b-b055-b3c836e1c292');

console.log(verification.data);

Verify verification code by ID

通过ID验证验证码

POST /verifications/{verification_id}/actions/verify
javascript
const verifyVerificationCodeResponse = await client.verifications.actions.verify(
  '12ade33a-21c0-473b-b055-b3c836e1c292',
);

console.log(verifyVerificationCodeResponse.data);
POST /verifications/{verification_id}/actions/verify
javascript
const verifyVerificationCodeResponse = await client.verifications.actions.verify(
  '12ade33a-21c0-473b-b055-b3c836e1c292',
);

console.log(verifyVerificationCodeResponse.data);

List verifications by phone number

按电话号码列出验证记录

GET /verifications/by_phone_number/{phone_number}
javascript
const byPhoneNumbers = await client.verifications.byPhoneNumber.list('+13035551234');

console.log(byPhoneNumbers.data);
GET /verifications/by_phone_number/{phone_number}
javascript
const byPhoneNumbers = await client.verifications.byPhoneNumber.list('+13035551234');

console.log(byPhoneNumbers.data);

Verify verification code by phone number

按电话号码验证验证码

POST /verifications/by_phone_number/{phone_number}/actions/verify
— Required:
code
,
verify_profile_id
javascript
const verifyVerificationCodeResponse = await client.verifications.byPhoneNumber.actions.verify(
  '+13035551234',
  { code: '17686', verify_profile_id: '12ade33a-21c0-473b-b055-b3c836e1c292' },
);

console.log(verifyVerificationCodeResponse.data);
POST /verifications/by_phone_number/{phone_number}/actions/verify
— 必填参数:
code
,
verify_profile_id
javascript
const verifyVerificationCodeResponse = await client.verifications.byPhoneNumber.actions.verify(
  '+13035551234',
  { code: '17686', verify_profile_id: '12ade33a-21c0-473b-b055-b3c836e1c292' },
);

console.log(verifyVerificationCodeResponse.data);

List all Verify profiles

列出所有验证配置文件

Gets a paginated list of Verify profiles.
GET /verify_profiles
javascript
// Automatically fetches more pages as needed.
for await (const verifyProfile of client.verifyProfiles.list()) {
  console.log(verifyProfile.id);
}
获取验证配置文件的分页列表。
GET /verify_profiles
javascript
// 自动按需获取更多页面。
for await (const verifyProfile of client.verifyProfiles.list()) {
  console.log(verifyProfile.id);
}

Create a Verify profile

创建验证配置文件

Creates a new Verify profile to associate verifications with.
POST /verify_profiles
— Required:
name
javascript
const verifyProfileData = await client.verifyProfiles.create({ name: 'Test Profile' });

console.log(verifyProfileData.data);
创建新的验证配置文件,用于关联验证记录。
POST /verify_profiles
— 必填参数:
name
javascript
const verifyProfileData = await client.verifyProfiles.create({ name: 'Test Profile' });

console.log(verifyProfileData.data);

Retrieve Verify profile

获取验证配置文件

Gets a single Verify profile.
GET /verify_profiles/{verify_profile_id}
javascript
const verifyProfileData = await client.verifyProfiles.retrieve(
  '12ade33a-21c0-473b-b055-b3c836e1c292',
);

console.log(verifyProfileData.data);
获取单个验证配置文件信息。
GET /verify_profiles/{verify_profile_id}
javascript
const verifyProfileData = await client.verifyProfiles.retrieve(
  '12ade33a-21c0-473b-b055-b3c836e1c292',
);

console.log(verifyProfileData.data);

Update Verify profile

更新验证配置文件

PATCH /verify_profiles/{verify_profile_id}
javascript
const verifyProfileData = await client.verifyProfiles.update(
  '12ade33a-21c0-473b-b055-b3c836e1c292',
);

console.log(verifyProfileData.data);
PATCH /verify_profiles/{verify_profile_id}
javascript
const verifyProfileData = await client.verifyProfiles.update(
  '12ade33a-21c0-473b-b055-b3c836e1c292',
);

console.log(verifyProfileData.data);

Delete Verify profile

删除验证配置文件

DELETE /verify_profiles/{verify_profile_id}
javascript
const verifyProfileData = await client.verifyProfiles.delete(
  '12ade33a-21c0-473b-b055-b3c836e1c292',
);

console.log(verifyProfileData.data);
DELETE /verify_profiles/{verify_profile_id}
javascript
const verifyProfileData = await client.verifyProfiles.delete(
  '12ade33a-21c0-473b-b055-b3c836e1c292',
);

console.log(verifyProfileData.data);

Retrieve Verify profile message templates

获取验证配置文件消息模板

List all Verify profile message templates.
GET /verify_profiles/templates
javascript
const response = await client.verifyProfiles.retrieveTemplates();

console.log(response.data);
列出所有验证配置文件的消息模板。
GET /verify_profiles/templates
javascript
const response = await client.verifyProfiles.retrieveTemplates();

console.log(response.data);

Create message template

创建消息模板

Create a new Verify profile message template.
POST /verify_profiles/templates
— Required:
text
javascript
const messageTemplate = await client.verifyProfiles.createTemplate({
  text: 'Your {{app_name}} verification code is: {{code}}.',
});

console.log(messageTemplate.data);
创建新的验证配置文件消息模板。
POST /verify_profiles/templates
— 必填参数:
text
javascript
const messageTemplate = await client.verifyProfiles.createTemplate({
  text: 'Your {{app_name}} verification code is: {{code}}.',
});

console.log(messageTemplate.data);

Update message template

更新消息模板

Update an existing Verify profile message template.
PATCH /verify_profiles/templates/{template_id}
— Required:
text
javascript
const messageTemplate = await client.verifyProfiles.updateTemplate(
  '12ade33a-21c0-473b-b055-b3c836e1c292',
  { text: 'Your {{app_name}} verification code is: {{code}}.' },
);

console.log(messageTemplate.data);
更新现有的验证配置文件消息模板。
PATCH /verify_profiles/templates/{template_id}
— 必填参数:
text
javascript
const messageTemplate = await client.verifyProfiles.updateTemplate(
  '12ade33a-21c0-473b-b055-b3c836e1c292',
  { text: 'Your {{app_name}} verification code is: {{code}}.' },
);

console.log(messageTemplate.data);