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.
Query (Batch Query)
Basic information of returned email template
URL
https://api.sendcloud.net/apiv2/template/list
HTTP Request Method
post get
Parameter Description
parameter | type | required or not | description |
---|---|---|---|
apiUser | string | yes | API_USER |
apiKey | string | yes | API_KEY |
invokeName | string | no | name of calling email template |
templateType | int | no | type of email type: 0 (transactional), 1 (marketing) |
start | int | no | start position, [0-], defaults to 0 |
limit | int | no | amount, [0-100],defaults to 100 |
Request Example
https://api.sendcloud.net/apiv2/template/list?apiUser=***&apiKey=***&start=0&limit=3
Return Value Description
parameter | description |
---|---|
name | template name |
invokeName | name of the calling template |
templateType | template type |
gmtCreated | time of template creation |
gmtModified | time of template modification |
Returned Value Example
{
"info": {
"dataList": [
{
"name": "ifaxin账单",
"invokeName": "***",
"templateType": 1,
"gmtCreated": "2013-11-21 16:37:41",
"gmtUpdated": "2015-06-12 19:44:07"
},
{
"name": "ifaxin密码找回",
"invokeName": "***",
"templateType": 0,
"gmtCreated": "2013-11-21 16:39:53",
"gmtUpdated": "2013-11-21 16:39:53"
}
],
"total": 42,
"count": 2
},
"statusCode": 200,
"message": "请求成功",
"result": true
}
Query
Detailed information of returned email template
URL
https://api.sendcloud.net/apiv2/template/get
HTTP Request Method
post get
Parameter Description
parameter | type | required or not | description |
---|---|---|---|
apiUser | string | yes | API_USER |
apiKey | string | yes | API_KEY |
invokeName | string | yes | name of the calling email template |
Request Example
https://api.sendcloud.net/apiv2/template/get?apiUser=***&apiKey=***&invokeName=test
Returned Value Description
parameter | description |
---|---|
name | template name |
invokeName | name of the calling template |
templateType | template type |
gmtCreated | time of template creation |
gmtModified | time of template modification |
html | template content |
contentSummary | summary of email content |
subject | template subject |
Returned Value Example
{
"statusCode": 200,
"info": {
"data": {
"name": "SendCloud测试样本",
"invokeName": "15_invoke_2",
"templateType": 0,
"templateStat": 1,
"gmtCreated": "2015-02-02 17:01:43",
"gmtUpdated": "2015-04-16 15:04:12",
"html": "<p>你太棒了!你已成功的从SendCloud发送了一封测试邮件,接下来快登录前台去完善账户信息吧!12</p>\n",
"subject": "来自SendCloud的第一封邮件!",
"contentSummary":"shesh"
}
},
"message": "请求成功",
"result": true
}
Add
URL
https://api.sendcloud.net/apiv2/template/add
HTTP Request Method
post get
parameter | type | required or not | description |
---|---|---|---|
apiUser | string | yes | API_USER |
apiKey | string | yes | API_KEY |
invokeName | string | yes | name of the calling template |
name | string | yes | template name |
html | string | yes | content in html format |
text | string | no | content in text format |
subject | string | yes | template subject |
templateType | int | yes | template type: 0 (triggered), 1 (bulk) |
Tips:
- Variables are allowed in html content.
- post is required when html content is too long or contains special characters.
- Templates should not be more than 1,000.
Request Example
curl -d 'apiUser=***&apiKey=***&invokeName=testtemplate&name=test&html=<p>add new template</p>&subject=test_subject&templateType=1' https://api.sendcloud.net/apiv2/template/add
Returned Value Description
parameter | description |
---|---|
name | template name |
invokeName | name of the calling template |
templateType | template type |
templateStat | template status |
gmtCreated | time of template creation |
gmtModified | time of template modification |
html | template content |
subject | template subject |
Returned Value Example
{
"statusCode": 200,
"info": {
"data": {
"name": "test",
"invokeName": "testtemplate",
"templateType": 0,
"templateStat": 0,
"gmtCreated": "2015-10-16 10:42:01",
"gmtUpdated": "",
"html": "<p>add new template</p>",
"subject": "test_subject"
}
},
"message": "请求成功",
"result": true
}
Delete
URL
https://api.sendcloud.net/apiv2/template/delete
Parameter Description
post get
Parameter Description
parameter | type | required or not | description |
---|---|---|---|
apiUser | string | yes | API_USER |
apiKey | string | yes | API_KEY |
invokeName | string | * | name of the calling template |
startDate | string | * | The start update date of the mail template to be deleted, in the format of yyyy MM DD , starting from 00:00:00 of the current day |
endDate | string | * | The end update date of the mail template to be deleted, in the format yyyy MM DD , starts at 23:59:59 of the end day |
Tips: 1. At least one item needs to be filled in for invokeName and the mail template update time interval, both of which are dominated by the invokeName.
Request Example
curl https://api.sendcloud.net/apiv2/template/delete?apiUser=***&apiKey=***&invokeName=test
Returned Value Description
parameter | description |
---|---|
count | count of deleted templates |
Returned Value Example
{
"statusCode": 200,
"message": "请求成功",
"result": true,
"info": {
"count": 1
}
}
Modification
Name, content, subject and type of the template can be modified.
URL
https://api.sendcloud.net/apiv2/template/update
HTTP Request Mode
post get
parameter | type | required or not | description |
---|---|---|---|
apiUser | string | yes | API_USER |
apiKey | string | yes | API_KEY |
invokeName | string | yes | name of the calling template |
name | string | no | template name |
html | string | no | content in html format |
subject | string | no | template subject |
templateType | int | no | template type: 0 (transactional), 1 (marketing) |
Tips:
- Variables are allowed in html content.
- post request is required when html content is too long or contains
Request Example
curl -d 'apiUser=***&apiKey=***&invokeName=testtemplate&name=test&html=<p>update template</p>&subject=test&templateType=1' http://api.sendcloud.net/apiv2/template/update
Returned Value Description
parameter | description |
---|---|
count | count of modified templates |
Returned Value Example
{
"statusCode": 200,
"message": "请求成功",
"result": true,
"info": {
"count": 1
}
}