Отправка одноразового кода
Этот вызов API используется для генерации и отправки одноразового пароля пользователю в SMS- или Viber-сообщении. Пожалуйста, обратите внимание: аутентификация получателей, находящихся в стоп-листе SMS или Viber в вашей адресной книге, не возможна с использованием соответствующего метода.
То есть, если получатель находится в стоп-листе SMS, то при запросе аутентификации с использованием метода SMS одноразовый пароль не будет отправлен, и вы получите ошибку в ответ.
Чтобы отправить одноразовый пароль, выполните запрос по этому URL:
POST https://one-api.notificore.ru/api/2fa/authentications/otp
Request parameters
Parameter | Requires | Type | Default | Description |
---|---|---|---|---|
channel | Yes | string | No | A channel for sending a one-time password. Possible values: “SMS”, “Viber”. |
sender | Yes | string | No | Sender’s name: from 3 to 11 characters for the sender’s alphanumeric name (Latin letters, symbols, numbers, spaces); 3 to 15 characters for the sender’s numeric name. |
recipient | Yes | integer | No | The phone number of the recipient of the one-time password. 9 to 15 digits without the + sign. |
template_id | Yes | string | No | Unique identifier of the template with the Approved status. It’s not allowed to specify the template ID in other statuses. The template ID must be from 1 to 9 digits. |
code_digits | Yes | integer | No | The length of the numeric code, from 3 to 9 digits. |
code_lifetime | Yes | integer | No | The password expiration time after which the password becomes invalid. An integer from 30 seconds to 300 seconds. |
code_max_tries | Yes | integer | No | The number of password verification attempts. An integer from 1 to 5. |
sender_alt | No | string | No | Used only for the Viber channel to alternatively send a one-time code in SMS (if it was not possible to send the code in a Viber message, for example, if the recipient is not a Viber user). The name or number of the SMS sender. String up to 15 characters: from 3 to 11 characters for the sender’s alphanumeric name (Latin letters, symbols, numbers, spaces); 3 to 15 characters for the sender’s numeric name. |
Request example
{ "recipient": "61401629754", "channel": "string", "sender": "SENDER", "sender_alt": "SENDER_ALT", "template_id": "12", "code_lifetime": 300, "code_max_tries": 3, "code_digits": 5 }
Response parameters
Parameter | Type | Description |
---|---|---|
id | string | The ID of the generated authentication. |
recipient | string | Number of the recipient of the message with a one-time code. |
status | string | Authentication status. Possible values: pending (authentication session successfully created and pending). |
channel | string | Authentication channel selected for sending the one-time code |
sender | string | Sender name. |
sender_alt | string/null | SMS sender name. |
message_text | string | Message text. |
code_lifetime | integer | OTP expiration date. |
code_max_tries | integer | The number of OTP check attempts. |
code_digits | integer | The number of digits in the OTP. |
price | float | Authentication cost. At the time of creating the authentication, 0 is indicated. |
currency | string | The three-letter code of the currency in which the value is indicated. Corresponds to the user’s account currency. |
country_code | string | The country code of the recipient of the one-time password according to the ISO 3166-1 alpha-2 standard. |
expired_at | string | Date and time when the authentication expires in ISO 8601 format. |
created_at | string | The date and time of the authentication session were created in ISO 8601 format. |
finished_at | null | Date and time when the authentication session was closed. At the time of creating the authentication, the value “null” is indicated. |
Response example
Ответ в случае успешного запроса:
{ "data": { "id": "bf4381c8-9d4a-4705-bd28-f89a830b7f96", "recipient": "792979965073", "status": "pending", "channel": "sms", "sender": "SENDER", "sender_alt": "SENDER_ALT", "message_text": "Your verification code: {code}", "code_lifetime": 300, "code_max_tries": 3, "code_digits": 5, "price": "0,02", "currency": "USD", "country_code": "RU", "expired_at": "2023-01-04 18:37:06", "created_at": "2023-01-04 17:37:06", "finished_at": "2023-01-04 17:37:06" } }
Codes of errors
Code | Error | Description |
---|---|---|
404 | User channel not found | This error can occur when the channel is specified incorrectly. Please ensure that you are using the correct channel and try again. |
404 | Template not found | This error can occur when the template identifier is specified incorrectly or the specified template is not present in the system. Please ensure that you are using the correct template identifier and try again. |
422 | Invalid template status | This error occurs when the provided template identifier in the request does not match the “Approved” status. |
402 | Insufficient funds | Insufficient funds to send OTP. Please top up your account. |
422 | Exists on the stop list | We’re unable to send message as the phone number of recipient is currently in stop list. |
422 | User channel inactive | The message sending method is disabled. Please enable method in your personal account and try again. |
422 | This action is available for the account of your type only for your manager phone number. | To send OTP code is not allowed in Demo account mode. |
422 | Authentication limit with status pending | This error can occur when total authentication limit with status “pending” is exceeded for your account. |
422 | Total authentication limit | This error can occur when total authentication limit is exceeded for your account. |
422 | Template is not available | This error occurs when you try to create authentication using a template that is only available in the test mode of your account. Please choose a different template. |