Pushing Messages

The Magnet Max REST API supports pushing messages to all active devices of a user using recipientUserId via APNS or GCM.

For details on how to obtain the recipientUserId and access token to make the request, please refer to Authentication and User Management.

Push Message to User ID

To push a message to a user ID:

* Path
```
POST https://<server>/message/api/v2/push/user/{recipientUserId}```

* Sample Request
```
curl -X POST \

-H "Authorization: " \ -H "Content-Type: application/json" \ -d '{"action": "PUSH", "name": "SwimEvent", "payload": { "title": "Event 11 Heat 1/8", "body": "200 Butterfly", "startTime": "09:28am", "lanes": 10}}' \ https:///message/api/v2/push/user/ff808081518800fb0151888b5c190014

```

* Sample Response
```
{
    "count": {
        "requested": 1,
        "sent": 1,
        "unsent": 0
    },
    "sentList": [
        {
            "pushId": "46591c56a7bca27610bef63326bb716a",
            "deviceId": "eee4a108-9daa-45a5-8a09-a84d8d1782e3"
        }
    ],
    "unsentList": []
}
```

* Parameters

<table>
    <tbody>
        <tr> 
            <td>action</td>
            <td>PUSH for non-silent push or WAKEUP for silent push</td>
        </tr>
        <tr >
            <td>name</td>
            <td>a name used to identify this push message</td>
        </tr>
        <tr >
            <td>payload</td>
            <td>dictionary list of key/value pairs of the actual message contents.  A set of pre-defined keys for Apple Push Notification Service and
            Android Notification are <b>title</b>, <b>body</b>, <b>sound</b>, <b>badge</b>, and <b>icon</b>.</td>
        </tr>
        <tr >
            <td>count</td>
            <td>dictionary providing count information returned from server:
                <ul>
                <li> <b>requested:</b>Count of users that matched the request</li>
                <li> <b>sent:</b> Count of devices to which the system sent a push message</li>
                <li> <b>unsent:</b> Count of devices to which the system was unable to send a push message </li></ul>
            </td>
        </tr>
        <tr >
            <td>sentList</td>
            <td>dictionary list of element providing information about send push message:
                <ul>
                <li> <b>pushId:</b> Id of the push message sent </li>
                <li> <b>deviceId:</b> id of the device to which the message was sent</li>
                </ul>
            </td>
        </tr>
        <tr >
            <td>unsentList</td>
            <td>dictionary list of element providing information about unsent push messages</td>
        </tr>
    </tbody>
</table>