Send Notifications

This section describes API to send push notifications.

Send Push

To send push notifications.

This API requires a JSON payload.

curl https://app.mpush.cloud/api/send
-X POST 
-H "Accept: application/json" 
-H "Content-Type: application/json" 
-H "X-MPush-Token: <token>" 
-H "X-MPush-Token: 2" 
-d '<JSON payload>' 

On success is returned an HTTP 200 and JSON like this:

{
  "status_code": 0,
  "body": {
    "total": 1
  }
}

HTTP Request

POST https://app.mpush.cloud/api/send

Parameters (JSON)

Key

Type

Required

Description

push.topics

array

Yes

Contains a list of all topics to send the push to.

push.payload.title

string

No

Notification title.

push.payload.body

string

Yes

Notification body.

push.payload.badge

int

No

Badge number.

push.payload.sound

string

No

Specify the sound path to play when the push arrives.

push.payload.title_loc_key

string

No

Specify the key to a body string in a localization file for the current locale.

push.payload.title_loc_args

array

No

Specify the values to appear in place of the format specifiers in title_loc_key.

push.payload.loc_key

string

No

Specify the key to a title string in a localization file for the current locale.

push.payload.loc_args

array

No

Specify the values to appear in place of the format specifiers in loc_key.

push.payload.action_loc_key

string

No

Custom sound to play.

push.payload.launch_image

string

No

Specify the image path to launch at the app launch.

push.payload.scheduled_at

int

No

A UNIX timestamp (UTC) that identifies the date when the notification should be sent.

push.payload.mutable_content

bool

No

Mutable content (only iOS).

push.payload.content_available

bool

No

Content available (only iOS).

push.payload.category

string

No

Specify a category (only iOS).

push.payload.thread_id

int

No

Specify a thread (only iOS).

push.payload.collapse_id

int

No

Multiple notifications with the same collapse identifier are displayed to the user as a single notification (only iOS).

push.payload.expiration_at

int

No

A UNIX timestamp (UTC) that identifies the date when the notification is no longer valid and can be discarded.

push.payload.custom

object

No

An object containing custom data.

This table is used the "dot" notation to show the payload JSON structure.

For a complete reference to all available values to include in the payload we remand to the official documentation: iOS and Android.

Examples

Payload example to send a basic notification:

{
  "push": {
    "topics": ["all"],
    "payload": {
      "body": "Hello"
    }
  }
}

Payload example to send a basic notification to multiple topics with custom badge and sound:

{
  "push": {
    "topics": ["news", "user.12", "user.15"],
    "payload": {
      "title": "News!",
      "body": "Hello",
      "badge": 2,
      "sound": "sound.aiff"
    }
  }
}

Payload example to send a scheduled notification with custom data:

{
  "push": {
    "topics": ["user.12"],
    "payload": {
      "body": "Hello",
      "scheduled_at": 1546300800,
      "custom": {
        "custom": "data",
        "key": "value"
      }
    }
  }
}

Payload example to send a notification with localization:

{
  "push": {
    "topics": ["user.23"],
    "payload": {
      "loc_key": "LOCALIZED_PUSH",
      "loc_args": [
        "Name",
        "Surname"
      ]
    }
  }
}

In the sidebar a list of examples with the most common configurations.

Last updated