Nexmo Verify API

The Verify API helps you to implement 2FA (two-factor authentication) in your applications. This is useful for:

  • Protecting against spam, by preventing spammers from creating multiple accounts
  • Monitoring suspicious activity, by forcing an account user to verify ownership of a number
  • Ensuring that you can reach your users at any time because you have their correct phone number

Verify Request

Generate and send a PIN to your user. You use the `request_id` in the response for the Verify check.

Verify request

To use Verify request you:

  1. Create a request to send a verification code to your user.
  2. Check the status field in the response to ensure that your request was successful.

GET https://api.nexmo.com/verify/:format

Path Parameters

Key Description Example Default
format
Required | string

The response format.


Must be one of: json or xml
json None

Query Parameter

Key Description Example Default
api_key
apiKey

You can find your API key in your Nexmo account developer dashboard

abc123 None
api_secret
apiKey

You can find your API secret in your Nexmo account developer dashboard

abc123 None
number
Required | string

The mobile or landline phone number to verify. Unless you are setting country explicitly, this number must be in E.164 format.

447700900000 None
country
string

If you do not provide number in international format or you are not sure if number is correctly formatted, specify the two-character country code in country. Verify will then format the number for you.

GB None
brand
Required | string

An 18-character alphanumeric string you can use to personalize the verification request SMS body, to help users identify your company or application name. For example: "Your Acme Inc PIN is ..."

Acme Inc None
sender_id
string

An 11-character alphanumeric string that represents the identify the sender of the verification request. Depending on the destination of the phone number you are sending the verification SMS to, restrictions might apply.

VERIFY VERIFY
code_length
integer

The length of the verification code.


Must be one of: 4 or 6
4 4
lg
string

By default, the SMS or text-to-speech (TTS) message is generated in the locale that matches the number. For example, the text message or TTS message for a 33* number is sent in French. Use this parameter to explicitly control the language, accent and gender used for the Verify request.


Must be one of: de-de, en-au, en-gb, en-us, en-in, es-es, es-mx, es-us, fr-ca, fr-fr, is-is, it-it, ja-jp, ko-kr, nl-nl, pl-pl, pt-pt, pt-br, ro-ro, ru-ru, sv-se, tr-tr, zh-cn or zh-tw
en-us en-us
require_type
string

Restrict verification to a certain network type. You must contact support@nexmo.com to enable this feature.


Must be one of: All, Mobile or Landline
Mobile All
pin_expiry
integer

How log the generated verification code is valid for, in seconds. When you specify both pin_expiry and next_event_wait then pin_expiry must be an integer multiple of next_event_wait. Otherwise, pin_expiry is set to equal next_event_wait. See changing the default event timings.

300 300
next_event_wait
integer

Specifies the wait time in seconds between attempts to deliver the verification code. Verify calculates the default value based on the average time taken by users to complete verification.

300 None

View response field descriptions

Response Fields

Field Description
request_id

The unique ID of the Verify request. You need this request_id for the Verify check.

status
Code Text Description
0 Success The request was successfully accepted by Nexmo.
1 Throttled You are trying to send more than the maximum of 30 requests per second.
2 Your request is incomplete and missing the mandatory parameter $parameter The stated parameter is missing.
3 Invalid value for parameter $parameter Invalid value for parameter. If you see Facility not allowed in the error text, check that you are using the correct Base URL in your request.
4 Invalid credentials were provided The supplied API key or secret in the request is either invalid or disabled.
5 Internal Error An error occurred processing this request in the Cloud Communications Platform.
6 The Nexmo platform was unable to process this message for the following reason: $reason The request could not be routed.
7 The number you are trying to verify is blacklisted for verification.
8 The api_key you supplied is for an account that has been barred from submitting messages.
9 Partner quota exceeded Your account does not have sufficient credit to process this request.
10 Concurrent verifications to the same number are not allowed
15 The destination number is not in a supported network The request has been rejected. Find out more about this error in the Knowledge Base
16 The code inserted does not match the expected value
17 The wrong code was provided too many times You can run Verify check on a specific request_id up to three times unless a new verification code is generated. If you check a request more than three times, it is set to FAILED and you cannot check it again.
18 Too many request_ids provided You added more than the maximum ten request_ids to your request.
19 No more events are left to execute for this request
101 No request found There are no matching verify requests.
One of: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 16, 17, 18, 19 or 101
error_text

If status is non-zero, this explains the error encountered.

Field Description
request_id

The unique ID of the Verify request. You need this request_id for the Verify check.

status
Code Text Description
0 Success The request was successfully accepted by Nexmo.
1 Throttled You are trying to send more than the maximum of 30 requests per second.
2 Your request is incomplete and missing the mandatory parameter $parameter The stated parameter is missing.
3 Invalid value for parameter $parameter Invalid value for parameter. If you see Facility not allowed in the error text, check that you are using the correct Base URL in your request.
4 Invalid credentials were provided The supplied API key or secret in the request is either invalid or disabled.
5 Internal Error An error occurred processing this request in the Cloud Communications Platform.
6 The Nexmo platform was unable to process this message for the following reason: $reason The request could not be routed.
7 The number you are trying to verify is blacklisted for verification.
8 The api_key you supplied is for an account that has been barred from submitting messages.
9 Partner quota exceeded Your account does not have sufficient credit to process this request.
10 Concurrent verifications to the same number are not allowed
15 The destination number is not in a supported network The request has been rejected. Find out more about this error in the Knowledge Base
16 The code inserted does not match the expected value
17 The wrong code was provided too many times You can run Verify check on a specific request_id up to three times unless a new verification code is generated. If you check a request more than three times, it is set to FAILED and you cannot check it again.
18 Too many request_ids provided You added more than the maximum ten request_ids to your request.
19 No more events are left to execute for this request
101 No request found There are no matching verify requests.
One of: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 16, 17, 18, 19 or 101
error_text

If status is non-zero, this explains the error encountered.

{
  "request_id": "aaaaaaaa-bbbb-...",
  "status": "0",
  "error_text": "error"
}
<?xml version="1.0" encoding="UTF-8"?>
<verify_response>
  <request_id>aaaaaaaa-bbbb-...</request_id>
  <status>0</status>
  <error_text>error</error_text>
</verify_response>

Verify Check

Confirm that the PIN you received from your user matches the one sent by Nexmo as a result of your Verify request.

Verify check

To use Verify check you:

  1. Send the verification code that your user supplied, with the corresponding request_id from the Verify request.
  2. Check the status of the response to determine if the code the user supplied matches the one sent by Nexmo.

GET https://api.nexmo.com/verify/check/:format

Path Parameters

Key Description Example Default
format
Required | string

The response format.


Must be one of: json or xml
json None

Query Parameter

Key Description Example Default
api_key
apiKey

You can find your API key in your Nexmo account developer dashboard

abc123 None
api_secret
apiKey

You can find your API secret in your Nexmo account developer dashboard

abc123 None
request_id
Required | string

The Verify request to check. This is the request_id you received in the response to the Verify request.

aaaaaaaa-bbbb-... None
code
Required | string

The verification code entered by your user.

1234 None
ip_address
string

The IP address used by your user when they entered the verification code. Nexmo uses this information to identify fraud and spam. This ultimately benefits all Nexmo customers.

123.0.0.255 None

View response field descriptions

Response Fields

Field Description
request_id

The request_id that you received in the response to the Verify request and used in the Verify check request.

event_id

The message-id of the verification SMS.

status

A value of 0 indicates that your user entered the correct code. If it is non-zero, check the error_text.

price

The cost incurred for this request.

currency

The currency code.

error_text

If the status is non-zero, this explains the error encountered.

Field Description
request_id

The request_id that you received in the response to the Verify request and used in the Verify check request.

event_id

The message-id of the verification SMS.

status

A value of 0 indicates that your user entered the correct code. If it is non-zero, check the error_text.

price

The cost incurred for this request.

currency

The currency code.

error_text

If the status is non-zero, this explains the error encountered.

{
  "request_id": "aaaaaaaa-bbbb-...",
  "event_id": "0A00000012345678",
  "status": "0",
  "price": "0.10000000",
  "currency": "EUR",
  "error_text": "error"
}
<?xml version="1.0" encoding="UTF-8"?>
<verify_response>
  <request_id>aaaaaaaa-bbbb-...</request_id>
  <event_id>0A00000012345678</event_id>
  <status>0</status>
  <price>0.10000000</price>
  <currency>EUR</currency>
  <error_text>error</error_text>
</verify_response>

Verify Search

Lookup the status of one or more requests.

Verify search

To check the status of past or current verification requests:

  1. Send a Verify Search request containing the request_ids of the verification requests you are interested in
  2. Use the status of each verification request in the checks array of the response object to determine the outcome

GET https://api.nexmo.com/verify/search/:format

Path Parameters

Key Description Example Default
format
Required | string

The response format.


Must be one of: json or xml
json None

Query Parameter

Key Description Example Default
api_key
apiKey

You can find your API key in your Nexmo account developer dashboard

abc123 None
api_secret
apiKey

You can find your API secret in your Nexmo account developer dashboard

abc123 None
request_id
string

The request_id you received in the Verify Request Response.

aaaaaaaa-bbbb-... None
request_ids
array
of strings
None

View response field descriptions

Response Fields

Field Description
request_id

The request_id that you received in the response to the Verify request and used in the Verify search request.

account_id

The Nexmo account ID the request was for.

status
Code Description
IN PROGRESS The search is still in progress.
SUCCESS Your user entered a correct verification code.
FAILED Your user entered an incorrect code more than three times.
EXPIRED Your user did not enter a code before the pin_expiry time elapsed.
CANCELLED The verification process was cancelled by a Verify control request.
101 You supplied an invalid request_id.
One of: IN PROGRESS, SUCCESS, FAILED, EXPIRED, CANCELLED or 101
number

The phone number this verification request was used for.

price

The cost incurred for this verification request.

currency

The currency code.

sender_id

The sender_id you provided in the Verify request.

date_submitted

The date and time the verification request was submitted, in the following format YYYY-MM-DD HH:MM:SS.

date_finalized

The date and time the verification request was completed. This response parameter is in the following format YYYY-MM-DD HH:MM:SS.

first_event_date

The time the first verification attempt was made, in the following format YYYY-MM-DD HH:MM:SS.

last_event_date

The time the last verification attempt was made, in the following format YYYY-MM-DD HH:MM:SS.

checks
array of objects

The list of checks made for this verification and their outcomes.

Field Description
date_received
code
status One of: VALID or INVALID
ip_address
error_text

If status is not SUCCESS, this message explains the issue encountered.

Field Description
request_id

The request_id that you received in the response to the Verify request and used in the Verify search request.

account_id

The Nexmo account ID the request was for.

status
Code Description
IN PROGRESS The search is still in progress.
SUCCESS Your user entered a correct verification code.
FAILED Your user entered an incorrect code more than three times.
EXPIRED Your user did not enter a code before the pin_expiry time elapsed.
CANCELLED The verification process was cancelled by a Verify control request.
101 You supplied an invalid request_id.
One of: IN PROGRESS, SUCCESS, FAILED, EXPIRED, CANCELLED or 101
number

The phone number this verification request was used for.

price

The cost incurred for this verification request.

currency

The currency code.

sender_id

The sender_id you provided in the Verify request.

date_submitted

The date and time the verification request was submitted, in the following format YYYY-MM-DD HH:MM:SS.

date_finalized

The date and time the verification request was completed. This response parameter is in the following format YYYY-MM-DD HH:MM:SS.

first_event_date

The time the first verification attempt was made, in the following format YYYY-MM-DD HH:MM:SS.

last_event_date

The time the last verification attempt was made, in the following format YYYY-MM-DD HH:MM:SS.

checks
array of objects

The list of checks made for this verification and their outcomes.

Field Description
date_received
code
status One of: VALID or INVALID
ip_address
error_text

If status is not SUCCESS, this message explains the issue encountered.

{
  "request_id": "aaaaaaaa-bbbb-...",
  "account_id": "abcdef01",
  "status": "IN PROGRESS",
  "number": "447700900000",
  "price": "0.10000000",
  "currency": "EUR",
  "sender_id": "mySenderId",
  "date_submitted": "2020-01-01 12:00:00",
  "date_finalized": "2020-01-01 12:00:00",
  "first_event_date": "2020-01-01 12:00:00",
  "last_event_date": "2020-01-01 12:00:00",
  "checks": [
    {
      "date_received": "2020-01-01 12:00:00",
      "code": "abc123",
      "status": "abc123",
      "ip_address": "123.0.0.255"
    }
  ],
  "error_text": "user entered the wrong pin more than 3 times"
}
<?xml version="1.0" encoding="UTF-8"?>
<verify_request>
  <request_id>aaaaaaaa-bbbb-...</request_id>
  <account_id>abcdef01</account_id>
  <status>IN PROGRESS</status>
  <number>447700900000</number>
  <price>0.10000000</price>
  <currency>EUR</currency>
  <sender_id>mySenderId</sender_id>
  <date_submitted>2020-01-01 12:00:00</date_submitted>
  <date_finalized>2020-01-01 12:00:00</date_finalized>
  <first_event_date>2020-01-01 12:00:00</first_event_date>
  <last_event_date>2020-01-01 12:00:00</last_event_date>
  <checks>
    <check>
      <date_received>2020-01-01 12:00:00</date_received>
      <code>abc123</code>
      <status>abc123</status>
      <ip_address>123.0.0.255</ip_address>
    </check>
  </checks>
  <error_text>user entered the wrong pin more than 3 times</error_text>
</verify_request>

Verify Control

Control the progress of your Verify Requests.

Verify control

To cancel an existing Verify request, or to trigger the next verification event:

  1. Send a Verify control request with the appropriate command (cmd) for what you want to achieve

  2. Check the response.

GET https://api.nexmo.com/verify/control/:format

Path Parameters

Key Description Example Default
format
Required | string

The response format.


Must be one of: json or xml
json None

Query Parameter

Key Description Example Default
api_key
apiKey

You can find your API key in your Nexmo account developer dashboard

abc123 None
api_secret
apiKey

You can find your API secret in your Nexmo account developer dashboard

abc123 None
request_id
Required | string

The request_id you received in the response to the Verify request.

aaaaaaaa-bbbb-... None
cmd
Required | string

The command to execute, depending on whether you want to cancel the verification process, or advance to the next verification event. You must wait at least 30 seconds before cancelling a Verify request.


Must be one of: cancel or trigger_next_event
cancel None

View response field descriptions

Response Fields

Field Description
status
cmd Code Description
Any 0 Success
cancel 19 Either you have not waited at least 30 secs after sending a Verify request before cancelling or Verify has made too many attempts to deliver the verification code for this request and you must now wait for the process to complete.
trigger_next_event 19 All attempts to deliver the verification code for this request have completed and there are no remaining events to advance to.
One of: 0 or 19
command

The cmd you sent in the request.

One of: cancel or trigger_next_event
error_text

If the status is non-zero, this explains the error encountered.

Field Description
status
cmd Code Description
Any 0 Success
cancel 19 Either you have not waited at least 30 secs after sending a Verify request before cancelling or Verify has made too many attempts to deliver the verification code for this request and you must now wait for the process to complete.
trigger_next_event 19 All attempts to deliver the verification code for this request have completed and there are no remaining events to advance to.
One of: 0 or 19
command

The cmd you sent in the request.

One of: cancel or trigger_next_event
error_text

If the status is non-zero, this explains the error encountered.

{
  "status": "0",
  "command": "cancel",
  "error_text": "error"
}
<?xml version="1.0" encoding="UTF-8"?>
<response>
  <status>0</status>
  <command>cancel</command>
  <error_text>error</error_text>
</response>