Send verification code with workflow [Deprecated]

When you have collected a user's phone number, start the verification process by sending a verify request to the Verify API. This example includes use of a specific workflow for the request.

The Verify API returns a request_id. Use this to identify a specific verification request in subsequent calls to the API, such as when making a check request to see if the user provided the correct code.

Replace the following variables in the sample code with your own values:

KeyDescription
VONAGE_API_KEY

Your Vonage API key (see it on your dashboard).

VONAGE_API_SECRET

Your Vonage API secret (also available on your dashboard).

RECIPIENT_NUMBER

The phone number to verify

BRAND_NAME

Included in the message to explain who is confirming the phone number

WORKFLOW_ID

Choose a workflow (number between 1 and 7), these are defined in the workflows guide

Write the code

Add the following to send-verification-code-with-workflow.sh:

curl \

View full source

Run your code

Save this file to your machine and run it:

sh send-verification-code-with-workflow.sh

Prerequisites

Add the following to build.gradle:

implementation 'com.vonage:server-sdk-kotlin:2.1.1'

Create a file named StartVerificationWithWorkflow and add the following code to the main method:

val client = Vonage {
    apiKey(VONAGE_API_KEY)
    apiSecret(VONAGE_API_SECRET)
}

View full source

Write the code

Add the following to the main method of the StartVerificationWithWorkflow file:

val response = client.verifyLegacy.verify(VERIFY_NUMBER, VERIFY_BRAND_NAME) {
    workflow(VERIFY_WORKFLOW_ID)
}
if (response.status == VerifyStatus.OK) {
    println("Verification sent. Request ID: ${response.requestId}")
}
else {
    println("Error: ${response.errorText}")
}

View full source

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 StartVerificationWithWorkflow:

gradle run -Pmain=com.vonage.quickstart.kt.verify.legacy.StartVerificationWithWorkflow

Prerequisites

Add the following to build.gradle:

implementation 'com.vonage:server-sdk:9.3.1'

Create a file named StartVerificationWithWorkflow and add the following code to the main method:

VonageClient client = VonageClient.builder()
        .apiKey(VONAGE_API_KEY)
        .apiSecret(VONAGE_API_SECRET)
        .build();

View full source

Write the code

Add the following to the main method of the StartVerificationWithWorkflow file:

VerifyResponse response = client.getVerifyClient().verify(
        VERIFY_NUMBER, VERIFY_BRAND_NAME, VERIFY_WORKFLOW_ID
);

if (response.getStatus() == VerifyStatus.OK) {
    System.out.printf("RequestID: %s", response.getRequestId());
}
else {
    System.out.printf("ERROR! %s: %s", response.getStatus(), response.getErrorText());
}

View full source

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 StartVerificationWithWorkflow:

gradle run -Pmain=com.vonage.quickstart.verify.StartVerificationWithWorkflow

Prerequisites

Install-Package Vonage

Create a file named SendVerificationRequestWithWorkflow.cs and add the following code:

using Vonage;
using Vonage.Request;
using Vonage.Verify;

View full source

Add the following to SendVerificationRequestWithWorkflow.cs:


var credentials = Credentials.FromApiKeyAndSecret(vonageApiKey, vonageApiSecret);

View full source

Write the code

Add the following to SendVerificationRequestWithWorkflow.cs:


var request = new VerifyRequest() { Brand = brandName, Number = recipientNumber, WorkflowId = VerifyRequest.Workflow.TTS };

View full source

Prerequisites

composer require vonage/client

Create a file named request_with_workflow.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));

View full source

Write the code

Add the following to request_with_workflow.php:

$request = new \Vonage\Verify\Request(NUMBER, BRAND_NAME, (int) WORKFLOW_ID);
$response = $client->verify()->start($request);

echo "Started verification, `request_id` is " . $response->getRequestId();

View full source

Run your code

Save this file to your machine and run it:

php request_with_workflow.php

Prerequisites

pip install vonage python-dotenv

Write the code

Add the following to send-verification-request-with-workflow.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', workflow_id=VERIFY_WORKFLOW_ID
)

response: StartVerificationResponse = client.verify_legacy.start_verification(request)
print(response)

View full source

Run your code

Save this file to your machine and run it:

python verify_legacy/send-verification-request-with-workflow.py

Prerequisites

gem install vonage

Create a file named request_with_workflow.rb and add the following code:

client = Vonage::Client.new(
  api_key: VONAGE_API_KEY,
  api_secret: VONAGE_API_SECRET
)

View full source

Write the code

Add the following to request_with_workflow.rb:

response = client.verify.request(
  number: VERIFY_NUMBER,
  brand: VERIFY_BRAND_NAME
  workflow_id: VERIFY_WORKFLOW_ID
)

View full source

Run your code

Save this file to your machine and run it:

ruby request_with_workflow.rb

Note: If you receive the error code 15: The destination number is not in a supported network, the target network might have been blocked by the platform's anti-fraud system. See Velocity Rules.