Verify API

The verification API allows you to verify if a user currently has access to a given phone number or email address, by sending them an OTP and asking them to verify the code that was sent to them.

This can be achieved by using the following API endpoints below.

Currently, verify only supports Email, WhatsApp and SMS

Sending a Verification

In order to send a message you must have an active channel and perform an HTTP request to the following endpoint with a valid access key.

Creates a new verification message

Creates a new verification message

POST/workspaces/{workspaceId}/verify
Authorization
Path parameters
workspaceId*string (uuid)

The ID of the workspace

Body
identifier*Identifier-2 (object)
localeLocale (string (locale-bcp47))

The locale/language of the message sent to the user. If not provided, we will attempt to determine the locale from the user's phone number. If we are unable to determine the locale, we will default to "en-US".

maxAttemptsMaxAttempts (integer)

The maximum number of attempts to verify the user. [Default: 3]

timeoutTimeout (integer)

The time in seconds before this verification expires. Once expired, it can no longer be verified. [Default: 600]

codeLengthCodeLength (integer)

The length of the verification code. [Default: 6]

steps*array of CreateStep (object)
Response

Verify request was accepted for processing

Body
idstring (uuid)
identifierIdentifier-2 (object)
localeLocale (string (locale-bcp47))

The locale/language of the message sent to the user. If not provided, we will attempt to determine the locale from the user's phone number. If we are unable to determine the locale, we will default to "en-US".

maxAttemptsMaxAttempts (integer)

The maximum number of attempts to verify the user. [Default: 3]

failedAttemptsinteger

The number of times an attempt was made to verify with an incorrect code.

timeoutTimeout (integer)

The time in seconds before this verification expires. Once expired, it can no longer be verified. [Default: 600]

codeLengthCodeLength (integer)

The length of the verification code. [Default: 6]

statusenum

The current status of the verification.

acceptedpendingverifiedfailedexpiredcanceled
currentStepIndexinteger

The index of the current active step in the steps array.

stepsarray of Step (object)
createdAtstring (date-time)

The time the verification was created.

updatedAtstring (date-time)

The time the verification was last updated.

expiresAtstring (date-time)

The time after which the verification can no longer be verified.

Request
const response = await fetch('/workspaces/{workspaceId}/verify', {
    method: 'POST',
    headers: {
      "Authorization": "Bearer jwt",
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      "identifier": {},
      "steps": [
        {}
      ]
    }),
});
const data = await response.json();
Response
{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "identifier": {
    "phonenumber": "text",
    "emailaddress": "text"
  },
  "locale": "text",
  "status": "accepted",
  "steps": [
    {
      "channelId": "123e4567-e89b-12d3-a456-426614174000",
      "navigatorId": "123e4567-e89b-12d3-a456-426614174000",
      "identifier": "text",
      "template": {
        "name": "text",
        "projectId": "text",
        "version": "text",
        "locale": "text",
        "shortLinks": {
          "enabled": false,
          "domain": "text"
        },
        "variables": {
          "default": "text"
        },
        "utmParameters": [
          {
            "key": "text",
            "value": "text"
          }
        ],
        "parameters": [
          {
            "type": "string",
            "key": "text",
            "value": "text"
          }
        ]
      },
      "status": "unused",
      "attempts": [
        {
          "messageId": "123e4567-e89b-12d3-a456-426614174000",
          "status": "prepared",
          "verified": false,
          "sentAt": "2024-09-16T18:51:10.893Z",
          "verifiedAt": "2024-09-16T18:51:10.893Z"
        }
      ]
    }
  ],
  "createdAt": "2024-09-16T18:51:10.893Z",
  "updatedAt": "2024-09-16T18:51:10.893Z",
  "expiresAt": "2024-09-16T18:51:10.893Z"
}

Here is an example of a basic verify request body for SMS

{
  "identifier": {
    "phonenumber": "+31623456789"
  },
  "steps": [
    {
      "channelId": "SMS_CHANNEL_UUID"
    }
  ]
}

Steps

You can use Steps to implement a failover strategy between different channels. The minimum amount of steps is one. Calling the failover endpoint will cause it to move to the next step.

{
  "identifier": {
    "phonenumber": "+31623456789",
    "emailaddress": "name@example.com"
  },
  "locale": "en-US",
  "maxAttempts": 3,
  "timeout": 300,
  "codeLength": 6,
  "steps": [
    {
      "channelId": "CHANNEL_UUID"
    },
    {
      "channelId": "FAILOVER_CHANNEL_UUID"
    }
  ]
}

Templates

Verify supports using templates for some channels. The following is an example of using a channel with a template.

{
  "identifier": {
    "phonenumber": "+31623456789",
  },
  "steps": [
    {
      "channelId": "CHANNEL_UUID",
      "template": {
        "projectId": "TEMPLATE_UUID",
        "version": "TEMPLATE_VERSION_UUID|latest",
        "locale": "en"
      }
    }
  ]
}

SMS Templates

SMS does not support templates. For SMS, the body is generated by the verify API. You can however change the language by setting the locale of the verification. Supported languages include:

  • Afrikaans

  • Arabic

  • German

  • English

  • Spanish

  • French

  • Italian

  • Dutch

  • Polish

  • Portuguese

  • Russian

  • Turkish

Email Templates

For emails, templates work just as you would expect via the channels API, with the addition of a variable for the Verify OTP Code.

When setting up a template for Email, select {} -> Verify -> OTP from the list of variables

WhatsApp Templates

Templates for WhatsApp channels are required. In order to send an OTP message to a WhatsApp channel, you need to have an Authentication Template set up.

Verifying the code

Once you have received a code from one of your users you will have to confirm if the code is valid.

Verifies a code of a verification message

Verifies a code of a verification message

POST/workspaces/{workspaceId}/verify/{verificationId}
Authorization
Path parameters
workspaceId*string (uuid)

The ID of the workspace

verificationId*string (uuid)

The ID for a verification

Body
code*string
Response

Code was successfully verified

Body
idstring (uuid)
identifierIdentifier-2 (object)
localeLocale (string (locale-bcp47))

The locale/language of the message sent to the user. If not provided, we will attempt to determine the locale from the user's phone number. If we are unable to determine the locale, we will default to "en-US".

maxAttemptsMaxAttempts (integer)

The maximum number of attempts to verify the user. [Default: 3]

failedAttemptsinteger

The number of times an attempt was made to verify with an incorrect code.

timeoutTimeout (integer)

The time in seconds before this verification expires. Once expired, it can no longer be verified. [Default: 600]

codeLengthCodeLength (integer)

The length of the verification code. [Default: 6]

statusenum

The current status of the verification.

acceptedpendingverifiedfailedexpiredcanceled
currentStepIndexinteger

The index of the current active step in the steps array.

stepsarray of Step (object)
createdAtstring (date-time)

The time the verification was created.

updatedAtstring (date-time)

The time the verification was last updated.

expiresAtstring (date-time)

The time after which the verification can no longer be verified.

Request
const response = await fetch('/workspaces/{workspaceId}/verify/{verificationId}', {
    method: 'POST',
    headers: {
      "Authorization": "Bearer jwt",
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      "code": "text"
    }),
});
const data = await response.json();
Response
{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "identifier": {
    "phonenumber": "text",
    "emailaddress": "text"
  },
  "locale": "text",
  "status": "accepted",
  "steps": [
    {
      "channelId": "123e4567-e89b-12d3-a456-426614174000",
      "navigatorId": "123e4567-e89b-12d3-a456-426614174000",
      "identifier": "text",
      "template": {
        "name": "text",
        "projectId": "text",
        "version": "text",
        "locale": "text",
        "shortLinks": {
          "enabled": false,
          "domain": "text"
        },
        "variables": {
          "default": "text"
        },
        "utmParameters": [
          {
            "key": "text",
            "value": "text"
          }
        ],
        "parameters": [
          {
            "type": "string",
            "key": "text",
            "value": "text"
          }
        ]
      },
      "status": "unused",
      "attempts": [
        {
          "messageId": "123e4567-e89b-12d3-a456-426614174000",
          "status": "prepared",
          "verified": false,
          "sentAt": "2024-09-16T18:51:10.893Z",
          "verifiedAt": "2024-09-16T18:51:10.893Z"
        }
      ]
    }
  ],
  "createdAt": "2024-09-16T18:51:10.893Z",
  "updatedAt": "2024-09-16T18:51:10.893Z",
  "expiresAt": "2024-09-16T18:51:10.893Z"
}

Resend a code for a specific verification step

Using the following endpoint, you can also resend a message for a given verification step.

By not setting a value for stepIndex, it will default to the currently active step.

Resend verification code

Attempt resending a verification code for a given step

POST/workspaces/{workspaceId}/verify/{verificationId}/resend
Authorization
Path parameters
workspaceId*string (uuid)

The ID of the workspace

verificationId*string (uuid)

The ID for a verification

Body
stepIndexnullable StepIndex (integer)

The index of the step to use.

Response

Resend request was accepted for processing

Body
idstring (uuid)
identifierIdentifier-2 (object)
localeLocale (string (locale-bcp47))

The locale/language of the message sent to the user. If not provided, we will attempt to determine the locale from the user's phone number. If we are unable to determine the locale, we will default to "en-US".

maxAttemptsMaxAttempts (integer)

The maximum number of attempts to verify the user. [Default: 3]

failedAttemptsinteger

The number of times an attempt was made to verify with an incorrect code.

timeoutTimeout (integer)

The time in seconds before this verification expires. Once expired, it can no longer be verified. [Default: 600]

codeLengthCodeLength (integer)

The length of the verification code. [Default: 6]

statusenum

The current status of the verification.

acceptedpendingverifiedfailedexpiredcanceled
currentStepIndexinteger

The index of the current active step in the steps array.

stepsarray of Step (object)
createdAtstring (date-time)

The time the verification was created.

updatedAtstring (date-time)

The time the verification was last updated.

expiresAtstring (date-time)

The time after which the verification can no longer be verified.

Request
const response = await fetch('/workspaces/{workspaceId}/verify/{verificationId}/resend', {
    method: 'POST',
    headers: {
      "Authorization": "Bearer jwt",
      "Content-Type": "application/json"
    },
    body: JSON.stringify({}),
});
const data = await response.json();
Response
{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "identifier": {
    "phonenumber": "text",
    "emailaddress": "text"
  },
  "locale": "text",
  "status": "accepted",
  "steps": [
    {
      "channelId": "123e4567-e89b-12d3-a456-426614174000",
      "navigatorId": "123e4567-e89b-12d3-a456-426614174000",
      "identifier": "text",
      "template": {
        "name": "text",
        "projectId": "text",
        "version": "text",
        "locale": "text",
        "shortLinks": {
          "enabled": false,
          "domain": "text"
        },
        "variables": {
          "default": "text"
        },
        "utmParameters": [
          {
            "key": "text",
            "value": "text"
          }
        ],
        "parameters": [
          {
            "type": "string",
            "key": "text",
            "value": "text"
          }
        ]
      },
      "status": "unused",
      "attempts": [
        {
          "messageId": "123e4567-e89b-12d3-a456-426614174000",
          "status": "prepared",
          "verified": false,
          "sentAt": "2024-09-16T18:51:10.893Z",
          "verifiedAt": "2024-09-16T18:51:10.893Z"
        }
      ]
    }
  ],
  "createdAt": "2024-09-16T18:51:10.893Z",
  "updatedAt": "2024-09-16T18:51:10.893Z",
  "expiresAt": "2024-09-16T18:51:10.893Z"
}

Failover to next step

You can failover to another verification step by calling the following endpoint.

By not setting a value for stepIndex, it will default to the next step in the array.

Failover to next step

Failover to the next step of the verification process

POST/workspaces/{workspaceId}/verify/{verificationId}/failover
Authorization
Path parameters
workspaceId*string (uuid)

The ID of the workspace

verificationId*string (uuid)

The ID for a verification

Body
stepIndexnullable StepIndex (integer)

The index of the step to use.

Response

Failover request was accepted for processing

Body
idstring (uuid)
identifierIdentifier-2 (object)
localeLocale (string (locale-bcp47))

The locale/language of the message sent to the user. If not provided, we will attempt to determine the locale from the user's phone number. If we are unable to determine the locale, we will default to "en-US".

maxAttemptsMaxAttempts (integer)

The maximum number of attempts to verify the user. [Default: 3]

failedAttemptsinteger

The number of times an attempt was made to verify with an incorrect code.

timeoutTimeout (integer)

The time in seconds before this verification expires. Once expired, it can no longer be verified. [Default: 600]

codeLengthCodeLength (integer)

The length of the verification code. [Default: 6]

statusenum

The current status of the verification.

acceptedpendingverifiedfailedexpiredcanceled
currentStepIndexinteger

The index of the current active step in the steps array.

stepsarray of Step (object)
createdAtstring (date-time)

The time the verification was created.

updatedAtstring (date-time)

The time the verification was last updated.

expiresAtstring (date-time)

The time after which the verification can no longer be verified.

Request
const response = await fetch('/workspaces/{workspaceId}/verify/{verificationId}/failover', {
    method: 'POST',
    headers: {
      "Authorization": "Bearer jwt",
      "Content-Type": "application/json"
    },
    body: JSON.stringify({}),
});
const data = await response.json();
Response
{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "identifier": {
    "phonenumber": "text",
    "emailaddress": "text"
  },
  "locale": "text",
  "status": "accepted",
  "steps": [
    {
      "channelId": "123e4567-e89b-12d3-a456-426614174000",
      "navigatorId": "123e4567-e89b-12d3-a456-426614174000",
      "identifier": "text",
      "template": {
        "name": "text",
        "projectId": "text",
        "version": "text",
        "locale": "text",
        "shortLinks": {
          "enabled": false,
          "domain": "text"
        },
        "variables": {
          "default": "text"
        },
        "utmParameters": [
          {
            "key": "text",
            "value": "text"
          }
        ],
        "parameters": [
          {
            "type": "string",
            "key": "text",
            "value": "text"
          }
        ]
      },
      "status": "unused",
      "attempts": [
        {
          "messageId": "123e4567-e89b-12d3-a456-426614174000",
          "status": "prepared",
          "verified": false,
          "sentAt": "2024-09-16T18:51:10.893Z",
          "verifiedAt": "2024-09-16T18:51:10.893Z"
        }
      ]
    }
  ],
  "createdAt": "2024-09-16T18:51:10.893Z",
  "updatedAt": "2024-09-16T18:51:10.893Z",
  "expiresAt": "2024-09-16T18:51:10.893Z"
}

Retrieving Verifications

Retrieving a list of Verifications

List all verifications

List all verifications for this workspace

GET/workspaces/{workspaceId}/verify
Authorization
Path parameters
workspaceId*string (uuid)

The ID of the workspace

Query parameters
Response

OK

Body
nextPageTokenstring
resultsarray of VerifyObject
nextPageTokenstring

The token that can be passed as pageToken in URL to retrieve the next set of results. If missing, no more results to display.

Request
const response = await fetch('/workspaces/{workspaceId}/verify', {
    method: 'GET',
    headers: {
      "Authorization": "Bearer jwt"
    },
});
const data = await response.json();
Response
{
  "nextPageToken": "text",
  "results": [
    {
      "id": "123e4567-e89b-12d3-a456-426614174000",
      "identifier": {
        "phonenumber": "text",
        "emailaddress": "text"
      },
      "locale": "text",
      "status": "accepted",
      "steps": [
        {
          "channelId": "123e4567-e89b-12d3-a456-426614174000",
          "navigatorId": "123e4567-e89b-12d3-a456-426614174000",
          "identifier": "text",
          "template": {
            "name": "text",
            "projectId": "text",
            "version": "text",
            "locale": "text",
            "shortLinks": {
              "enabled": false,
              "domain": "text"
            },
            "variables": {
              "default": "text"
            },
            "utmParameters": [
              {
                "key": "text",
                "value": "text"
              }
            ],
            "parameters": [
              {
                "type": "string",
                "key": "text",
                "value": "text"
              }
            ]
          },
          "status": "unused",
          "attempts": [
            {
              "messageId": "123e4567-e89b-12d3-a456-426614174000",
              "status": "prepared",
              "verified": false,
              "sentAt": "2024-09-16T18:51:10.893Z",
              "verifiedAt": "2024-09-16T18:51:10.893Z"
            }
          ]
        }
      ],
      "createdAt": "2024-09-16T18:51:10.893Z",
      "updatedAt": "2024-09-16T18:51:10.893Z",
      "expiresAt": "2024-09-16T18:51:10.893Z"
    }
  ]
}

Retrieving a single Verification

Get verification message

Get a verification message

GET/workspaces/{workspaceId}/verify/{verificationId}
Authorization
Path parameters
workspaceId*string (uuid)

The ID of the workspace

verificationId*string (uuid)

The ID for a verification

Response

OK

Body
idstring (uuid)
identifierIdentifier-2 (object)
localeLocale (string (locale-bcp47))

The locale/language of the message sent to the user. If not provided, we will attempt to determine the locale from the user's phone number. If we are unable to determine the locale, we will default to "en-US".

maxAttemptsMaxAttempts (integer)

The maximum number of attempts to verify the user. [Default: 3]

failedAttemptsinteger

The number of times an attempt was made to verify with an incorrect code.

timeoutTimeout (integer)

The time in seconds before this verification expires. Once expired, it can no longer be verified. [Default: 600]

codeLengthCodeLength (integer)

The length of the verification code. [Default: 6]

statusenum

The current status of the verification.

acceptedpendingverifiedfailedexpiredcanceled
currentStepIndexinteger

The index of the current active step in the steps array.

stepsarray of Step (object)
createdAtstring (date-time)

The time the verification was created.

updatedAtstring (date-time)

The time the verification was last updated.

expiresAtstring (date-time)

The time after which the verification can no longer be verified.

Request
const response = await fetch('/workspaces/{workspaceId}/verify/{verificationId}', {
    method: 'GET',
    headers: {
      "Authorization": "Bearer jwt"
    },
});
const data = await response.json();
Response
{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "identifier": {
    "phonenumber": "text",
    "emailaddress": "text"
  },
  "locale": "text",
  "status": "accepted",
  "steps": [
    {
      "channelId": "123e4567-e89b-12d3-a456-426614174000",
      "navigatorId": "123e4567-e89b-12d3-a456-426614174000",
      "identifier": "text",
      "template": {
        "name": "text",
        "projectId": "text",
        "version": "text",
        "locale": "text",
        "shortLinks": {
          "enabled": false,
          "domain": "text"
        },
        "variables": {
          "default": "text"
        },
        "utmParameters": [
          {
            "key": "text",
            "value": "text"
          }
        ],
        "parameters": [
          {
            "type": "string",
            "key": "text",
            "value": "text"
          }
        ]
      },
      "status": "unused",
      "attempts": [
        {
          "messageId": "123e4567-e89b-12d3-a456-426614174000",
          "status": "prepared",
          "verified": false,
          "sentAt": "2024-09-16T18:51:10.893Z",
          "verifiedAt": "2024-09-16T18:51:10.893Z"
        }
      ]
    }
  ],
  "createdAt": "2024-09-16T18:51:10.893Z",
  "updatedAt": "2024-09-16T18:51:10.893Z",
  "expiresAt": "2024-09-16T18:51:10.893Z"
}

Last updated