Email Template

อัพเดทล่าสุด :2023-03-14

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)

Basic information of returned email template

URL

https://email.api.engagelab.cc/v1/templates
          https://email.api.engagelab.cc/v1/templates

        
โค้ดนี้โชว์เป็นหน้าต่างลอย

HTTP Request Method

GET
          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
template_Type int no Type of email Type: 0 (trigger), 1 (batch)

Request Example

curl -X GET -H 'Content-Type: application/json; charset=utf-8' -H 'Authorization: YXBpX3VzZXI6YXBpX2tleQ==' 'https://email.api.engagelab.cc/v1/templates?offset=0&limit=3'
          curl -X GET -H 'Content-Type: application/json; charset=utf-8' 
     -H 'Authorization: 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
template_Type template Type
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", "template_Type": 1, "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 }
          
{
    "result":  [{
                "template_id": 82522,
                "name": "dffddf",
                "template_invoke_name": "dffdfd",
                "template_Type": 1,
                "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" }
          {
    "code": 30202,
    "message": "Invalid template_invoke_name"
}

        
โค้ดนี้โชว์เป็นหน้าต่างลอย

Query

Detailed information of returned email template

URL

https://email.api.engagelab.cc/v1/templates/{template_id}
          https://email.api.engagelab.cc/v1/templates/{template_id}

        
โค้ดนี้โชว์เป็นหน้าต่างลอย

HTTP Request Method

DELETE
          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: YXBpX3VzZXI6YXBpX2tleQ==' 'https://email.api.engagelab.cc/v1/templates/11111111'
          curl -X DELETE -H 'Content-Type: application/json; charset=utf-8' 
     -H 'Authorization: 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
template_Type template Type
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", "template_Type": 0, "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" } }
          
{
     "result":{
            "template_id": 76707,
            "name": "libo01s",
            "template_invoke_name": "libo01d",
            "template_Type": 0,
            "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" }
          {
    
    "code": 30202,
    "message": "Invalid template_invoke_name"
}

        
โค้ดนี้โชว์เป็นหน้าต่างลอย

Add

URL

https://email.api.engagelab.cc/v1/templates
          https://email.api.engagelab.cc/v1/templates

        
โค้ดนี้โชว์เป็นหน้าต่างลอย

Content-Type:

Content-Type: application/json;charset=utf-8
          Content-Type: application/json;charset=utf-8

        
โค้ดนี้โชว์เป็นหน้าต่างลอย

HTTP Request Method

POST
          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.
template_Type int yes template Type: 0 (trigger), 1 (batch)
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: YXBpX3VzZXI6YXBpX2tleQ==' --data '{"name": "template-name", "template_invoke_name": "myCustomTemplate", "template_Type": 0, "html": "xxx", "subject": "sususubej"}' 'https://email.api.engagelab.cc/v1/templates'
          curl -X POST -H 'Content-Type: application/json; charset=utf-8' 
     -H 'Authorization: YXBpX3VzZXI6YXBpX2tleQ==' 
     --data '{"name": "template-name", "template_invoke_name": "myCustomTemplate", "template_Type": 0, "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
template_Type template Type
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", "template_type": 0, "html": "This first template for apiv3", "subject": "xxxxxxx", "preview_text": "", "create_time": "2022-11-14T15:31:17+0800", "update_time": "" } }
          {
    "result": {
            "template_id": 82525,
            "name": "zhongg",
            "template_invoke_name": "gjtest122",
            "template_type": 0,
            "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" }
          {
    "code": 30202,
    "message": "Invalid template_invoke_name"
}

        
โค้ดนี้โชว์เป็นหน้าต่างลอย

Delete

URL

https://email.api.engagelab.cc/v1/templates/{template_id}
          https://email.api.engagelab.cc/v1/templates/{template_id}

        
โค้ดนี้โชว์เป็นหน้าต่างลอย

HTTP Request Method

DELETE
          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: YXBpX3VzZXI6YXBpX2tleQ==' 'https://email.api.engagelab.cc/v1/templates/11111111'
          curl -X DELETE -H 'Content-Type: application/json; charset=utf-8' 
     -H 'Authorization: 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 }
           { "count": 1 }

        
โค้ดนี้โชว์เป็นหน้าต่างลอย

Response-error

HTTP Status :401

{ "code": 30000, "message": "Unauthorized." }
          { 
    "code": 30000,
    "message": "Unauthorized."
}

        
โค้ดนี้โชว์เป็นหน้าต่างลอย

Modification

   Name, content, subject and Type of the template can be modified.

URL

https://email.api.engagelab.cc/v1/templates/{template_id}
          https://email.api.engagelab.cc/v1/templates/{template_id}

        
โค้ดนี้โชว์เป็นหน้าต่างลอย

Content-Type:

Content-Type: application/json;charset=utf-8
          Content-Type: application/json;charset=utf-8

        
โค้ดนี้โชว์เป็นหน้าต่างลอย

HTTP Request Method

PUT
          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.
template_Type int no template Type: 0 (transactional), 1 (marketing)
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: YXBpX3VzZXI6YXBpX2tleQ==' --data '{"template_invoke_name": "myCustomTemplate"}' 'https://email.api.engagelab.cc/v1/templates/11111111'
          curl -X PUT -H 'Content-Type: application/json; charset=utf-8' 
     -H 'Authorization: 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 }
           { 
 "count": 1 
 }

        
โค้ดนี้โชว์เป็นหน้าต่างลอย

Response-error

HTTP Status :401

{ "code": 30000, "message": "Unauthorized." }
          { 
    "code": 30000,
    "message": "Unauthorized."
}

        
โค้ดนี้โชว์เป็นหน้าต่างลอย
在文档中心打开