跳转到内容
返回官网

创建短信模板

短信模板创建接口

模板说明

1). 模板示例如下:
模版1:亲爱的,您的订单${tid}已发送。
模版2:亲爱的${receiverName},您的订单${tid}已发送。
注意:短信内容涉及到消费者隐私信息,需要对隐私信息进行脱敏处理
2). 短信模版内容均需遵循如下短信内容安全要求:
- 短信内容不允许出现涉黄涉政涉暴及其他违反国家相关法律法规的内容。
- 短信内容中涉及消费者相关信息的内容需要进行脱敏处理,该等内容包含但不限于:订单编号、买家NICK、商品SKU相关信息等,脱敏规则及变量名称定义如下:
(1)订单编号:变量名称统一为tid,变量值只显示前四位,其余部分用*号代替,只保留两位**。(如:您的订单编号12345678901,脱敏后:您的订单编号:1234**)。
(2)运单号:变量名称统一为outSid,变量值只显示后四位。(如:您的运单号12345674321的订单,脱敏后:您的运单尾号:4321)。
(3)买家nick:变量名称统一为buyerNick,变量值第一个字符为明文,其余部份用*号代替, 只保留两位**。(如:买家123,脱敏后:买**)。
(4)收货人姓名:变量名称统一为receiverName,变量值第一个字符为明文,其余部份用*号代替,只保留两位**(如:淘某某,脱敏后:淘**)。
(5)商品SKU相关信息:商品SKU信息(商品名称等)统一只允许显示“商品”两个字,不允许展现SKU名称及金额等信息,详情引导去系统里查看,短信只做通知使用。
-短信内容只允许嵌入经过业务安全审核的特定范围域名,变量名称统一为url, url参数值中的域名仅限于:taobao.com, tmall.com,tmall.hk,g.alicdn.com,taobao.net,tmall.net,etao.com,m.duanqu.com,s.tb.cn,c.tb.cn

一、请求参数

请求URL:

POST https://kf.fw199.com/gateway/taobao/jst/sms/template/create

参数名类型必须示例值说明
appidStringtrueuwkahf@jfs92合作伙伴AppId
timestampStringtrue1633618722当前时间戳
tb_seller_nickStringtruekingdo淘宝卖家店铺登录账号,非店铺名称
signStringtrue999de41d862efaa6f1084ead3b3ba480如何计算生成见示例代码
sms_template_for_isv_requesttrue见示例创建签名入参
template_typeNumbertrue10–验证码 1–短信通知 2– 推广短信 3–国际/港澳台消息
template_type_classStringtrueNORMALNORMAL – 普通模板 DIGITAL–数字短信模板
remarkStringtrue场景说明使用场景说明
template_nameStringtruexxx旗舰店双11活动模板模板名称
template_contentStringtrue您好,你的验证码为${code}模板内容,占位符用${}标识
– template_infosDigitalSmsTemplateContentDTO[]false上传的证明文件
—- file_nameStringfalse文件名称
—- file_sizeStringfalse文件大小
—- file_suffixStringfalse文件后缀名
—- file_contentsStringfalse文件Base64转码后的字符串

sms_template_for_isv_request请求的json示例

{
"template_infos": [
{
"file_name": "模板公众号证明文件",
"file_contents": "base64文件编码内容"
}
],
"template_name": "BXG-订单验证码",
"template_content": "您好,您的订单已经发货,收货时出示收货码:${code}给师傅",
"template_type_class": "NORMAL",
"template_type": "1",
"remark": "给买家发送BXG订单验证码"
}

二、请求示例代码

Java

@Test
public void JstSmsTemplateCreateRequest() throws Exception {
Map<String, String> data = new HashMap<String, String>();
data.put("appid", Config.AppId);
Long timestamp = System.currentTimeMillis() / 1000;
data.put("timestamp", timestamp.toString());
data.put("tb_seller_nick", Config.TBSellerNick);
JSONObject jsonObject = new JSONObject();
jsonObject.put("template_type", "1");
jsonObject.put("template_type_class", "NORMAL");
jsonObject.put("remark", "给买家发送BXG订单验证码");
jsonObject.put("template_name", "BXG-订单验证码");
jsonObject.put("template_content", "您好,您的订单已经发货,收货时出示收货码:${code}给师傅");
// 如果有需要,可以上传证明文件
// JSONArray files = new JSONArray();
// JSONObject fileItem = new JSONObject();
// fileItem.put("file_name", "模板公众号证明文件");
// String base64ImageLogo = Utils.getBase64ImageFromBinary("/Users/demo/Downloads/bl.jpg");
// fileItem.put("file_contents", base64ImageLogo);
// files.add(fileItem);
// jsonObject.put("template_infos", files);
data.put("sms_template_for_isv_request", jsonObject.toJSONString());
// 签名
data.put("sign", Utils.Sign(data,Config.AppSecret));
// 调用服务API
doHttpRequest(Config.JstSmsTemplateCreateRequestUrl ,data);
}

三、返回结果

返回成功的情况

{
"code": 0,
"message": "ok",
"data": {
"module": "SMS_257051849",
"r_success": true,
"request_id": "15s5fy0z3mk5u"
},
"trace_id": ""
}

返回失败的情况

{
"code": 202,
"message": "模板名重复。",
"trace_id": ""
}

四、返回参数说明

名称类型示例值描述
r_codeStringsign_name_duplicate错误CODE
r_successBooleantrue请求是否成功
moduleStringSMS_257051849模板代码Code
messageString签名重复失败原因

说明: code为0表示成功,非0为失败,message会包含失败原因。业务成功根据r_success字段来判断