One Time Password (OTP) [v1]

🚧

One Time Password (OTP) [v1] is deprecated

OTP API v1 is deprecated as a new version is available. OTP API v2 includes SMS, Push, Voice, Email, Viber, RCS, and WhatsApp Business Platform as channels. Please contact your account manager or our sales team to upgrade if you're using v1.

Generate code

Request

POST https://api.cm.com/v1.0/otp/generate

HTTP headers

HeaderDescription
X-CM-ProductTokenYour product token. Retrieve from Messaging Gateway app.
Content-Typeapplication/json

Request body

{
    "recipient": "0031601234567",
    "sender": "My company"
}

Parameters

PropertyTypeRequiredDescription
recipientstringYesPhone number in international format. e.g. 0031601234567.
senderstringYesThe name or phone number of the sender. Please note that alphanumeric sender is not supported in all countries. If allowVoice is true, sender must be a phone number. For alphanumeric senders, the length should be between 3 and 11 characters.
lengthintegerNolength of the code (min 4, max 10). default: 5.
expiryintegerNoexpiry in seconds (min 10, max 3600). default: 60 seconds.
allowPushbooleanNoAllow code to be send via push notification. default: false.
appKeystringNoThe app key GUID.
allowVoicebooleanNoSend the code via a voice call.
voiceLanguagestringNoChange the language of the voice call. Supported values: de, en, es, fr, it, nl. Default: en
messagestringNoSet a custom message. You can use the placeholder {code} which will be replaced by the actual code. e.g. Your code is: {code}.

📘

When allowPush is set to true, a valid app key is required

Response

{
    "id": "1e12cb10-d14a-4cd6-8d86-e5263cf122ee",
    "createdAt": "2022-01-01T13:00:00+0000",
    "expireAt": "2022-01-01T13:01:00+0000"
}

Parameters

ParameterDescription
idThe unique identifier for the code. Use this in combination with the received code to verify the code.
createdAtThe date the code was created.
expireAtThe date the code will expire.

Response codes

HTTP statusDescription
200Successful request.
400Invalid request, see message in the response.
500Unknown error occurred.

Verify code

Request

POST https://api.cm.com/v1.0/otp/verify

HTTP headers

HeaderDescription
X-CM-ProductTokenYour product token. Retrieve from Messaging Gateway app.
Content-Typeapplication/json

Request body

{
    "id": "1e12cb10-d14a-4cd6-8d86-e5263cf122ee",
    "code": "12345"
}

Parameters

ParameterTypeDescription
idstringCode identifier.
codestringThe code received via SMS/Push or Voice.

Response

{
  "valid": true
}

📘

Once a code has been successfully validated, it cannot be validated again.

Parameters

ParameterDescription
validIndicates if the code was valid.

Response codes

HTTP statusDescription
200Successful request.
400Invalid request, see message in the response.
500Unknown error occurred.