Topics
This section describes APIs to add devices to MPush and associate them with topics. Only clients (e.g. apps) should implement these APIs or use mobile SDKs.

Add Device

1
curl https://app.mpush.cloud/api/tokens
2
-X POST
3
-H "Accept: application/json"
4
-H "Content-Type: application/json"
5
-H "X-MPush-Token: <token>"
6
-H "X-MPush-Version: 2"
7
-d <data>
Copied!
To register a new device token.
This API requires a JSON payload.

HTTP Request

POST https://app.mpush.cloud/api/tokens
Payload example to register a device to 3 topics:
1
{
2
"token": "<token>",
3
"platform": "ios",
4
"device_id": "<device ID>"
5
}
Copied!

Parameters

Name
Type
Required
Description
token
string
Yes
Specify token device obtained from APNS and FCM.
platform
string
Yes
Specify the device platform. Values are ios and android.
device_id
string
Yes
Specify the unique device ID. It's used to update the token in case of change.
On success is returned an HTTP 200 and JSON like this:
1
{
2
"status_code": 0
3
}
Copied!

Register

1
curl https://app.mpush.cloud/api/register
2
-X POST
3
-H "Accept: application/json"
4
-H "Content-Type: application/json"
5
-H "X-MPush-Token: <token>"
6
-H "X-MPush-Version: 2"
7
-d '<JSON payload>'
Copied!
To register a device to one or more topics.
A topic can represent either a device or a list of devices, you can specify it through thesingleparameter. If the specified topic doesn't exist it will be created.
This API requires a JSON payload.

HTTP Request

POST https://app.mpush.cloud/api/register
Payload example to register a device to 3 topics:
1
{
2
"topics": [
3
{
4
"code": "all",
5
"title": "All Users",
6
"single": false,
7
},
8
{
9
"code": "ios",
10
"title": "iOS Users",
11
"single": false,
12
},
13
{
14
"code": "user.1",
15
"title": "User 1",
16
"single": true,
17
},
18
],
19
"device_id": "<device ID>"
20
}
Copied!

Parameters (JSON)

Key
Type
Required
Description
topics
array
Yes
Contains a list of all topics to register the device to.
device_id
string
Yes
Specify the unique device ID.
On success is returned an HTTP 200 and JSON like this:
1
{
2
"status_code": 0
3
}
Copied!

Unregister

1
curl https://app.mpush.cloud/api/unregister
2
-X POST
3
-H "Accept: application/json"
4
-H "Content-Type: application/json"
5
-H "X-MPush-Token: <token>"
6
-H "X-MPush-Version: 2"
7
-d '<JSON payload>'
Copied!
To unregister a device from one or more topics.
If the specified topic doesn't exist it will be ignored.
This API requires a JSON payload.

HTTP Request

POST https://app.mpush.cloud/api/unregister
Payload example to unregister a device from 2 topics (old version):
1
{
2
"topics": ["all", "ios"],
3
"device_id": "<device ID>"
4
}
Copied!
Payload example to unregister a device from 2 topics (new version):
1
{
2
"topics": [
3
{
4
"code": "all",
5
},
6
{
7
"code": "ios",
8
}
9
],
10
"device_id": "<device ID>"
11
}
Copied!

Parameters (JSON)

Key
Type
Required
Description
topics
array
Yes
Contains a list of all topics to register the device to.
device_id
string
Yes
Specify the unique device ID.
On success is returned an HTTP 200 and JSON like this:
1
{
2
"status_code": 0
3
}
Copied!

Unregister All

1
curl https://app.mpush.cloud/api/unregister-all
2
-X POST
3
-H "Accept: application/json"
4
-H "Content-Type: application/json"
5
-H "X-MPush-Token: <token>"
6
-H "X-MPush-Version: 2"
7
-d '<JSON payload>'
Copied!
To unregister a device from all topics.
This API requires a JSON payload.

HTTP Request

POST https://app.mpush.cloud/api/unregister-all
Payload example to unregister a device from all topics:
1
{
2
"device_id": "<device ID>"
3
}
Copied!

Parameters (JSON)

Key
Type
Required
Description
device_id
string
Yes
Specify the unique device ID.
On success is returned an HTTP 200 and JSON like this:
1
{
2
"status_code": 0
3
}
Copied!
Last modified 5mo ago