Создание шаблона сообщения
Этот метод создает новый шаблон сообщения, используемый для отправки OTP-кода. Обратите внимание, что после создания шаблона он проходит модерацию. Этот шаблон будет доступен для отправки сообщений с OTP-кодом только после модерации. Как только он будет готов, его статус изменится с Запрошен на Утвержден.
Чтобы создать шаблон сообщения, сделайте запрос по этому URL:
POST https://one-api.notificore.ru/api/2fa/authentications/templates
Request parameters
Parameter | Requires | Type | Default | Description |
---|---|---|---|---|
name | Yes | string | Name of the template. A string of 3 to 50 characters. | |
countries | Yes | string | Two-letter country code(s) for which the created template must apply. Sending messages with the OTP code will only be possible if the recipient’s number belongs to the country you specify for the template. | |
text | Yes | string | Text of the message template. A string of 9 to 70 characters for any encoding (Cyrillic, Latin). The text must contain one variable for the OTP code – {code2fa}, which will be automatically replaced with the OTP code when the message is sent. |
Request example
{ "name": "template name", "countries": ["RU", "PT", "AD", "IT"], "text": "test code is {code2fa}" }
Response parameters
Parameter | Type | Description |
---|---|---|
template_id | string | Unique, automatically generated by a system identifier of the template within the 2FA service. |
name | string | Name of the template. |
text | string | The text of the template message. |
countries | string | List of countries for which the template is created. |
status | string | Status of the template. After template creation, the status of the template will always be “requested.” |
updated_at | string | Date and time of the last change of the template in ISO 8601 format. |
Response example
Ответ в случае успешного запроса:
{ "data": { "template_id": 515, "name": "template name", "text": "test code is {code2fa}", "countries": [ "AD", "IT", "PT", "RU" ], "status": "requested", "updated_at": "2023-06-30 14:52:58" } }
Possible errors
Code | Error | Description |
---|---|---|
422 | The number of requests to create a template is limited to 10. Please wait for the manager approve before making a new request. | You can have no more than 10 templates with the current status “Requested”. If you already have 10 templates with this status, you need to delete one of them to create a new template. Additionally, if any of the existing templates transitions to the “Approved” or “Rejected” status, it also frees up space for creating a new template. |
422 | The variable {code2fa} is required in the text | This error occurs when the message template text does not contain the required variable {code2fa} or the variable syntax is incorrect. This variable is intended for inserting the actual OTP code into the message text. |
422 | The {code2fa} variable must occur only once in the text | This error occurs when multiple occurrences of the {code2fa} variable are found in the message template text. Please check the entire template text and remove any additional occurrences of the variable. |
422 | This action is not available for the account of your type | Creating a message template for sending OTP codes is not allowed in Demo and Test account mode. |
422 | User has a template with the identical name! | The template with the specified name in the parameter ‘name’ already exists. Please use names that are distinct from your existing templates. |