Logo Site EngageLab Mark Colored TransparentDocument
Search

Custom Send OTP

If you prefer to generate the verification code yourself instead of having the EngageLab platform generate it, you can call this interface.

This interface is dedicated to sending pre-generated verification codes and will not generate verification codes by itself. After sending the verification code, there is no need to call the verification interface for verification.

If you prefer the EngageLab platform to generate the verification code, you can call the EngageLab OTP Send OTP interface.

Request URL

POST https://otp.api.engagelab.cc/v1/codes

Authentication

Please refer to Authentication to learn how to perform API authentication.

Request Example

Request Header

POST /v1/codes HTTP/1.1 Content-Type: application/json Authorization: Basic amlndWFuZ2RldjpkZXZfc2VjcmV0
              
              POST /v1/codes  HTTP/1.1  
Content-Type: application/json  
Authorization: Basic amlndWFuZ2RldjpkZXZfc2VjcmV0

            
This code block in the floating window

Request Body

{ "to": "+6591234567", "code":"398210", "template":{ "id":"test-template-1", "language": "default", "params": { "key1": "value1", "key2": "value2" } } }
              
              {
    "to": "+6591234567",
    "code":"398210",
    "template":{
      "id":"test-template-1",
      "language": "default",
        "params": {
        "key1": "value1",
        "key2": "value2"
        }
    }
}

            
This code block in the floating window

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
code String Required The custom verification code to be sent
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

  1. For fields preset in the template such as from_id, if the params field value is not passed, the preset from_id of the template will be used when the message is sent;
  2. If a params field value is passed, such as params:{"from_id":"12345"}, the template's from_id will be replaced with 12345 when the message is sent;
  3. 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 is Hi {{name}}, your verify code is {{code}}, you need to assign the parameter params:{"name":"Bob"}.
  4. 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., through params. 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" }
              
              {
    "message_id": "1725407449772531712",
    "send_channel": "sms"
}

            
This code block in the floating window

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" }
              
              {
    "code": 5001,
    "message": "sms send fail"
}

            
This code block in the floating window

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
Icon Solid Transparent White Qiyu
Contact Sales