Request method: POST.
request address/v3/device/tag
The API request address is corresponding to the service access point. Select the request address corresponding to the service access point of your application.
API featureTag
API is the general term for all tag APIs. It includes various APIs for setting, updating, and deleting which are described as below:
For use cases of the tag feature, please see Tag Feature Use Instructions.
Parameter Name | Type | Required | Description |
---|---|---|---|
operator_type | Integer | Yes | Operation type: 1: add a single tag to a single token. 2: delete a single tag from a single token. 3: add multiple tags to a single token. 4: delete multiple tags from a single token. 5: delete all tags from a single token. 6: add one or more tags or custom tags to a single token in an overwriting manner. (This API only starts to set up new tags after the tag history is cleared, so calling it for the same token should be made at a certain interval (more than 1s recommended); otherwise, it may cause updating failure.) 7: add a single tag to multiple tokens. 8: delete a single 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). |
platform | String | Yes | Client platform type: |
token_list | Array | No | Device list:operator_type is 1, 2, 3, 4, 5, 6, 7, or 8.operator_type is 1, 2, 3, 4, 5, or 6, if this parameter contains multiple tokens, only the first one will be set. |
tag_list | Array | No | Tag list:operator_type is 1, 2, 3, 4, 6, 7, or 8; ignored if operator_type is 5.operator_type is 1, 2, 7, or 8, if this parameter contains multiple tags, only the first tag will be set if for a single tag. |
tag_token_list | Array | No | Tag-device list:operator_type is 9 or 10. |
tags
, one device token
can be bound to up to 100 customized tags
(if you want to increase this limit, please submit a ticket), and one custom tag
can be bound to an unlimited number of device tokens.operator_type
is 6 (overwriting tags by category). For example, if the existing tags of a device are level:1
, level:2
, and male
, you can directly use tag level:3
to overwrite tags level:1
and level:2
without having to unbind level:1
and level:2
one by one, and then bind tag level:4
. For more information, please see the following sample request where operator_type
is 6.Field name | Type | Required | Comments |
---|---|---|---|
ret_code | Integer | Yes | Error code. For more information, please see the error codes table |
err_msg | String | No | Error message when an error occurs in the request |
result | String | No | When the request is correct: |
{
"operator_type": 1,
"platform": "android",
"tag_list": [
"tag1"
],
"token_list": [
"token1"
]
}
{
"operator_type": 2,
"platform": "android",
"tag_list": [
"tag1"
],
"token_list": [
"token1"
]
}
{
"operator_type": 3,
"platform": "android",
"tag_list": [
"tag1",
"tag2"
],
"token_list": [
"token1"
]
}
{
"operator_type": 4,
"platform": "android",
"tag_list": [
"tag1",
"tag2"
],
"token_list": [
"token1"
]
}
{
"operator_type": 5,
"platform": "android",
"tag_list": [
"tag1",
"tag2"
],
"token_list": [
"token1"
]
}
{
"operator_type": 6,
"platform": "android",
"tag_list": [
"test:2",
"level"
],
"token_list": [
"token1"
]
}
If one or more of the tags do not contain ":", then the
test:2
andlevel
tags overwrite all custom tags of token1.
{
"operator_type": 6,
"platform": "android",
"tag_list": [
"test:2",
"level:2"
],
"token_list": [
"token1"
]
}
If all the tags have ":", as the string before the first ":" is the tag category, only tags in the same category corresponding to the device will be overwritten; for example,
test:2
will overwritetest:*
, andlevel:2
will overwritelevel:*
, without affecting other tags.
{
"operator_type": 7,
"platform": "android",
"tag_list": [
"tag1"
],
"token_list": [
"token1",
"token2"
]
}
{
"operator_type": 8,
"platform": "android",
"tag_list": [
"tag1"
],
"token_list": [
"token1",
"token2"
]
}
{
"operator_type": 9,
"platform": "android",
"tag_token_list": [
{
"tag": "tag1",
"token": "token1"
}
]
}
{
"operator_type": 10,
"platform": "android",
"tag_token_list": [
{
"tag": "tag1",
"token": "token1"
},
{
"tag": "tag2",
"token": "token2"
},
{
"tag": "tag3",
"token": "token3"
}
]
}
POST /v3/device/tag HTTP/1.1
Host: api.tpns.tencent.com
Content-Type: application/json
Authorization: Basic YTViNWYwNzFmZjc3YTplYTUxMmViNzcwNGQ1ZmI1YTZhOTM3Y2FmYTcwZTc3MQ==
Cache-Control: no-cache
Postman-Token: 4b82a159-afdd-4f5c-b459-de978d845d2f
{
"operator_type": 1,
"platform": "android",
"tag_list": [
"tag1"
],
"token_list": [
"token1"
]
}
{
"seq": 0,
"ret_code": 0
}
Was this page helpful?