Reza M.A
Reza M.A

Reputation: 1207

How to set a tag for a user in one signal with rest api

According to one signal documentation tag can be set with rest API:

Tags are data attributes that can be added to users via OneSignal SDKs or the Server REST API.

but there is no more data, about how to send a tag with rest api! the link just refer to create notification documentation and nothing more.

Is it possible to send tag from back-end? Does any one experience this?

Upvotes: 1

Views: 5559

Answers (1)

Reza M.A
Reza M.A

Reputation: 1207

OneSignal describe this issue under edit device section in it's documentation:

by using playerId in calling this web service with PUT method:

https://onesignal.com/api/v1/players/{playerid}

and in body:

{
 "app_id": "Your app id",
 "tags" : {
    "add_new_tag":"joined",
    "remove_old_tag" : ""
    }
}

To delete a tag, include its key and set its value to blank. Omitting a key/value will not delete it. For example, if I wanted to delete two existing tanks rank and category while simultaneously adding a new tag class, the tags JSON would look like the following:

"tags": {
           "rank": "",
           "category": "",
           "class": "my_new_value"
        }

Upvotes: 4

Related Questions