Tag Management API
Back

From WeChat Official Account Admin Platform
Jump to: navigation, search

Developers can call the APIs on the Admin Platform to query, create, change a tag or change a user's Tags.

Contents

Tags Management

Create Tags

An official account supports up to 100 tags.

Request Description

HTTP request method: POST (Use Https protocol)
https://api.wechat.com/cgi-bin/tags/create?access_token=ACCESS_TOKEN
POST data format: JSON
Example: {"tag":{"name":"test"}}

Parameter Description

Parameter Description
access_token The certificate for the calling API
name Tag name (up to 30 characters)

An example of a successful JSON response is as follows:

{
    "tag": {
        "id": 107, 
        "name": "test"
    }
}

Parameter Description

Parameter Description
id Tag ID, assigned by WeChat
name Tag name (UTF8)

Error Codes

Error Code Description
-1 System busy
45157 Invalid tag name, cannot be the same as other tags
45158 More than 30 bytes contained in the tag name
45056 Excessive tags created, cannot be more than 100


Query Tags

Request Description

HTTP request method: GET (Use Https protocol)
https://api.wechat.com/cgi-bin/tags/get?access_token=ACCESS_TOKEN

Parameter Description

Parameter Description
access_token The certificate for the calling API

An example of a successful JSON response is as follows:

{
   "tags": [
       {
           "id": 0, 
           "name": " UnTaged", 
           "count": 72596
       }, 
       {
           "id": 1, 
           "name": " Blacklist", 
           "count": 36
       }, 
       {
           "id": 2, 
           "name": " Starred", 
           "count": 8
       }, 
       {
           "id": 104, 
           "name": " East China media", 
           "count": 4
       }, 
       {
           "id": 106, 
           "name": "★Do Not Test★", 
           "count": 1
       }
   ]
}

Editing Tags

Request Description

HTTP request method: POST (Use Https protocol)
https://api.wechat.com/cgi-bin/tags/update?access_token=ACCESS_TOKEN
POST data format: JSON
Example: {"tag":{"id":108,"name":"test2_modify2"}}

An example of a successful JSON response is as follows:

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

Error Codes

Error Code Description
-1 System busy
45157 Invalid tag name, cannot be the same as other tags
45158 More than 30 bytes contained in the tag name
45058 Cannot modify tags 0, 1, and 2 (reserved by the system by default)


Deleting Tags

Note: If the number of followers configured with a tag exceeds 100,000, the tag cannot be directly deleted. To delete the tag, developers must cancel the tag for followers in the OpenID list till the number of followers is less than 100,000.

Request Description

HTTP request method: POST (Use Https protocol)
https://api.wechat.com/cgi-bin/tags/delete?access_token=ACCESS_TOKEN
POST data format: JSON
Example: {"tag":{"id":108}}

An example of a successful JSON response is as follows:

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

Error Codes

Error Code Description
-1 System busy
45058 Cannot modify tags 0, 1, and 2 (reserved by the system by default)
45057 Cannot directly delete the tag because the number of followers exceeds 100,000


Obtaining the List of Followers Configured with a Tag

Request Description

HTTP request method: POST (Use Https protocol)
https://api.wechat.com/cgi-bin/user/tag/get?access_token=ACCESS_TOKEN
POST data format: JSON
Example: {"tag":{"id":108,"next_openid":"" //The first OPENID,do not fill default from scratch}}

An example of a successful JSON response is as follows: {

 "count":2,
 "data":{
 "openid":[
   "ocYxcuAEy30bX0NXmGn4ypqx3tI0",
   "ocYxcuBt0mRugKZ7tGAHPnUaOW7Y"
   ]
 },
 "next_openid":"ocYxcuBt0mRugKZ7tGAHPnUaOW7Y"//The openid of the last user of the list

}


Error Codes

Error Code Description
-1 System busy
40003 Invalid Open ID
45159 Invalid tag_id


User Management

The "User Tags" feature allows official accounts to configure up to three tags for a user.

Configuring Tags for Users in Batches

Request Description

HTTP request method: POST (Use Https protocol)
https://api.wechat.com/cgi-bin/tags/members/batchtagging?access_token=ACCESS_TOKEN
POST data format: JSON
Example: {
 "openid_list" : [
   "ocYxcuAEy30bX0NXmGn4ypqx3tI0",
   "ocYxcuBt0mRugKZ7tGAHPnUaOW7Y"
 ],
 "tagid" : 134

}


An example of a successful JSON response is as follows:

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


Error Codes

Error Code Description
-1 System busy
40032 More than 50 OpenIDs imported to the OpenID list
45159 Invalid tag
45059 More than three tags configured for a follower
40003 Invalid OpenID imported
49003 Imported OpenID does not match the AppID


Canceling Tags for Users in Batches

Request Description

HTTP request method: POST (Use Https protocol)
https://api.wechat.com/cgi-bin/tags/members/batchuntagging?access_token=ACCESS_TOKEN
POST data format: JSON
Example: {
 "openid_list" : [
   "ocYxcuAEy30bX0NXmGn4ypqx3tI0",
   "ocYxcuBt0mRugKZ7tGAHPnUaOW7Y"
 ],
 "tagid" : 134

}


An example of a successful JSON response is as follows:

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


Error Codes

Error Code Description
-1 System busy
40032 More than 50 OpenIDs imported to the OpenID list
45159 Invalid tag
45059 More than three tags configured for a follower
40003 Invalid OpenID imported
49003 Imported OpenID does not match the AppID


Obtaining the List of Tags Configured for a User

Request Description

HTTP request method: POST (Use Https protocol)
https://api.wechat.com/cgi-bin/tags/getidlist?access_token=ACCESS_TOKEN
POST data format: JSON
Example: {
 "openid" : "ocYxcuBt0mRugKZ7tGAHPnUaOW7Y"

}


An example of a successful JSON response is as follows: {

 "tagid_list":[134,2]

}

Error Codes

Error Code Description
-1 System busy
40003 Invalid OpenID imported
49003 Imported OpenID does not match the AppID
Developer Guide
Custom-defined Menu
WeChat JS-SDK