郵件模板管理

最新更新:2023-03-14

開發者利用模板,可以方便的為不同用戶批量發送相似內容。

通過 API 可以對郵件模板進行査詢,添加,删除,修改操作。

查詢 ( 批量查詢 )

返回郵件模板的基本資訊

URL

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

        
此代碼塊在浮窗中顯示

HTTP 請求方式

GET
          GET

        
此代碼塊在浮窗中顯示

請求 Header

Header 類型 必須 説明
Authorization string true Basic base64(api_user:api_key)

Query 参数

参数 類型 必須 説明
offset int 査詢起始位置,取值區間 [0-],默認為 0。
limit int 査詢個數,取值區間 [0-100],默認為 100。
name string 郵件模板名稱。 模糊查詢。
template_invoke_name string 郵件模板調用名稱。 精確查詢。
template_type int 郵件模板類型:0(觸發)、1(批量)。

請求示例(xjm)

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'

        
此代碼塊在浮窗中顯示

响应説明

字段 説明
template_id 模板 ID
name 郵件模板名稱
template_invoke_name 郵件模板調用名稱
template_type 模板類型
html 模板內容
preview_text 模板摘要
subject 模板主題
create_time 郵件模板創建時間
update_time 郵件模板創建時間

響應示例

Response-success

HTTP Status: 200

{ "result": [{ "template_id": 82522, "name": "dffddf", "template_invoke_name": "dffdfd", "template_type": 1, "html": "<p>123445</p>", "subject": "fdfdfd😅🙂🙂🙂🙂", "preview_text": "", "create_time": "2022-11-10T15:47:05+0800", "update_time": "2022-11-10T15:47:05+0800" }] , "count":10, "total":20 }
          {
    "result":  [{
                "template_id": 82522,
                "name": "dffddf",
                "template_invoke_name": "dffdfd",
                "template_type": 1,
                "html": "<p>123445</p>",
                "subject": "fdfdfd😅🙂🙂🙂🙂",
                "preview_text": "",
                "create_time": "2022-11-10T15:47:05+0800", 
                "update_time": "2022-11-10T15:47:05+0800"
            }]
     ,
     "count":10,
     "total":20
}

        
此代碼塊在浮窗中顯示

Response-error

HTTP Status :400

{ "code": 30202, "message": "Invalid template_invoke_name" }
          {
    "code": 30202,
    "message": "Invalid template_invoke_name"
}

        
此代碼塊在浮窗中顯示

查詢

返回單個郵件模板的詳細資訊

URL

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

        
此代碼塊在浮窗中顯示

HTTP 請求方式

GET
           GET

        
此代碼塊在浮窗中顯示

請求 Header

Header 類型 必須 説明
Authorization string true Basic base64(api_user:api_key)

請求示例

curl -X GET -H 'Content-Type: application/json; charset=utf-8' -H 'Authorization: YXBpX3VzZXI6YXBpX2tleQ==' 'https://email.api.engagelab.cc/v1/templates/11111111'
          curl -X GET -H 'Content-Type: application/json; charset=utf-8' 
     -H 'Authorization: YXBpX3VzZXI6YXBpX2tleQ==' 
     'https://email.api.engagelab.cc/v1/templates/11111111'

        
此代碼塊在浮窗中顯示

响应説明

字段 説明
template_id 模板 ID
name 邮件模板名称
template_invoke_name 邮件模板调用名称
template_type 模板類型
html 模板内容
preview_text 邮件摘要
subject 模板标题
create_time 邮件模板创建时间
update_time 邮件模板创建时间

響應示例

Response-success

HTTP Status: 200

{ "result":{ "template_id": 76707, "name": "libo01s", "template_invoke_name": "libo01d", "template_type": 0, "html": "The is first email", "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",
            "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"
}

        
此代碼塊在浮窗中顯示

添加

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 請求方式

POST
          POST

        
此代碼塊在浮窗中顯示

請求 Headers

Header 類型 必須 説明
Authorization string true Basic base64(api_user:api_key)

Body 参数

参数 類型 必須 説明
name string 郵件模板名稱。 最長 32 字符。
template_invoke_name string 郵件模板調用名稱。 4~64 字符。
template_type int 郵件模板類型:0(觸發),1(批量)。
html string html 格式內容
subject string 模板標題。 最長 255 字符,支持 emoji。
preview_text string 模板摘要。 最長 255 字符。

注意:

  1. html 內容中可以使用變數。
  2. 發送時郵件總大小不得超過 70MB。

請求示例

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'

        
此代碼塊在浮窗中顯示

响应説明

字段 説明
template_id 模板 ID
name 郵件模板名稱
template_invoke_name 郵件模板調用名稱
template_type 模板類型
preview_text 郵件摘要
html 模板 html 格式內容
subject 模板標題
create_time 郵件模板創建時間
update_time 郵件模板修改時間

響應示例

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"
}

        
此代碼塊在浮窗中顯示

刪除

URL

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

        
此代碼塊在浮窗中顯示

HTTP 請求方式

DELETE
          DELETE

        
此代碼塊在浮窗中顯示

請求 Headers

Header 類型 必須 説明
Authorization string true Basic base64(api_user:api_key)

請求示例

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'

        
此代碼塊在浮窗中顯示

响应説明

参数 説明
count 成功删除的郵件模板個數

響應示例

Response-success

HTTP Status: 200

{ "count": 1 }
           { "count": 1 }

        
此代碼塊在浮窗中顯示

Response-error

HTTP Status :401

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

        
此代碼塊在浮窗中顯示

修改

用於修改模板的名稱,內容,主題,模板類型

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 請求方式

PUT
          PUT

        
此代碼塊在浮窗中顯示

請求 Headers

Header 類型 必須 説明
Authorization string true Basic base64(api_user:api_key)

Body 参数

参数 類型 必須 説明
name string 郵件模板名稱。 最長 32 字符。
template_invoke_name string 郵件模板調用名稱。 4~64 字符。
template_type int 郵件模板類型:0(觸發),1(批量)。
html string html 格式內容
subject string 模板標題。 最長 255 字符,支持 emoji。
preview_text string 郵件摘要。 最長 255 字符。

注意:

  1. html 內容中可以使用變數。
  2. 發送時郵件總大小不得超過 70MB。

請求示例

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'

        
此代碼塊在浮窗中顯示

响应説明

参数 説明
count 成功修改的模板數量

響應示例

Response-success

HTTP Status: 200

{ "count": 1 }
           { 
 "count": 1 
 }

        
此代碼塊在浮窗中顯示

Response-error

HTTP Status :401

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

        
此代碼塊在浮窗中顯示
在文档中心打开