Template API Interface
Create Template
Endpoint
POST https://otp.api.engagelab.cc/v1/template-configs
Authentication
Use HTTP Basic Authentication for authentication, and add Authorization to the HTTP header:
Authorization: Basic ${base64_auth_string}
The generation algorithm for base64_auth_string above is: base64(dev_key:dev_secret)
Request Example
Request Header
POST /v1/messages HTTP/1.1
Content-Type: application/json
Authorization: Basic amlndWFuZ2RldjpkZXZfc2VjcmV0
Request Body
{
"template_id": "test-template-1",
"description": "测试模版1",
"send_channel_strategy": "whatsapp|sms",
"brand_name": "品牌名称",
"verify_code_config": {
"verify_code_type": 1,
"verify_code_len": 6,
"verify_code_ttl": 1
},
"whatsapp_config": {
"template_type": 1,
"template_default_config": {
"contain_security": false,
"contain_expire": false
}
},
"sms_config": {
"template_type": 2,
"template_default_config": {
"contain_security": false,
"contain_expire": false
},
"template_custom_config": {
"custom_sub_type": "authentication",
"custom_content": "xxx",
"custom_country_codes": "HK,PH"
}
},
"voice_config": {
"template_type": 1,
"template_default_config": {
"contain_security": false,
"contain_expire": false
}
},
"email_config": {
"template_name": "email模板名称",
"template_custom_configs": [{
"language": "default",
"pre_from_name": "test",
"pre_from_mail": "test@test.com",
"pre_subject": "test",
"template_content": "预设邮件模版内容,必填,自定义变量如{{self}},验证码是{{code}}",
"pre_param_map": {
"self": "这里是self变量预设值"
}
}]
},
"pwa_config": {
"pwa_platform": "xx",
"pwa_code": "xx"
}
}
Request Parameters
A request object is expressed in JSON format, so the request header must include Content-Type: application/json.
| Parameter | Type | Option | Description |
|---|---|---|---|
| template_id | String | Required | Custom template ID that must be unique, limited to 128 characters |
| description | String | Optional | Template description, limited to 255 characters |
| send_channel_strategy | String | Required | Template strategy. A single channel can be whatsapp, sms, email, or voice. Multiple channels are separated by ` |
| brand_name | String | Optional | Brand identifier. In some template styles with brand signatures, it replaces the brand signature variable. Length must be 2-10 characters |
| verify_code_config | Object | Conditionally required | Verification code configuration. Required when the template includes a verification code type |
| verify_code_config.verify_code_type | Integer | Required | Verification code type, range [1,7]: 1-numeric / 2-lowercase letters / 4-uppercase letters. Values can be combined (for example, 3 means numbers + lowercase letters) |
| verify_code_config.verify_code_len | Integer | Required | Verification code length, range [4,10] |
| verify_code_config.verify_code_ttl | Integer | Required | Verification code validity period in minutes, range [1,10]. When the strategy includes whatsapp, it can only be 1, 5, or 10 |
| whatsapp_config | Object | Conditionally required | Configuration for the WhatsApp strategy. Required when the delivery strategy includes whatsapp |
| whatsapp_config.template_type | Integer | Required | WhatsApp template type. Currently, only the default template is supported, so the value is fixed at 1 |
| whatsapp_config.template_default_config | Object | Conditionally required | WhatsApp default template configuration. Required when the WhatsApp template type is the default template |
| sms_config | Object | Conditionally required | Configuration for the SMS strategy. Required when the delivery strategy includes sms |
| sms_config.template_type | Integer | Required | SMS template type: 1-default template / 2-custom template |
| sms_config.template_default_config | Object | Conditionally required | SMS default template configuration. Required when the SMS template type is the default template |
| sms_config.template_custom_config | Object | Conditionally required | SMS custom template configuration. Required when the SMS template type is a custom template |
| sms_config.template_custom_config.custom_sub_type | String | Required | Custom template type: authentication-verification code / marketing-marketing / utility-notification |
| sms_config.template_custom_config.custom_content | String | Required | Custom template content. For the authentication type, it must include the {{code}} variable |
| sms_config.template_custom_config.custom_country_codes | String | Optional | Target country/region codes, separated by commas, used as a reference during template review |
| voice_config | Object | Conditionally required | Configuration for the voice strategy. Required when the delivery strategy includes voice |
| voice_config.template_type | Integer | Required | Voice template type. Currently, only the default template is supported, so the value is fixed at 1 |
| voice_config.template_default_config | Object | Conditionally required | Voice default template configuration. Required when the voice template type is the default template |
| email_config | Object | Conditionally required | Configuration for the email strategy. Required when the delivery strategy includes email |
| email_config.template_name | String | Required | Email template name |
| email_config.template_custom_configs | Array | Conditionally required | Email custom template configurations. Required when the email template type is a custom template. Supports multilingual configuration |
| email_config.template_custom_configs.language | String | Required | Language, where default is the default language. Different template content can be matched according to the language parameter during message delivery |
| email_config.template_custom_configs.pre_from_name | String | Optional | Preset sender name |
| email_config.template_custom_configs.pre_from_mail | String | Required | Preset sender email |
| email_config.template_custom_configs.pre_subject | String | Required | Preset email subject |
| email_config.template_custom_configs.template_content | String | Required | Email content. Supports HTML. Variables must be enclosed in {{}} |
| email_config.template_custom_configs.pre_param_map | Object | Optional | Default values for variables in the email content, declared using key-value pairs. Values must be strings |
| pwa_config | Object | Optional | PWA-related configuration. Currently optional |
| pwa_config.pwa_platform | String | Optional | The PWA platform used. Please contact technical support for the specific value |
| pwa_config.pwa_code | String | Optional | The code used within the PWA platform |
Response Parameters
| Field | Type | Option | Description |
|---|---|---|---|
| code | Integer | Required | Error code. 0 indicates success; other values indicate failure |
| message | String | Required | Response message |
Successful Response
{
"code": 0,
"message": "success"
}
Failed Response
{
"code": 3003,
"message": "not contains any channel config"
}
Error Codes
| Error Code | HTTP Code | Description |
|---|---|---|
| 1000 | 500 | Internal error |
| 2001 | 401 | Authentication failed; the correct token was not provided |
| 2002 | 401 | Authentication failed; the token has expired or has been disabled |
| 2004 | 403 | No permission to call this API |
| 3001 | 400 | Invalid request parameter format. Please check whether the request body is valid JSON that conforms to the parameter format |
| 3002 | 400 | Invalid request parameters. Please check whether the request parameters meet the requirements |
| 3003 | 400 | Business-level parameter error. Please check the description in the returned message field |
Delete Template
Endpoint
DELETE /v1/template-configs/{templateId}
Authentication
Use HTTP Basic Authentication for authentication, and add Authorization to the HTTP header:
Authorization: Basic ${base64_auth_string}
The generation algorithm for base64_auth_string above is: base64(dev_key:dev_secret)
Request Example
Request Header
DELETE /v1/template-configs/{templateId} HTTP/1.1
Authorization: Basic amlndWFuZ2RldjpkZXZfc2VjcmV0
Request Body
None
Request Parameters
{templateId} in the URL indicates the template ID to be deleted, which is defined by the caller when using the Create Template API.
Response Parameters
| Field | Type | Option | Description |
|---|---|---|---|
| code | Integer | Required | Error code. 0 indicates success; other values indicate failure |
| message | String | Required | Response message |
Successful Response
{
"code": 0,
"message": "success"
}
Failed Response
{
"code": 4001,
"message": "config not exist"
}
Error Codes
| Error Code | HTTP Code | Description |
|---|---|---|
| 1000 | 500 | Internal error |
| 2001 | 401 | Authentication failed; the correct token was not provided |
| 2002 | 401 | Authentication failed; the token has expired or has been disabled |
| 2004 | 403 | No permission to call this API |
| 3001 | 400 | Invalid request parameter format. Please check whether the request body is valid JSON that conforms to the parameter format |
| 3002 | 400 | Invalid request parameters. Please check whether the request parameters meet the requirements |
| 4001 | 400 | Template does not exist |
Get All Template Lists
This API currently does not support pagination. It returns a summary list of all templates and mainly excludes the specific content. If you need detailed content, please use the detail API.
Endpoint
GET /v1/template-configs
Authentication
Use HTTP Basic Authentication for authentication, and add Authorization to the HTTP header:
Authorization: Basic ${base64_auth_string}
The generation algorithm for base64_auth_string above is: base64(dev_key:dev_secret)
Request Example
Request Header
GET /v1/template-configs HTTP/1.1
Authorization: Basic amlndWFuZ2RldjpkZXZfc2VjcmV0
Request Body
None
Request Parameters
None
Successful Response
[{
"template_id": "test-template-1",
"description": "测试模版1",
"send_channel_strategy": "whatsapp|sms",
"brand_name": "品牌名称",
"verify_code_config": {
"verify_code_type": 1,
"verify_code_len": 6,
"verify_code_ttl": 1
},
"whatsapp_config": {
"template_type": 1
},
"sms_config": {
"template_type": 2,
"template_parts": 1
},
"voice_config": {
"template_type": 1
},
"email_config": {
"template_name": "email模板名称"
},
"pwa_config": {
"pwa_platform": "xx",
"pwa_code": "xx"
},
"created_time": 1234567890,
"status": 1,
"audit_remark": "xx"
}]
Failed Response
{
"code": 4001,
"message": "config not exist"
}
Error Codes
| Error Code | HTTP Code | Description |
|---|---|---|
| 1000 | 500 | Internal error |
| 2001 | 401 | Authentication failed; the correct token was not provided |
| 2002 | 401 | Authentication failed; the token has expired or has been disabled |
| 2004 | 403 | No permission to call this API |
| 4001 | 400 | Template does not exist |
Get Template Details
Endpoint
GET /v1/template-configs/{templateId}
Authentication
Use HTTP Basic Authentication for authentication, and add Authorization to the HTTP header:
Authorization: Basic ${base64_auth_string}
The generation algorithm for base64_auth_string above is: base64(dev_key:dev_secret)
Request Example
Request Header
GET /v1/template-configs/custom-template-id HTTP/1.1
Authorization: Basic amlndWFuZ2RldjpkZXZfc2VjcmV0
Request Body
None
Request Parameters
{templateId} in the URL indicates the template ID to retrieve, which is defined by the caller when using the Create Template API.
Successful Response
{
"template_id": "test-template-1",
"description": "测试模版1",
"send_channel_strategy": "whatsapp|sms",
"brand_name": "品牌名称",
"verify_code_config": {
"verify_code_type": 1,
"verify_code_len": 6,
"verify_code_ttl": 1
},
"whatsapp_config": {
"template_type": 1
},
"sms_config": {
"template_type": 2,
"template_parts": 1,
"template_custom_config": {
"custom_sub_type": "authentication",
"custom_content": "xxx"
}
},
"voice_config": {
"template_type": 1
},
"email_config": {
"template_name": "email模板名称",
"template_custom_configs": [{
"language": "default",
"pre_from_name": "test",
"pre_from_mail": "test@test.com",
"pre_subject": "test",
"template_content": "预设邮件模版内容,必填,自定义变量如{{self}},验证码是{{code}}",
"pre_param_map": {
"self": "这里是self变量预设值"
}
}]
},
"pwa_config": {
"pwa_platform": "xx",
"pwa_code": "xx"
},
"created_time": 1234567890,
"status": 1,
"audit_remark": "xx"
}
Failed Response
{
"code": 4001,
"message": "config not exist"
}
Error Codes
| Error Code | HTTP Code | Description |
|---|---|---|
| 1000 | 500 | Internal error |
| 2001 | 401 | Authentication failed; the correct token was not provided |
| 2002 | 401 | Authentication failed; the token has expired or has been disabled |
| 2004 | 403 | No permission to call this API |
| 4001 | 400 | Template does not exist |










