更新範本設定
更新已存在的範本設定,支援修改範本名稱、類型、內容、發送國家及簽名資訊。更新後範本狀態會變回"待審核"。
呼叫位址
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 | 後綴 |










