May 20, 2021 WeChat Mini Program Development Document
This interface should be called on the server side, as detailed in the Service Side API.
This interface supports cloud calls. Developer tool version required . . . 1.02.1904090 (latest stable download)
wx-server-sdk >= 0.4.0
Combine templates and add them to the personal template library under your account
How to call:
POST https://api.weixin.qq.com/wxaapi/newtmpl/addtemplate?access_token=ACCESS_TOKEN
Property | Type | The default | Required | Description |
---|---|---|---|---|
access_token | string | Is | The interface calls the credentials | |
tid | string | Is | Template title id, available via interface, or signed in to the applet background to view the get | |
kidList | Array.<number> | Is | Developers self-combined template keyword list, keyword order can be freely matched (e.g., s3, 5, 4) or s4, 5, 3), support up to 5, a minimum of 2 keyword combinations | |
sceneDesc | string | Whether | Description of the service scene, within 15 words |
The returned JSON packet
Property | Type | Description |
---|---|---|
errcode | number | Error code |
errmsg | string | The error message |
priTmplId | string | Add to the template id under your account to send the applet subscription messages you need |
The legal value of errcode
Value | Description | The lowest version |
---|---|---|
200014 | The template tid parameter is wrong | |
200020 | Keyword list KidList parameter error | |
200021 | Scene description SceneDesc parameter error | |
200011 | This account has been blocked and cannot be operated | |
200013 | This template has been blocked and cannot be selected | |
200012 | The number of personal templates has reached the upper limit, the upper limit is 25 |
content-type: application/json;
{
"tid":"401",
"kidList":[1,2],
"sceneDesc": "测试数据"
}
{
"errmsg": "ok",
"errcode": 0,
"priTmplId": "9Aw5ZV1j9xdWTFEkqCpZ7jWySL7aGN6rQom4gXINfJs"
}
Cloud call is the ability provided by the small program Cloud Development to call WeChat open interfaces in cloud functions and need to be used in cloud functions via wx-server-sdk.
openapi.subscribeMessage.addTemplate
Permissions for the subscribeMessage.addTemplate API need to be configured in config.json, details
Property | Type | The default | Required | Description |
---|---|---|---|---|
tid | string | Is | Template title id, available via interface, or signed in to the applet background to view the get | |
kidList | Array.<number> | Is | Developers self-combined template keyword list, keyword order can be freely matched (e.g., s3, 5, 4) or s4, 5, 3), support up to 5, a minimum of 2 keyword combinations | |
sceneDesc | string | Whether | Description of the service scene, within 15 words |
The returned JSON packet
Property | Type | Description |
---|---|---|
errCode | number | Error code |
errMsg | string | The error message |
priTmplId | string | Add to the template id under your account to send the applet subscription messages you need |
The legal value of errCode
Value | Description | The lowest version |
---|---|---|
0 | Success |
The exception thrown
Property | Type | Description |
---|---|---|
errCode | number | Error code |
errMsg | string | The error message |
The legal value of errCode
Value | Description | The lowest version |
---|---|---|
200014 | The template tid parameter is wrong | |
200020 | Keyword list KidList parameter error | |
200021 | Scene description SceneDesc parameter error | |
200011 | This account has been blocked and cannot be operated | |
200013 | This template has been blocked and cannot be selected | |
200012 | The number of personal templates has reached the upper limit of 25 |
content-type: application/json;
const cloud = require('wx-server-sdk')
cloud.init()
exports.main = async (event, context) => {
try {
const result = await cloud.openapi.subscribeMessage.addTemplate({
tid: '401',
kidList: [
1,
2
],
sceneDesc: '测试数据'
})
return result
} catch (err) {
return err
}
}
const cloud = require('wx-server-sdk')
cloud.init()
exports.main = async (event, context) => {
try {
const result = await cloud.openapi.subscribeMessage.addTemplate({
errmsg: 'ok',
errcode: 0,
priTmplId: '9Aw5ZV1j9xdWTFEkqCpZ7jWySL7aGN6rQom4gXINfJs'
})
return result
} catch (err) {
return err
}
}