短信模版

最新更新: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 
 }

        
此代码块在浮窗中显示
在文档中心打开