Service URL/v3/device/tag
Parameter | Type | Required | Description |
operator_type | Integer | Yes | Operation type:
1: add a tag to a token.
2: delete a tag from a token.
3: add multiple tags to a token.
4: delete multiple tags from a token.
5: delete all tags from a token.
6: add one or more tags or custom tags to a token in an overwriting manner.
(This API starts to set new tags only after the tag history is cleared. Therefore, for the same token, it is recommended that the interval between API calls be over 1s; otherwise, the update may fail.)
7: add a tag to multiple tokens.
8: delete a tag from multiple tokens.
9: batch add tags (up to 20 pairs are allowed per call; in each tag-token pair, the tag is before the token).
10: batch delete tags (up to 20 pairs are allowed per call; in each tag-token pair, the tag is before the token). |
token_list | Array | No | Device list: Required when operator_type is 1, 2, 3, 4, 5, 6, 7, or 8. When operator_type is 1, 2, 3, 4, 5, or 6 and this parameter contains multiple tokens, only the first token will be set. Format example: ["token1","token2"] The list can contain up to 500 values. A token string cannot exceed 36 characters. |
tag_list | Array | No | Tag list: Required when operator_type is 1, 2, 3, 4, 6, 7, or 8; ignored when operator_type is 5.When operator_type is 1, 2, 7, or 8 and this parameter contains multiple tags, only the first tag will be set.Format example: ["tag1","tag2"] The list can contain up to 500 values. A tag string cannot exceed 50 characters. |
tag_token_list | Array | No | Tag-device pair list: Required when operator_type is 9 or 10.Format example: [{"tag":"tag123", "token":"token123"}] In each pair, the tag is before the token. The list can contain up to 500 values. A tag string cannot exceed 50 characters. A token string cannot exceed 36 characters. |
:
is a keyword used by the Tencent Push Notification Service backend for tag categorization. If you include :
in a tag when setting it, the string before the first :
serves as the category name of the tag. This is only used when operator_type
is 6
, which means overwriting tags by category. For example, if the existing tags of a device are level:1
, level:2
, and male
, you can directly overwrite level:1
and level:2
with level:3
without having to unbind level:1
and level:2
one by one, and then bind level:3
. For more information, please see the following sample request where operator_type
is 6
.Parameter | Type | Required | Description |
ret_code | Integer | Yes | Error code. For more information, please see the error codes table. |
err_msg | String | No | Error message when a request error occurs |
result | String | No | When the request is correct: If there is extra data to return, the result will be encapsulated in this parameter in JSON format. If there is no extra data, this parameter may not exist. |
{"operator_type": 1,"tag_list": ["tag1"],"token_list": ["token1"]}
{"operator_type": 2,"tag_list": ["tag1"],"token_list": ["token1"]}
{"operator_type": 3,"tag_list": ["tag1","tag2"],"token_list": ["token1"]}
{"operator_type": 4,"tag_list": ["tag1","tag2"],"token_list": ["token1"]}
{"operator_type": 5,"tag_list": ["tag1","tag2"],"token_list": ["token1"]}
{"operator_type": 6,"tag_list": ["test:2","level"],"token_list": ["token1"]}
:
, then the test:2
and level
tags overwrite all custom tags of token1
.{"operator_type": 6,"tag_list": ["test:2","level:2"],"token_list": ["token1"]}
:
, since the string before the first :
is the tag category, only tags in the same category bound to the device will be overwritten; for example, test:2
overwrites test:*
, and level:2
overwrites level:*
, without affecting other tags.{"operator_type": 7,"tag_list": ["tag1"],"token_list": ["token1","token2"]}
{"operator_type": 8,"tag_list": ["tag1"],"token_list": ["token1","token2"]}
{"operator_type": 9,"tag_token_list": [{"tag": "tag1","token": "token1"}]}
{"operator_type": 10,"tag_token_list": [{"tag": "tag1","token": "token1"},{"tag": "tag2","token": "token2"},{"tag": "tag3","token": "token3"}]}
POST /v3/device/tag HTTP/1.1Host: api.tpns.tencent.comContent-Type: application/jsonAuthorization: Basic YTViNWYwNzFmZjc3YTplYTUxMmViNzcwNGQ1ZmI1YTZhOTM3Y2FmYTcwZTc3MQ==Cache-Control: no-cachePostman-Token: 4b82a159-afdd-4f5c-b459-de978d845d2f{"operator_type": 1,"tag_list": ["tag1"],"token_list": ["token1"]}
{"seq": 0,"ret_code": 0}
Was this page helpful?