Pub/Sub Subscribe API
Subscribe a device to one or more topics.
-
API Reference
-
Test it out
-
POST https://api.pushy.me/topics/subscribe?api_key=SECRET_API_KEY
Note: Make sure to replace
SECRET_API_KEY
with your app's Secret API Key, available in the Pushy Dashboard (Click your app -> API Authentication tab). This is a backend API endpoint. Never expose your application's Secret API Key in your client code.API Request
Sample Request Body
{ "token": "a6345d0278adc55d3474f5", "topics": [ "news", "media" ] }
Note: Please make sure to send the
Content-type: application/json
header with your request.Request Schema
Field Description Example token
*
StringThe token of the device to subscribe. "a6345d0278adc55d3474f5" topics
*
String[]An array of topics to subscribe the device to, limited to 100 topics per request.
Topics are case-sensitive and must match the following regular expression:[a-zA-Z0-9-_.]{1,100}
.["news", "media"] API Response
Sample Response Body
{ "success": true }
Response Schema
Field Description Example success
BooleanReturned if the API request was successful. true API Error Reference
Sample Error Response
{ "code": "INVALID_DEVICE_TOKEN", "error": "The provided device token is invalid." }
Error Codes
A list of endpoint-specific error codes, in addition to the global API errors.
Error code Description HTTP status code INVALID_DEVICE_TOKEN
The device token
provided is invalid or no longer exists, or the device is not registered to the app whoseSECRET_API_KEY
you are using to authenticate.400 Bad Request -
POST https://api.pushy.me/topics/subscribe?api_key=SECRET_API_KEY
API Response
500 CLIENT ERROR
N/A