Send OTP
This interface is used to generate a verification code by the EngageLab platform and send it according to the channel strategy specified in the template.
If you prefer to generate the verification code yourself instead of having the EngageLab platform generate it, you can call the EngageLab OTP Custom Send OTP interface.
Request URL
POST https://otp.api.engagelab.cc/v1/messages
Authentication
Please refer to Authentication to learn how to perform API authentication.
Request Example
Request Header
POST /v1/messages HTTP/1.1
Content-Type: application/json
Authorization: Basic amlndWFuZ2RldjpkZXZfc2VjcmV0
Request Body
{
"to": "+6591234567",
"template":{
"id":"test-template-1",
"language": "default",
"params": {
"key1": "value1",
"key2": "value2"
}
}
}
Request Parameters
A request object is expressed in JSON format, so the request header must include Content-Type: application/json.
| Parameter | Type | Option | Description |
|---|---|---|---|
| to | String | Required | Sending target, mobile number or email address, +6598765432, support@engagelab.com |
| template | JSON Object | Required | Template information, see secondary parameters below |
| |_ id | String | Required | Template ID |
| |_ language | String | Optional | Template language, supports the following languages: default (Default language) zh_CN (Simplified Chinese) zh_HK (Traditional Chinese) en (English) ja (Japanese) th (Thai) es (Spanish) If not passed, it defaults to default. |
| |_ params | JSON Object | Optional | Values for custom template variable keys. If you customized variables when creating the template, pass their values here. If not passed, they will be sent directly as variable keys, such as {{var}} |
Notes on params
- For fields preset in the template such as
from_id, if theparamsfield value is not passed, the presetfrom_idof the template will be used when the message is sent; - If a
paramsfield value is passed, such asparams:{"from_id":"12345"}, the template'sfrom_idwill be replaced with 12345 when the message is sent; - At the same time, for custom variable fields in the template content when creating the template, they are also assigned values through
params. For example, if the template content isHi {{name}}, your verify code is {{code}}, you need to assign the parameterparams:{"name":"Bob"}. - Email Channel Special Variables: For the Email channel, you can dynamically override the email subject (
subject), sender name (from_name), sender email (from_mail), etc., throughparams. For detailed advanced usage, please refer to Create Template - Email Template Variables Advanced Usage.
Response Parameters
Success Response
| Field | Type | Option | Description |
|---|---|---|---|
| message_id | String | Required | Message ID, uniquely identifies a message |
| send_channel | String | Required | Indicates the current sending channel, values are whatsapp/sms/email/voice |
{
"message_id": "1725407449772531712",
"send_channel": "sms"
}
Note that the returned send_channel value does not represent the final channel delivered to the user, but only represents the channel used at this stage; for example, if the strategy configured in the template specifies that the WhatsApp channel fails to deliver and then automatically falls back to the SMS channel, the interface will return the whatsapp value. After sensing the delivery failure after a certain period of time, the system will use the SMS channel to send.
Failure Response
The HTTP status code is 4xx or 5xx, and the response body contains the following fields:
| Field | Type | Option | Description |
|---|---|---|---|
| code | int | Required | Error code, see error code description for details |
| message | String | Required | Error details |
{
"code": 5001,
"message": "sms send fail"
}
Error Codes
| Error Code | HTTP Code | Description |
|---|---|---|
| 1000 | 500 | Internal error |
| 2001 | 401 | Authentication failed, incorrect token carried |
| 2002 | 401 | Authentication failed, token has expired or been disabled |
| 2004 | 403 | No permission to call this API |
| 3001 | 400 | Invalid request parameter format, please check if the JSON content conforms to the parameter format |
| 3002 | 400 | Incorrect request parameters, please check if the request parameters meet the requirements |
| 3003 | 400 | Incorrect request parameters, related business verification failed, please refer to the error description in the message field for details |
| 3004 | 400 | Frequency limit exceeded, for the same template and the same target user, it cannot be sent again within the validity period of the verification code |
| 4001 | 400 | Related resource does not exist, such as using a non-existent template when sending a template message |
| 5001 | 400 | Sending failed (general/other) |
| 5011 | 400 | Invalid mobile number format |
| 5012 | 400 | Target unreachable |
| 5013 | 400 | Number is blacklisted |
| 5014 | 400 | Content does not meet specifications |
| 5015 | 400 | Message intercepted/rejected |
| 5016 | 400 | Internal sending error |
| 5017 | 400 | No sending permission for China region |
| 5018 | 400 | Mobile phone failure (powered off/out of service) |
| 5019 | 400 | User has unsubscribed |
| 5020 | 400 | Number unregistered/empty number |










