Generate code

🚧

A new version of the OTP API is available. This version includes email and WhatsApp as channels. Please consider upgrading. A subscription is required for this version. Please contact your account manager or our sales team.

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

recipientstringYesPhone number in international format. e.g. 0031601234567.
senderstringYesThe name or phone number of the sender (min 3, max 11). Please note that alphanumeric sender is not supported in all countries.
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.