Use the /setTags endpoint to change tags for a specific device. While /bulkSetTags works for groups of 50 or more, /setTags is the correct choice for individual updates.
You can use a Device API Token to call this endpoint from your server.
API Tokens
Pushwoosh uses two types of tokens:
- Server API Token: Used for administrative tasks like sending messages. Do not put this in a mobile app.
- Device API Token: Used for device-level tasks like setting tags or tracking events. This token is safe to use in both mobile apps and backend scripts.
How to use /setTags
To update a device, send a POST request to this endpoint:
POST https://api.pushwoosh.com/json/1.3/setTags
Include these headers: * Authorization: Token YOURDEVICEAPI_TOKEN * Content-Type: application/json
Use this JSON structure in the request body:
{
"request": {
"application": "YOUR_APP_CODE",
"hwid": "DEVICE_HWID",
"tags": {
"YourTag": "value"
}
}
}
Technical details
- Application authorization: Create your token in the Control Panel under Settings - API Access. You must select the specific Application Code when generating the token. If the application is not authorized, the API returns a 401 error.
- Hardware IDs: Your server needs to store the
hwidfor each user to tell the API which device to update. - Processing time: The
/setTagsendpoint is asynchronous. A 200 OK response means the request is in the queue. The tags usually update in the database a few seconds later.
Comments
0 comments
Please sign in to leave a comment.