Verify API
Verify API を使用すると、特定の番号でユーザーに連絡できることを確認できるため、次のことができます。
- 自分の電話番号が正しいことが保証されるため、いつでもユーザーにリーチできます
- 1 人のユーザーが複数のアカウントを作成できないため、詐欺やスパムから保護されます
- ユーザーが特定のアクティビティを実行するときにユーザーの身元を確認できるように、セキュリティレイヤーを追加できます
仕組み
確認は 2 段階のプロセスで、次の 2 つの API 呼び出しが必要です。
確認リクエスト

ユーザーは、アプリまたは Web サイト経由でサービスに登録し、電話番号を提供します。
ユーザーが登録した番号にアクセスできることを確認するために、アプリケーションは確認リクエストのエンドポイントへの API 呼び出しを行います。
Verify API は、関連付けられた
request_idを使用して PIN コードを生成します。場合によっては、独自の PIN コードも入力できますので、アカウントマネージャーにお問い合わせください。
次に、Verify API は、この PIN のユーザーへの配信を試みます。これらの試行の形式 (SMS またはテキスト読み上げ (TTS)) とタイミングは、選択したワークフローによって定義されます。ユーザーが受け取った PIN を入力するためにアプリまたは Web サイトに再度アクセスしなかった場合、確認リクエストは最終的にタイムアウトになります。それ以外の場合は、[確認] チェックを実行して、入力された番号を確認する必要があります。
確認チェック

5 . ユーザーは PIN を受け取り、アプリケーションに入力します。
6 .アプリケーションは、確認チェックのエンドポイント に API 呼び出しを行い、ユーザーが入力した request_id と PIN を渡します。
7 . Verify API は、入力された PIN が送信された PIN と一致することを確認し、結果をアプリケーションに返します。
最初のステップ
次のサンプルは、ユーザーに確認コードを送信して確認プロセスを開始する方法を示しています。ユーザーが入力したコードを確認したり、その他の操作を実行したりする方法については、コードスニペットを参照してください。
Write the code
Add the following to send-verification-code.sh:
curl GET "https://api.nexmo.com/verify/json?api_key=$VONAGE_API_KEY&api_secret=$VONAGE_API_SECRET&number=$VERIFY_NUMBER&brand=AcmeInc"Run your code
Save this file to your machine and run it:
Prerequisites
Add the following to build.gradle:
implementation 'com.vonage:server-sdk-kotlin:2.1.1'Create a class named StartVerification and add the following code to the main method:
val client = Vonage {
apiKey(VONAGE_API_KEY)
apiSecret(VONAGE_API_SECRET)
}Write the code
Add the following to the main method of the StartVerification class:
val response = client.verifyLegacy.verify(VERIFY_NUMBER, VERIFY_BRAND_NAME)
if (response.status == VerifyStatus.OK) {
println("Verification sent. Request ID: ${response.requestId}")
}
else {
println("Error: ${response.errorText}")
}Run your code
We can use the application plugin for Gradle to simplify the running of our application. Update your build.gradle with the following:
apply plugin: 'application'
mainClassName = project.hasProperty('main') ? project.getProperty('main') : ''Run the following gradle command to execute your application, replacing com.vonage.quickstart.kt.verify.legacy with the package containing StartVerification:
Prerequisites
Add the following to build.gradle:
implementation 'com.vonage:server-sdk:9.3.1'Create a class named StartVerification and add the following code to the main method:
VonageClient client = VonageClient.builder()
.apiKey(VONAGE_API_KEY)
.apiSecret(VONAGE_API_SECRET)
.build();Write the code
Add the following to the main method of the StartVerification class:
VerifyResponse response = client.getVerifyClient().verify(VERIFY_NUMBER, VERIFY_BRAND_NAME);
if (response.getStatus() == VerifyStatus.OK) {
System.out.printf("RequestID: %s", response.getRequestId());
}
else {
System.out.printf("ERROR! %s: %s", response.getStatus(), response.getErrorText());
}Run your code
We can use the application plugin for Gradle to simplify the running of our application. Update your build.gradle with the following:
apply plugin: 'application'
mainClassName = project.hasProperty('main') ? project.getProperty('main') : ''Run the following gradle command to execute your application, replacing com.vonage.quickstart.verify with the package containing StartVerification:
Prerequisites
Install-Package VonageCreate a file named SendVerificationRequest.cs and add the following code:
using System.Threading.Tasks;
using Vonage.Verify;
using Vonage;Add the following to SendVerificationRequest.cs:
var credentials = Credentials.FromApiKeyAndSecret(vonageApiKey, vonageApiSecret);Write the code
Add the following to SendVerificationRequest.cs:
var request = new VerifyRequest() { Brand = brandName, Number = recipientNumber };Prerequisites
composer require vonage/clientCreate a file named request.php and add the following code:
$basic = new \Vonage\Client\Credentials\Basic(VONAGE_API_KEY, VONAGE_API_SECRET);
$client = new \Vonage\Client(new \Vonage\Client\Credentials\Container($basic));Write the code
Add the following to request.php:
$request = new \Vonage\Verify\Request(NUMBER, BRAND_NAME);
// choose PIN length (4 or 6)
$request->setCodeLength(4);
// set locale
$request->setCountry('de');
$response = $client->verify()->start($request);
echo "Started verification, `request_id` is " . $response->getRequestId();Run your code
Save this file to your machine and run it:
Prerequisites
pip install vonage python-dotenvWrite the code
Add the following to request.py:
from vonage import Auth, Vonage
from vonage_verify_legacy import StartVerificationResponse, VerifyRequest
client = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))
request = VerifyRequest(number=VERIFY_NUMBER, brand='AcmeInc')
response: StartVerificationResponse = client.verify_legacy.start_verification(request)
print(response)Run your code
Save this file to your machine and run it:
Prerequisites
gem install vonageCreate a file named request.rb and add the following code:
Run your code
Save this file to your machine and run it:
ガイド
- Verify Migration Guide: This guide will help you migrate from Verify Legacy to Verify.
- Authentication: Authentication with Verify API
- Verify Languages: The available languages for V2 of the Verify API
- Verify API Workflow: Verify API Workflow
- Template Management: How to use template management to send custom OTP messages with the Vonage Verify API
- Verify API Webhooks: A guide to webhooks and how they can be used with the Verify API.
- Silent Authentication: Silent Authentication with the Vonage Verify API
- Verify Anti-Fraud System: Verify's anti-fraud system
- Virtual Operator for Silent Authentication: An introduction to using the Virtual Operator feature within the Vonage Network APIs Playground with the Silent Authentication
- Network Unblock API: Learn what the Vonage Network Unblock API is and how to use it.
コードスニペット
- Cancel a verification request
- Check a verification code
- Create a Template
- Create a Template Fragment
- Delete a Template
- Delete a Template Fragment
- Get a Template
- Get a Template Fragment
- List Template Fragments
- List Templates
- Send verification request (with fallback option)
- Send verification request using Email
- Send verification request using Silent Authentication
- Send verification request using SMS
- Send verification request using Voice (TTS)
- Send verification request using WhatsApp
- Update a Template
- Update a Template Fragment