tencent cloud

Tencent Push Notification Service

Release Notes
Announcements
Features
SDK for Android
SDK for iOS
SDK for macOS
Product Introduction
Overview
Strengths
Use Cases
Global Deployment
Purchase Guide
Billing Overview
Purchase Directions
Billing Modes
Free Trial
Payment Overdue
Getting Started
Creating Products and Applications
Quick Integration with Android
Quick Integration with iOS
Creating a Push Task
Querying Push Records
Guidelines for Push Testing Methods
Product Restrictions
Operation Guide
Push Management
Advanced Push Features
Practical Tutorial
iOS Badge Feature Practice
API Documentation
Overview
API Overview
Call Method
Push APIs
Tag APIs
Account APIs
Statistics APIs
User Attribute APIs
Server-Side Error Codes
Server SDKs
API (Java)
SDK Documentation
Android Integration Guide
iOS Integration Guide
Client Integration Plugin
macOS Integration Guide
Users and Permissions
Quick Configuration
Advanced Custom Configuration
Resource Tag
Service Agreement
Service Level Agreement
FAQs
iOS
Android
Flutter
Others
Tencent Push Notification Service Policy
Privacy Policy
Data Processing and Security Agreement
Developer Agreement
Contact Us
Glossary

User Attribute APIs

PDF
Focus Mode
Font Size
Last updated: 2024-01-17 14:26:44

API Description

Request method: POST.
Service URL/v3/device/set_custom_attribute
API service URLs correspond to service access points one by one. Please select the service URL corresponding to the service access point of your application.
Feature: this API is used to manage personalized attributes at the token level, including creation, deletion, update, and query operations.

Parameter Description

Request parameters

Parameter
Required
Type
Description
cmd
Yes
Integer
Operation type:
1: adding an attribute.
2: updating an attribute.
3: deleting an attribute.
4: deleting all attributes.
5: querying attributes.
token
Yes
String
Unique ID assigned to each device by TPNS.

attributeInfo

Yes (when cmd is 1, 2, or 3)
Map
Attribute details. See the description of the attributeMap parameter below.
attributeMap
Yes (when cmd is 1, 2, or 3)
Map
Attribute details:
key indicates the attribute name and can contain up to 50 bytes. Note: you should have created an attribute in the TPNS console > Toolbox > User Attribute Management; otherwise, this parameter will be filtered out, and invalidAttribute will be returned.
value indicates the attribute value and can contain up to 50 bytes.

Response parameters

Parameter
Returned
Type
Description
retCode
Yes
Integer
Error code. For more information, please see Server-Side Error Codes.
errMsg
Yes
String
Error message when an error occurs in the request.
attributeInfo
Yes (when cmd is 5)
Map
Attribute details.
invalidAttribute
Yes (when the attribute is invalid)
Array
Details of the invalid attribute.

Samples

Adding an attribute

Sample request

Add three attributes to a token.
{
"cmd": 1,
"token": "04cac74a714f61bf089987a986363d88****",
"attributeInfo": {
"attributeMap": {
"age": "100",
"name": "Ming",
"high": "2.66"
}
}
}



Sample response

{
"retCode": 0,
"errMsg": "success",
"invalidAttribute": [
"high" // The corresponding key value does not exist in the console
]
}

Updating an attribute

Sample request

Update the value of the name attribute to workman.
{
"cmd": 2,
"token": "04cac74a714f61bf089987a986363d88****",
"attributeInfo": {
"attributeMap": {
"name": "workman"
}
}
}




Sample response

{
"retCode": 0,
"errMsg": "success"
}

Deleting an attribute

Sample request

Delete the workman value of the name attribute.
{
"cmd": 3,
"token": "04cac74a714f61bf089987a986363d88****",
"attributeInfo": {
"attributeMap": {
"name": "workman"
}
}
}




Sample response

{
"retCode": 0,
"errMsg": "success"
}

Deleting all attributes

Sample request

Delete all attributes of a token.
{
"cmd": 4,
"token": "04cac74a714f61bf089987a986363d88****"

}

Sample response

{
"retCode": 0,
"errMsg": "success"
}

Querying attributes

Sample request

Query the attribute details of a token.
{
"cmd": 5,
"token": "04cac74a714f61bf089987a986363d88****"

}

Sample response

{
"retCode": 0,
"errMsg": "success",
"attributeInfo": {
"attributeMap": {
"nickname": "workman"
}
}
}


Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback