Skip to content
Home » Octopush Gateway SMS API » (2FA) Two Factor Authentication » OTP/MFA – Send a code

OTP/MFA – Send a code

POST
https://api.octopush.com/v1/public/service/otp/generate

Encodage : UTF-8

Authentification

Your “api-key” and “api-login” identifiers must be added in the headers.

Definition

Allows you to generate and send an OTP code to a recipient on the channel of your choice.

Special parameters

NameTypeDescription
phone_numberstringRecipient’s telephone numbers
channelstring(optional) Channel to send your message [“text_sms”, “voice_sms”, “whatsapp”, “email”, “imessage”]
textstring(optional) You can include the place holder {code} (the generated OTP code) and/or {hh:mm:ss} (the expiry date of this code). Leave this field empty so that only the code is sent.
voice_languagestring(optional) Voice language used in the case of the sms_voice channel [“en-US”, “en-GB”, “el-GR”, “pl-PL”, “hu-HU”, “sv-SE”, “de-DE”, “es-ES”, “es-LA”, “fr-FR”, “it-IT”, “pt-BR”, “ru-RU]
voice_genderstring(optional) Gender of voice [“male”, “female”].
senderstring(optional) Sender of your message.
code_lengthinteger(optional) from 3 to 32 characters.
allow_digitsboolean(optional) Allow numbers.
allow_upper_caseboolean(optional) Allows upper case characters.
allow_lower_caseboolean(optional) Allows lower case characters.
allow_special_charsboolean(optional) allows special characters [! # $ % & ? @]
remove_confusing_charactersboolean(optional) Removes characters for which the reader may hesitate:
validity_periodinteger(optionnel) en secondes. Définit le nombre de secondes avant que le code n’expire.
max_wrong_attemptsstring(optionnel) Nombre maximum de tentatives de front.
recipient_ipstring(optional) IP of your recipient. If the value is non-zero, the IP must be identical when checked.

For each of the optional fields, the default value used will be the one you have defined on your Octopush interface.

Curl Example

curl -X POST \ 
'https://api.octopush.com/v1/public/service/otp/generate' \ 
-H 'Content-Type: application/json' \ 
-H 'api-login: ******@email.org' \ 
-H 'api-key: ************' \ 
-H 'cache-control: no-cache' \ 
-d '
{
  "phone_number": "+33611223344",
    "text": "Bonjour, voici votre code pour vous authentifier sur LESITE.com : {code}, il esxpira à {hh:mm:ss}",
    "voice_language": "fr-FR",
    "voice_gender": "female",
    "sender": "OneTimePass",
    "channel": "voice_sms",
    "code_length": 10,
    "allow_digits": true,
    "allow_upper_case": false,
    "allow_lower_case": false,
    "allow_special_chars": false,
    "remove_confusing_characters": true,
    "validity_period": 600,
    "max_wrong_attempts": 3,
    "recipient_ip": "127.0.0.1"
}'

Copy and paste code

curl -X POST 'https://api.octopush.com/v1/public/service/otp/generate' -H 'Content-Type: application/json' -H 'api-login: ******@email.org' -H 'api-key: ************' -H 'cache-control: no-cache' -d ' {"phone_number": "+33611223344", "text": "Bonjour,  voici votre code pour vous authentifier sur LESITE.com : {code},  il esxpira à {hh:mm:ss}", "voice_language": "fr-FR", "voice_gender": "female", "sender": "OneTimePass", "channel": "voice_sms", "code_length": 10, "allow_digits": true, "allow_upper_case": false, "allow_lower_case": false, "allow_special_chars": false, "remove_confusing_characters": true, "validity_period": 600, "max_wrong_attempts": 3, "recipient_ip": "127.0.0.1"}'

JSON Server Response

Success : 200 Created

{
    "code": 0,
    "message": "success",
    "ticket_number": "sms_1111cccc6666bbb2222233333",
    "otp_request_token": "otp_2222cc888888dd11110000"
}

Failure : 400 BAD REQUEST

{
  "code": 400,
  "message": "Payload validation error.",
  "errors": {
    "phone_number": {
      "code": 410,
      "message": "This value should not be blank."
    }
  }
}

Returned parameters

FieldTypeDescription
codeintergerReturn code of your request. 0 === success.
messagestringMore explicit message of the error encountered.
ticket_numberstringCampaign ticket
otp_request_tokenstringIdentifier of your request. It will be needed to check the code entered by your visitor.