Email Template
Email template allows developers to send emails with similar content to different customers.
You can query, add, delete and modify templates with API.
Call Address
| Data Center | URL |
|---|---|
| Singapore | https://email.api.engagelab.cc |
| Turkey | https://emailapi-tr.engagelab.com |
When using the REST API, ensure that the selected data center corresponds to the appropriate base URL.
POST/v1/templates
Query (Batch)
Basic information of returned email template
URL
https://email.api.engagelab.cc/v1/templates
HTTP Request Method
GET
Header
| Header | Type | Required | Description |
|---|---|---|---|
| Authorization | String | true | Basic base64(api_user:api_key) |
Query Parameter Description
| Parameter | Type | Required or not | Description |
|---|---|---|---|
| offset | int | no | offset position, [0-], defaults to 0 |
| limit | int | no | amount, [0-100],defaults to 100 |
| name | string | name | name of email template |
| template_invoke_name | string | no | name of calling email template |
Request Example
curl -X GET -H 'Content-Type: application/json; charset=utf-8'
-H 'Authorization:Basic YXBpX3VzZXI6YXBpX2tleQ=='
'https://email.api.engagelab.cc/v1/templates?offset=0&limit=3'
Return Value Description
| Parameter | Description |
|---|---|
| template_id | id of template |
| name | name of template |
| template_invoke_name | name of the calling template |
| html | content in html format |
| preview_text | preview_text of template |
| subject | subject of template |
| create_time | time of template creation |
| update_time | time of template modification |
Returned Value Example
Response-success
HTTP Status: 200
{
"result": [{
"template_id": 82522,
"name": "dffddf",
"template_invoke_name": "dffdfd",
"html": null,
"text": null,
"subject": "fdfdfd😅🙂🙂🙂🙂",
"preview_text": "",
"create_time": "2022-11-10 15:47:05",
"update_time": "2022-11-10 15:47:05"
}]
,
"count":10,
"total":20
}
Response-error
HTTP Status :400
{
"code": 30202,
"message": "Invalid template_invoke_name"
}
Query
Detailed information of returned email template
URL
https://email.api.engagelab.cc/v1/templates/{template_id}
HTTP Request Method
DELETE
Header
| Header | Type | Required | Description |
|---|---|---|---|
| Authorization | String | true | Basic base64(api_user:api_key) |
Request Example
curl -X DELETE -H 'Content-Type: application/json; charset=utf-8'
-H 'Authorization:Basic YXBpX3VzZXI6YXBpX2tleQ=='
'https://email.api.engagelab.cc/v1/templates/11111111'
Return Value Description
| Parameter | Description |
|---|---|
| template_id | template ID |
| name | template name |
| template_invoke_name | name of the calling template |
| html | template content |
| preview_text | preview_text of email content |
| subject | subject of email content |
| create_time | time of template creation |
| update_time | time of template modification |
Returned Value Example
Response-success
HTTP Status: 200
{
"result":{
"template_id": 76707,
"name": "libo01s",
"template_invoke_name": "libo01d",
"html": "The is first email",
"text": null,
"subject": "happyaaa",
"preview_text": "",
"create_time": "2019-07-22T11:52:45+0800",
"update_time": "2019-08-01T11:29:19+0800"
}
}
Response-error
HTTP Status :400
{
"code": 30202,
"message": "Invalid template_invoke_name"
}
Add
URL
https://email.api.engagelab.cc/v1/templates
Content-Type:
Content-Type: application/json;charset=utf-8
HTTP Request Method
POST
Request Header
| Header | Type | Required | Description |
|---|---|---|---|
| Authorization | String | true | Basic base64(api_user:api_key) |
Body Parameter Description
| Parameter | Type | Required or not | Description |
|---|---|---|---|
| name | string | yes | template name. Maximum length of 32 characters. |
| template_invoke_name | string | yes | name of the calling template. 4~64 characters. |
| html | string | yes | content in html format |
| text | string | no | content in html format |
| subject | string | yes | template subject .The maximum length is 255 characters, and emoji are supported. |
| preview_text | string | 否 | template preview. The maximum length is 255 characters. |
Tips:
- Variables are allowed in html content.
- The total size of an email message must not exceed 70MB when sending.
Request Example
curl -X POST -H 'Content-Type: application/json; charset=utf-8'
-H 'Authorization:Basic YXBpX3VzZXI6YXBpX2tleQ=='
--data '{"name": "template-name", "template_invoke_name": "myCustomTemplate", "html": "xxx", "subject": "sususubej"}'
'https://email.api.engagelab.cc/v1/templates'
Returned Value Description
| Parameter | Description |
|---|---|
| template_id | template ID |
| name | template name |
| template_invoke_name | name of the calling template |
| html | template content |
| text | template text |
| subject | template subject |
| create_time | time of template creation |
| update_time | time of template modification |
Returned Value Example
Response-success
HTTP Status: 200
{
"result": {
"template_id": 82525,
"name": "zhongg",
"template_invoke_name": "gjtest122",
"html": "This first template for apiv3",
"subject": "xxxxxxx",
"preview_text": "",
"create_time": "2022-11-14T15:31:17+0800",
"update_time": ""
}
}
Response-error
HTTP Status :400
{
"code": 30202,
"message": "Invalid template_invoke_name"
}
Delete
URL
https://email.api.engagelab.cc/v1/templates/{template_id}
HTTP Request Method
DELETE
Request Header
| Header | Type | Required | Description |
|---|---|---|---|
| Authorization | String | true | Basic base64(api_user:api_key) |
Request Example
curl -X DELETE -H 'Content-Type: application/json; charset=utf-8'
-H 'Authorization:Basic YXBpX3VzZXI6YXBpX2tleQ=='
'https://email.api.engagelab.cc/v1/templates/11111111'
Returned Value Description
| Parameter | Description |
|---|---|
| count | count of deleted templates |
Returned Value Example
Response-success
HTTP Status: 200
{ "count": 1 }
Response-error
HTTP Status :401
{
"code": 30000,
"message": "Authentication failed."
}
Modification
Name, content, subject and Type of the template can be modified.
URL
https://email.api.engagelab.cc/v1/templates/{template_id}
Content-Type:
Content-Type: application/json;charset=utf-8
HTTP Request Method
PUT
Request Header
| Header | Type | Required | Description |
|---|---|---|---|
| Authorization | String | true | Basic base64(api_user:api_key) |
Body Parameter Description
| Parameter | Type | Required or not | Description |
|---|---|---|---|
| name | string | no | template name. Maximum length of 32 characters. |
| template_invoke_name | string | no | name of the calling template. 4~64 characters. |
| html | string | no | content in html format |
| text | string | no | content in text format |
| subject | string | no | template subject. The maximum length is 255 characters, and emoji are supported. |
| preview_text | string | no | template preview.The maximum length is 255 characters. |
Tips:
- Variables are allowed in html content.
- When sending, the total size of the message should not exceed 70MB.
Request Example
curl -X PUT -H 'Content-Type: application/json; charset=utf-8'
-H 'Authorization:Basic YXBpX3VzZXI6YXBpX2tleQ=='
--data '{"template_invoke_name": "myCustomTemplate"}'
'https://email.api.engagelab.cc/v1/templates/11111111'
Request Example
| Parameter | Description |
|---|---|
| count | count of modified templates |
Returned Value Example
Response-success
HTTP Status: 200
{
"count": 1
}
Response-error
HTTP Status :401
{
"code": 30000,
"message": "Authentication failed."
}








