更新模板配置
更新已存在的模板配置,支持修改模板名称、类型、内容、发送国家及签名信息。更新后模板状态会变回"待审核"。
调用地址
PUT https://smsapi.engagelab.com/v1/template-configs/:templateId
调用验证
请参考 调用验证 了解如何进行 API 鉴权。
请求示例
请求头
PUT /v1/template-configs/123456789 HTTP/1.1
Content-Type: application/json
Authorization: Basic amlndWFuZ2RldjpkZXZfc2VjcmV0
PUT /v1/template-configs/123456789 HTTP/1.1
Content-Type: application/json
Authorization: Basic amlndWFuZ2RldjpkZXZfc2VjcmV0
此代码块在浮窗中显示
请求体
{
"template_name": "订单通知模板",
"template_type": "utility",
"template_content": "您的订单{order_no}已发货,预计{delivery_time}送达",
"country_codes": "CN,US",
"add_signature": true,
"sign_id": "987654321",
"sign_position": 2
}
{
"template_name": "订单通知模板",
"template_type": "utility",
"template_content": "您的订单{order_no}已发货,预计{delivery_time}送达",
"country_codes": "CN,US",
"add_signature": true,
"sign_id": "987654321",
"sign_position": 2
}
此代码块在浮窗中显示
请求参数
路径参数
| 参数 | 类型 | 选项 | 说明 |
|---|---|---|---|
| templateId | String | 必填 | 模板 ID |
请求体参数
| 参数 | 类型 | 选项 | 说明 |
|---|---|---|---|
| template_name | String | 必填 | 模板名称,最大 255 个字符 |
| template_type | String | 必填 | 模板类型:utility(通知类)、marketing(营销类) |
| template_content | String | 必填 | 模板内容,不能包含:【、】、、、测试、test、[、] |
| country_codes | String | 必填 | 主要发送国家代码,逗号分隔 |
| add_signature | Boolean | 可选 | 是否添加签名,默认 false |
| sign_id | String | 条件必填 | 当 add_signature 为 true 时必填,签名 ID |
| sign_position | Integer | 条件必填 | 当 add_signature 为 true 时必填,签名位置:1-前缀,2-后缀 |
返回参数
成功返回
http 状态码为 200,响应体包含字段如下:
| 字段 | 类型 | 描述 |
|---|---|---|
| code | Integer | 状态码,0 表示成功 |
| message | String | 状态描述 |
成功示例
{
"code": 0,
"message": "success"
}
{
"code": 0,
"message": "success"
}
此代码块在浮窗中显示
失败返回
http 状态码为 4xx/5xx,响应体包含字段如下:
| 字段 | 类型 | 描述 |
|---|---|---|
| code | Integer | 错误码 |
| message | String | 错误详情 |
异常示例
{
"code": 400,
"message": "can not update pending status template"
}
{
"code": 400,
"message": "can not update pending status template"
}
此代码块在浮窗中显示
错误码
| 错误码 | http code | 说明 |
|---|---|---|
| 400 | 400 | 参数错误或业务逻辑错误 |
| 500 | 500 | 服务器内部错误 |
常见错误信息:
invalid templateId:模板 ID 格式错误template config not exist:模板配置不存在can not update pending status template:待审核状态的模板不能更新there are pending or running plans using current template, can not update:存在使用该模板的待发送或运行中的计划,不能更新sign config not exist:签名配置不存在sign status is not approved, can not use:签名状态未审核通过,不能使用
注意事项
- 待审核状态的模板不能更新
- 如果存在待发送或运行中的消息计划使用该模板,则不能更新
- 更新后模板状态会变回"待审核"(status=1)
- 如果添加签名,签名必须是已审核通过状态
- 模板内容不能包含禁用字符:
【、】、、、测试、test、[、] - 模板和签名的 ID 都是字符串类型的数字
附录
模板配置状态 (status)
| 值 | 说明 |
|---|---|
| 1 | 待审核 |
| 2 | 审核通过 |
| 3 | 审核拒绝 |
模板类型 (template_type)
| 值 | 说明 |
|---|---|
| utility | 通知类 |
| marketing | 营销类 |
签名位置 (sign_position)
| 值 | 说明 |
|---|---|
| 0 | 无签名 |
| 1 | 前缀 |
| 2 | 后缀 |










