POST /alerts/ - Create a push

Create a new push notification


Endpoint:
/alerts/

HTTP method: POST

Format: JSON

Properties

AttributeRequiredTypeExampleDescription
message(coche)Object
{
    "eng": "English message"
}

An object where the properties are the languages (ISO 639-2) and the values are short messages to be sent. Max 140 characters per language.

extra_message
Object
{
    "eng": "<p>English extra content</p>"
}

An object where the properties are the languages and the values are long messages to be sent. Messages can be in HTML format.

url
String
"http://www.greencopper.com"

Where should the notification link to. Must be a complete URL. To link to an internal section of the app, contact us.

button_label
Object
{
    "eng": "Button text"
}
If you provide an extra_message and a url, a button will be displayed at the end of your extra_message. You can customize the label of this button for each language.
Max length: 40 characters per language.
scheduled_datetime
Datetime string
in
ISO 8601 format
"2017-01-21T16:00:00"

Enter a datetime to schedule the notification or leave empty to send now.

Time will be considered in UTC by default, if the time is localized, you must make it explicit:

"2017-01-21T16:00:00-05:00"
target_ids



(coche)
One of these
4 targeting options is required

Integer or
array of integers

1
or
[1, 2]

A target id or a list of ids
ios_gc_user_idsArray of strings
[
    "57573a2f-4683-4a18-a29e-2ad0f0f1f809",
    "4a82d315-7c1c-4386-9dd9-3778e5a13372"
]
A list of gc_user_id to target specific iOS devices.
android_gc_user_idsArray of strings[
    "e40fbbfa-13ab-46ef-ae6e-2619ff0ebca9",
    "26d2a0a4-4f76-45cc-b85e-2c2f5ab70e48"
]
A list of gc_user_id to target specific Andoid devices.
gc_user_idsArray of strings[
    "e40fbbfa-13ab-46ef-ae6e-2619ff0ebca9",
    "26d2a0a4-4f76-45cc-b85e-2c2f5ab70e48"
]
A list of gc_user_id. Can be a mix of both iOS or Android devices.
limit
Integer75Set a maximum of recipient chosen randomly.
Cannot be used in combination with ios_gc_user_ids or android_gc_user_ids.
include_ios
BooleantrueDefaults to true. Set to false if you do not want to target iOS devices.
include_android
BooleantrueDefaults to true. Set to false if you do not want to target Android devices.
webhook_url
Stringhttp://domain.com/callbackA URL that will be called when the push is processed. The URL will be called using POST with a body that contains the ID of the push:
{
   "push_id": 1234
}

Request

Request body must be a JSON object

Examples

Send a simple notification to a list of iOS and Android devices

{
 "message": {
    "fre": "message"
 },
 "ios_gc_user_ids" : [
    "57573a2f-4683-4a18-a29e-2ad0f0f1f809",
    "4a82d315-7c1c-4386-9dd9-3778e5a13372"
 ],
 "android_gc_user_ids": [
    "e40fbbfa-13ab-46ef-ae6e-2619ff0ebca9",
    "26d2a0a4-4f76-45cc-b85e-2c2f5ab70e48"
 ]
} 


Send a simple notification to a list of devices of unknown platform

{
 "message": {
    "eng": "message"
 },
 "gc_user_ids" : [
    "57573a2f-4683-4a18-a29e-2ad0f0f1f809",
    "4a82d315-7c1c-4386-9dd9-3778e5a13372"
 ]
} 


Schedule a notification with additional content and a link to an external website

{
 "message": {
    "fre": "court message",
    "eng": "short message"
 },
 "extra_message": {
    "fre": "<p>message supplementaire</p>"
    "eng": "<p>extra message</p>"
 },
 "url": "http://greencopper.com",
 "scheduled_datetime": "2016-04-02T18:38:12",
 "ios_gc_user_ids" : [
    "57573a2f-4683-4a18-a29e-2ad0f0f1f809",
    "4a82d315-7c1c-4386-9dd9-3778e5a13372"
 ],
 "android_gc_user_ids": [
    "e40fbbfa-13ab-46ef-ae6e-2619ff0ebca9",
    "26d2a0a4-4f76-45cc-b85e-2c2f5ab70e48"
 ],
 "webhook_url": "https://www.domain.com/webhook/greencopper/push"
}


Response

Response body will contain the created push object or a list of error messages

Example

Status 201: A successfully created push notification

{ 
 "id": 32,
 "message": {
    "fre": "court message",
    "eng": "short message"
 },
 "extra_message": {
    "fre": "<p>message supplementaire</p>"
    "eng": "<p>extra message</p>"
 },
 "url": "http://google.com",
 "created_datetime": "2016-04-02T18:38:12",
 "scheduled_datetime": "2016-04-02T18:38:12",
 "ios_gc_user_ids" : [
    "57573a2f-4683-4a18-a29e-2ad0f0f1f809",
    "4a82d315-7c1c-4386-9dd9-3778e5a13372"
 ],
 "android_gc_user_ids": [
    "e40fbbfa-13ab-46ef-ae6e-2619ff0ebca9",
    "26d2a0a4-4f76-45cc-b85e-2c2f5ab70e48"
 ],
 "webhook_url": "https://www.domain.com/webhook/greencopper/push"
 "status_ios": "READY",
 "status_android": "READY",
 "sent_ios": null,
 "sent_android": null
}


Status 400: The data is not valid, see the response for details

{"url": ["Enter a valid URL"]}