Label binding with Unbind

Last updated: 2020-03-18 10:42:15

PDF

Interface description

Request method : POST .

https://api.tpns.tencent.com/v3/device/tag

Interface function : Tag API is the general name for all tag interfaces. Tag API has a variety of interfaces to set, update and delete. For more information, please see below.

Parameter description

Request parameter

Parameter name Type Required Parameter description
Operator_type Int Yes Type of operation:
  • Add a single tag, for a single token
  • Delete a single tag, for a single token
  • Adding multiple tag, for a single token
  • Delete multiple tag, for a single token
  • Delete all tags, for a single token
  • Tag override interface (supports multiple tags or custom class tag overrides), for a single token
    This API needs to clear the history tag before setting a new label, so it takes a period of time to call (it is recommended that it is greater than 5s), otherwise the update may fail.
  • Add a single tag, for multiple token
  • Delete a single tag, for multiple token
  • Add tags in batches (a maximum of 20 pairs are allowed for each call, with tags in front of each pair and token after each pair)
  • Delete tags in batches (a maximum of 20 pairs are allowed for each call, with tags in front of each pair and token after each pair)
  • Platform String Yes Client platform type:
  • Android: Android
  • IOS: apple
  • Token_list Array No Device list:
  • Operator_type = 1, 2, 3, 4, 5, 6, 7, 8: 00, required
  • Operator_type = 1, 2, 3, 4, 5, 6, if the parameter contains more than one token, only the first token will be set.
  • Format eg: [ "token1", "token2"]
  • The maximum number of values in a list is 20.
  • Token string length cannot exceed 64
  • Tag_list Array No List of tags:
  • Operator_type = 1, 2, 3, 4, 6, 7: 00, 8: 00, required, ignored when operator_type = 5
  • Operator_type = 1, 2, 3, 4, 6, 7, 8: 00, if the parameter contains multiple tag, if you only operate on a single tag, only the first tag will be set.
  • Format eg: [ "tag1", "tag2"]
  • The maximum number of values in a list is 20.
  • Tag string length cannot exceed 50
  • Tag_token_list Array No Tag, Device corresponding list:
  • Operator_type = 9, 10:00, required
  • Format eg: [ {"tag": "tag123", "token": "token123"}]
  • The label on the inside of each pair comes first, and the token comes after.
  • The maximum number of values in a list is 20.
  • Tag string length cannot exceed 50
  • Token string length cannot exceed 64
    • If there is only a single rather than a continuous call to the label setting interface, there is no limit to the way the interface is called.
    • If you set up interface calls for continuous labels, you should pay attention to the following:
    • If you need to set API calls for consecutive tags with more than 10 tags or more than 10 token, it is recommended to use batch APIs, but to ensure the correct operation of tags, it is recommended that the interval between two API calls be no less than 5s.
    • If the non-batch API is called, the next non-batch label API call will be made when the return value of the TPNS server is explicitly obtained. It is not recommended to use multi-thread asynchronously to call the label API at the same time.
    • ":" is the keyword of TPNS Backend Background, and is used as the classification of custom tags. If the tag is set with the ":" field, the first ":" tag is used as the classification of this custom tag. For the case where operator_type is 6, the classification batch setting of tags is supported. When the tags are deleted in batch, tags can be deleted by class. For more information, please see the example of operator_type 6 in the request example below.

    Response parameter

    Field name Type Required Annotation
    Seq Int64_t Yes Consistent with the request packet (this field is 0 if the request packet is illegal json,)
    Ret_code Int32_t Yes Error code, refer to the error code comparison table for details
    Err_msg String No Error message when the request goes wrong
    Result String No When the request is correct:
  • If there is additional data to return, the result is encapsulated in the json of the field
  • If there is no additional data, this field may not be available.
  • Example illustration

    Example of Unbind request for label binding

    • add a single tag1, to a single token1
    {
    "operator_type": 1,
    "platform": "android",
    "tag_list": ["tag1"],
    "token_list": ["token1"]
    }
    • Delete a single tag1, to a single token1
    {
    "operator_type": 2,
    "platform": "android",
    "tag_list": ["tag1"],
    "token_list": ["token1"]
    }
    • add multiple tag1 and tag2, to a single token1
    {
    "operator_type": 3,
    "platform": "android",
    "tag_list": ["tag1","tag2"],
    "token_list": ["token1"]
    }
    • Delete multiple tag1, tag2, to a single token1
    {
    "operator_type": 4,
    "platform": "android",
    "tag_list": ["tag1","tag2"],
    "token_list": ["token1"]
    }
    • remove all tags for a single token1
    {
    "operator_type": 5,
    "platform": "android",
    "tag_list": ["tag1","tag2"],
    "token_list": ["token1"]
    }
    • tags override custom class tags for a single token1
    {
    "operator_type": 6,
    "platform": "android",
    "tag_list": ["test:2", "level"], 
    "token_list": ["token1"]
    }

    If one or more of the tags do not have a ":" sign, the test:2 and level tags will overwrite all custom tags of token1.

    • batch override custom class tags for a single token (this API only covers custom class tags, not all)
    {
    "operator_type": 6,
    "platform": "android",
    "tag_list": ["test:2", "level:2"],
    "token_list": ["token1"]
    }

    If all tags are marked with ":", only the custom tags of the token1 corresponding to the tag class before the ":" sign are overwritten.

    • add a single tag1 for multiple token1 and token2
    {
    "operator_type": 7,
    "platform": "android",
    "tag_list": ["tag1"],
    "token_list": ["token1","token2"]
    }
    • multiple token1, token2 to delete a single tag1
    {
    "operator_type": 8,
    "platform": "android",
    "tag_list": ["tag1"],
    "token_list": ["token1","token2"]
    }
    • batch labeling
    {
    "operator_type": 9,
    "platform": "android",
    "tag_token_list": [{"tag":"tag1","token":"token1"}]
    
    }
    • Delete tags in batch, delete tags for tag1, tag2, tag3
    {
    "operator_type": 10,
    "platform": "android",
    "tag_token_list": [
    {
    "tag":"tag1",
    "token":"token1"
    },
    {
    "tag":"tag2",
    "token":"token2"
    },
    {
    "tag":"tag3",
    "token":"token3"
    }]
    }

    Example of a label setting request

    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"]
    }

    Example of label setting reply

    {
    "seq": 0,
    "ret_code": 0,
    }