Create code

🚧

A subscription is required to use this API. Please contact your account manager or our sales team.

Request

POST https://api.cm.com/otp/v2/otp

HTTP headers

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

Request body

{
    "from": "+31601234567",
    "to": "+31602345678",
    "channel": "sms"
}

Parameters

ParameterTypeRequiredDescription
channelstringYesThe channel to send the code. Supported values: sms, rcs, push, whatsapp, viber, voice, email.
digitsintegerNoThe length of the code (min 4, max 10). default: 5.
expiryintegerNoThe expiry in seconds (min 10, max 3600). default: 60 seconds.

Parameters for channel sms, rcs, viber, or push

ParameterTypeRequiredDescription
fromstringYesThe number or name of the sender. This must be a valid phone number in E.164 format or an alphanumeric string between 3 and 11 characters. Please note that alphanumeric senders are not supported in all countries.
tostringYesThe receiver of the code. This must be a valid phone number in E.164 format.
messagestringNoSet a custom message. You can use the placeholder {code}, this will be replaced by the actual code.
Example: Your code is: {code}.
pushAppKeystringWhen channel is pushThe app key.

Parameters for channel whatsapp

ParameterTypeRequiredDescription
fromstringYesThe number or name of the sender. This must be a valid phone number in E.164 format or an alphanumeric string between 3 and 11 characters. Please note that alphanumeric senders are not supported in all countries.
tostringYesThe receiver of the code. This must be a valid phone number in E.164 format.
messagestringNoSet a custom message. You can use the placeholder {code}, this will be replaced by the actual code.
Example: Your code is: {code}. This is only used as a fallback in case the message could not be delivered via WhatsApp.
localestringNoThe locale of the message. This must match with configured locales for the template.

Parameters for channel voice

ParameterTypeRequiredDescription
fromstringYesThe number of the sender. This must be a valid phone number in E.164 format.
tostringYesThe number of the receiver. This must be a valid phone number in E.164 format.
localestringNoSet the spoken language in the voice call. Supported values: de-DE, en-AU, en-GB, en-IN, en-US, es-ES, fr-CA, fr-FR, it-IT, ja-JP, nl-NL
Default: en-GB
anonymousbooleanNoSet whether the number of the caller (from) is hidden in the voice call.
Default: false
messagestringNoSet a custom message to be used in the voice call. Do not include the {code} placeholder.

Parameters for channel email

ParameterTypeRequiredDescription
tostringYesThe email address of the receiver.
localestringNoThe locale for the email template.
messagestringNoSet a custom message to be used in the email message. Do not include the {code} placeholder.

Response

{
    "id": "1e12cb10-d14a-4cd6-8d86-e5263cf122ee",
    "channel": "sms",
    "verified": false,
    "createdAt": "2022-01-01T13:00:00+0000",
    "expiresAt": "2022-01-01T13:01:00+0000"
}

Parameters

ParameterDescription
idThe identifier of the OTP. Use this, together with the code received via the requested channel, to verify the code.
channelThe channel used to send the code.
verifiedIndicates if the OTP was verified.
createdAtThe date the OTP was created.
expiresAtThe date the OTP will expire.