# templateMessage.deleteTemplate

Call this API at the server side. For more information, see Server API.

This API supports Cloud Calls. The WeChat DevTools version must be 1.02.1904090 or later (download the latest stable version here), and the wx-server-sdk version must be 0.4.0 or later.

Deletes a template from the account.

Calling methods:

# HTTPS Call

# Request Address

POST https://api.weixin.qq.com/cgi-bin/wxopen/template/del?access_token=ACCESS_TOKEN

# Request Parameters

Attribute Type Default Required Description
access_token string Yes Credentials to call API
template_id string Yes The ID of the template to be deleted

# Return Value

# Object

JSON data package that is returned

Attribute Type Description
errcode number Error code
errmsg string Error message

# Request Data Example

{
  "template_id":"wDYzYZVxobJivW9oMpSCpuvACOfJXQIoKUm0PY397Tc"
}

# Return Data Example

{
  "errcode":0,
  "errmsg":"ok"
}

# Cloud Call

Cloud call is a capability provided by Mini Program·Cloud Base that allows you to call WeChat APIs in a cloud function. It must be used via wx-server-sdk in the cloud function.

# API Calling Method

openapi.templateMessage.deleteTemplate

You need to configure the permissions for the templateMessage.deleteTemplate API via config.json. Details

# Request Parameters

Attribute Type Default Required Description
templateId string Yes The ID of the template to be deleted

# Return Value

# Object

JSON data package that is returned

Attribute Type Description
errCode number Error code
errMsg string Error message

# Exceptions

# Object

Thrown Exceptions

Property Type Description
errCode number Error code
errMsg string Error message

Valid values of errCode

Value Description Minimum Version

# Request Data Example

const cloud = require('wx-server-sdk')
  cloud.init()
  exports.main = async (event, context) => {
    try {
      const result = await cloud.openapi.templateMessage.deleteTemplate({
        templateId: 'wDYzYZVxobJivW9oMpSCpuvACOfJXQIoKUm0PY397Tc'
      })
      console.log(result)
      return result
    } catch (err) {
      console.log(err)
      return err
    }
  }

# Return Data Example

{
  "errCode": 0,
  "errMsg": "openapi.templateMessage.deleteTemplate:ok"
}