短信模版

最新更新:2023-04-10

通過以下接口可以對短信模板進行添加、修改、刪除操作,可以對短信和彩信模板進行查詢、提交審核操作。

查詢單個模板

返回短信模板的基本信息

URL

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

        
此代碼塊在浮窗中顯示

HTTP請求方式

GET
          GET

        
此代碼塊在浮窗中顯示

Request-Headers

Header 類型 必須 說明
Authorization string true Basic base64(sms_user:sms_key)

請求示例

curl -X GET "https://sms.api.engagelab.cc/v1/templates/1235" --header "Authorization: Basic <<YOUR_SMS_KEY_HERE>>"
          curl -X GET "https://sms.api.engagelab.cc/v1/templates/1235" 
--header "Authorization: Basic <<YOUR_SMS_KEY_HERE>>"

        
此代碼塊在浮窗中顯示

響應說明

字段 說明
template_id 模板ID
template_name 模板名稱,最長64個字符
msg_type 短信類型 ,2代表國際短信
template_type 短信內容類型,0表示驗證碼,1表示行業通知,2表示營銷
approval_status 審核狀態,0表示待審核,1表示審核通過,-1表示審核不通過 ,-2表示未提審
approval_message 審核信息,僅 approval_status 為 -1 有值
template_content 模板內容,最長512個字符
sign_id 簽名ID
create_time 創建時間
update_time 更新時間

響應示例

Response-success

HTTP Status: 200

{ "result": { "template_id": 123, "template_name": "test", "msg_type": 2, "template_type": 1, "template_content": "Dear %name%,your consumption amount on the platform this month is:***", "approval_status": 1, "approval_message": "" "sign_id": 11504, "create_time": "2015-03-23T14:27:48+0800", "update_time": "2017-03-29T14:27:48+0800" } }
          {
    "result": {
        "template_id": 123,
        "template_name": "test",
        "msg_type": 2,
        "template_type": 1,
        "template_content": "Dear %name%,your consumption amount on the platform this month is:***",
        "approval_status": 1,
        "approval_message": ""
        "sign_id": 11504,
        "create_time": "2015-03-23T14:27:48+0800",
        "update_time": "2017-03-29T14:27:48+0800"
    }
}

        
此代碼塊在浮窗中顯示

Response-error

HTTP Status :400

{ "code": 33001, "message": "The template does not exist" }
          {
    "code": 33001,
    "message": "The template does not exist"
}

        
此代碼塊在浮窗中顯示

查詢多個模板

返回短信模板的基本信息

URL

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

        
此代碼塊在浮窗中顯示

HTTP請求方式

GET
          GET

        
此代碼塊在浮窗中顯示

Request-Headers

Header 類型 必須 說明
Authorization String true Basic base64(sms_user:sms_key)

參數說明

參數 類型 必須 說明
template_ids string 模板ID, 多個用;分隔
approval_status string 審核狀態,0待審核 ,1審核通過,-1審核不通過 ,-2未提審
template_name string 模板名稱,模糊匹配,最長64個字符
offset int 查詢起始位置, 取值區間 [0-], 默認為 0
limit int 查詢個數, 取值區間 [0-100], 默認為 100

注意:

  1. 用戶可指定模板ID進行查詢,未指定時,默認查詢全部模板

請求示例

curl -X GET "https://sms.api.engagelab.cc/v1/templates?approval_status=1" --header "Authorization: Basic <<YOUR_SMS_KEY_HERE>>"
          curl -X GET "https://sms.api.engagelab.cc/v1/templates?approval_status=1" 
--header "Authorization: Basic <<YOUR_SMS_KEY_HERE>>"

        
此代碼塊在浮窗中顯示

響應說明

字段 說明
template_id 模板ID
template_name 模板名稱
msg_type 業務類型
template_type 內容類型
approval_status 審核狀態
approval_message 審核信息,僅 approval_status 為 -1 有值
template_content 模板內容
sign_id 簽名
create_time 創建時間
update_time 更新時間

響應示例

Response-success

HTTP Status: 200

{ "result" : [{ "template_id" : 100, "template_name" : "tset", "msg_type" : 2, "template_type" : 1, "template_content" : "Dear %name%,your consumption amount on the platform this month is:***", "approval_status" : 1, "approval_message": "", "sign_id": 1002, "create_time" : "2016-08-25T14:27:48+0800", "update_time" : "2016-08-25T14:27:48+0800" } ], "count":1, "total" : 1 }
          {
    "result" :  [{
                "template_id" : 100,
                "template_name" : "tset",
                "msg_type" : 2,
                "template_type" : 1,
                "template_content" : "Dear %name%,your consumption amount on the platform this month is:***",
                "approval_status" : 1,
                "approval_message": "",
                "sign_id": 1002,
                "create_time" : "2016-08-25T14:27:48+0800",
                "update_time" : "2016-08-25T14:27:48+0800"
            }
        ],
        "count":1,
        "total" : 1
    }

        
此代碼塊在浮窗中顯示

Response-error

HTTP Status: 400

{ "code": 30002, "message": "invalid limit" }
          {
  "code": 30002,
  "message": "invalid limit"
}

        
此代碼塊在浮窗中顯示

添加模板

返回是否添加成功的信息

URL

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

        
此代碼塊在浮窗中顯示

HTTP請求方式

POST
          POST

        
此代碼塊在浮窗中顯示

Content-type

application/json
          application/json

        
此代碼塊在浮窗中顯示

Request-Headers

Header 類型 必須 說明
Authorization string true Basic base64(sms_user:sms_key)

參數說明

参数 類型 必須 說明
template_name string 模板名稱,賬戶內唯一,最長64個字符
template_content string 模板內容,不可包含【】、[]、測試、test等字符,最長512字符
template_type string 短信內容類型,0表示驗證碼,1表示行業通知,2表示營銷
msg_type string 業務類型,2代表國際短信,默認為2
sign_id Integer 短信簽名的ID
sign_pos string 簽名位置,0代表前置,1代表後置,默認為0
submit bool 是否直接提交審核,默認為 false

請求示例

curl -X POST "https://sms.api.engagelab.cc/v1/templates" --header "Authorization: Basic <<YOUR_SMS_KEY_HERE>>" --header "Content-Type: application/json" --data '{ "template_name": "test", "template_content": "Dear %name%,your consumption amount on the platform this month is:***", "sign_id": 1235, "template_type": "0" }'
          curl -X POST "https://sms.api.engagelab.cc/v1/templates"
--header "Authorization: Basic <<YOUR_SMS_KEY_HERE>>" 
--header "Content-Type: application/json" 
--data '{
    "template_name": "test",
    "template_content": "Dear %name%,your consumption amount on the platform this month is:***",
    "sign_id": 1235,
    "template_type": "0"
}'  

        
此代碼塊在浮窗中顯示

響應說明

字段 說明
template_id 模板ID
template_name 模板名稱
msg_type 業務類型
template_type 內容類型
approval_status 審核狀態
approval_message 審核信息,僅 approval_status 為 -1 有值
template_content 模板內容
sign_id 簽名ID
create_time 創建時間
update_time 更新時間

響應示例

Response-success

HTTP Status: 200

{ "result" : { "template_id" : 200, "template_name" : "bill", "msg_type" : 2, "template_type" : 1, "template_content" : "Dear %name%,your consumption amount on the platform this month is:***", "approval_status" : 1, "approval_message": "", "sign_id": 1235, "create_time" : "2022-08-25T14:35:48+0800", "update_time" : "2022-08-25T14:35:48+0800" } }
          {
    "result" : {
        "template_id" : 200,
        "template_name" : "bill",
        "msg_type" : 2,
        "template_type" : 1,
        "template_content" : "Dear %name%,your consumption amount on the platform this month is:***",
        "approval_status" : 1,
        "approval_message": "",
        "sign_id": 1235,
        "create_time" : "2022-08-25T14:35:48+0800",
        "update_time" : "2022-08-25T14:35:48+0800"
        
    }
}

        
此代碼塊在浮窗中顯示

Response-error

HTTP Status: 400

{ "code": 33006, "message": "Template name only supports 64 characters" }
          {
    "code": 33006,
    "message": "Template name only supports 64 characters"
}

        
此代碼塊在浮窗中顯示

提交審核

返回是否提交成功的基本信息

URL

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

        
此代碼塊在浮窗中顯示

HTTP請求方式

POST
          POST

        
此代碼塊在浮窗中顯示

Content-type

application/json
          application/json

        
此代碼塊在浮窗中顯示

Request-Headers

Header 類型 必須 說明
Authorization String true Basic base64(sms_user:sms_key)

請求示例

curl -X POST "https://sms.api.engagelab.cc/v1/templates/3381/submit" --header "Authorization: Basic <<YOUR_SMS_KEY_HERE>>" --header "Content-Type: application/x-www-form-urlencoded"
          curl -X POST "https://sms.api.engagelab.cc/v1/templates/3381/submit"
--header "Authorization: Basic <<YOUR_SMS_KEY_HERE>>" 
--header "Content-Type: application/x-www-form-urlencoded"

        
此代碼塊在浮窗中顯示

響應示例

Response-success

HTTP Status: 200

{ }
          { 
  
}

        
此代碼塊在浮窗中顯示

更新模板

返回是否提交成功的基本信息

URL

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

        
此代碼塊在浮窗中顯示

HTTP請求方式

PUT
          PUT

        
此代碼塊在浮窗中顯示

Content-type

application/json
          application/json

        
此代碼塊在浮窗中顯示

Request-Headers

Header 類型 必須 說明
Authorization String true Basic base64(sms_user:sms_key)

參數說明

参数 類型 必須 說明
template_name string 模板名稱,最長64個字符
template_content string 模板內容,不可包含【】、[]、測試、test等字符,最長512字符
sign_id Integer 短信簽名的ID
sign_pos string 簽名位置:0代表前置,1代表後置,默認為0
template_type string 短信內容類型,0表示驗證碼,1表示行業通知,2表示營銷
submit bool 是否直接提交審核,默認為 false

注意:
1.調用此接口後,更新 template_name不會導致模板審核狀態發生變化,其他參數更新會導致模板審核變化

請求示例

curl -X PUT "https://sms.api.engagelab.cc/v1/templates/3381" --header "Authorization: Basic <<YOUR_SMS_KEY_HERE>>" --header "Content-Type: application/json" --data '{ "template_name": "test", "template_content": "Dear %name%,your consumption amount on the platform this month is:***", "sign_id": 132, "template_type": 0 }'
          curl -X PUT "https://sms.api.engagelab.cc/v1/templates/3381"
--header "Authorization: Basic <<YOUR_SMS_KEY_HERE>>" 
--header "Content-Type: application/json" 
--data '{
    "template_name": "test",
    "template_content": "Dear %name%,your consumption amount on the platform this month is:***",
    "sign_id": 132,
    "template_type": 0
    }'  

        
此代碼塊在浮窗中顯示

響應示例

Response-success

HTTP Status: 200

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

        
此代碼塊在浮窗中顯示

Response-error

HTTP Status: 401

{ "code": 30000, "message": "Authentication failed" }
          {
  "code": 30000,
  "message": "Authentication failed"
}

        
此代碼塊在浮窗中顯示

删除模板

返回是否提交成功的基本信息

URL

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

        
此代碼塊在浮窗中顯示

HTTP請求方式

DELETE
          DELETE

        
此代碼塊在浮窗中顯示

Request-Headers

Header 類型 必須 說明
Authorization String true Basic base64(sms_user:sms_key)

請求示例

curl -X DELETE "https://sms.api.engagelab.cc/v1/templates/3381" --header "Authorization: Basic <<YOUR_SMS_KEY_HERE>>"
          curl -X DELETE "https://sms.api.engagelab.cc/v1/templates/3381" 
--header "Authorization: Basic <<YOUR_SMS_KEY_HERE>>"

        
此代碼塊在浮窗中顯示

響應示例

Response-success

HTTP Status: 200

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

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