POST
https://api.octopush.com/v1/public/service/otp/generateEncodage : 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
| Name | Type | Description |
|---|---|---|
| phone_number | string | Recipient’s telephone numbers |
| channel | string | (optional) Channel to send your message [“text_sms”, “voice_sms”, “whatsapp”, “email”, “imessage”] |
| text | string | (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_language | string | (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_gender | string | (optional) Gender of voice [“male”, “female”]. |
| sender | string | (optional) Sender of your message. |
| code_length | integer | (optional) from 3 to 32 characters. |
| allow_digits | boolean | (optional) Allow numbers. |
| allow_upper_case | boolean | (optional) Allows upper case characters. |
| allow_lower_case | boolean | (optional) Allows lower case characters. |
| allow_special_chars | boolean | (optional) allows special characters [! # $ % & ? @] |
| remove_confusing_characters | boolean | (optional) Removes characters for which the reader may hesitate: |
| validity_period | integer | (optionnel) en secondes. Définit le nombre de secondes avant que le code n’expire. |
| max_wrong_attempts | string | (optionnel) Nombre maximum de tentatives de front. |
| recipient_ip | string | (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
| Field | Type | Description |
|---|---|---|
| code | interger | Return code of your request. 0 === success. |
| message | string | More explicit message of the error encountered. |
| ticket_number | string | Campaign ticket |
| otp_request_token | string | Identifier of your request. It will be needed to check the code entered by your visitor. |