API - Notification API for audience (revamp)
Usage
Use this API when you want to send the same notification to multiple users.
Use case examples:
General notifications
Notifications for an audience segment
If you want to send personalized notification or you want to target single users, the Notification API for individuals will give better results
Authentication and Authorization
You will have to ask your implementation manager to create a key/secret combination for you.
The API authentication is done using HTTP Basic Authentication. You need need to add an Authorization header to every request:
Authorization: Basic <token>
where <token> is a base64 encoded string of key:secret
Create(send) a Notification
The notification will be queued to be sent as soon as it is created.
Endpoint URL
https://api1.greencopper.net/notification/<project-tag>/
For preproduction environment: https://preprod-api1.greencopper.net/notification/<project-tag>/
HTTP Method
POST
Request body
Body should be valid JSON
Attribute | Type | Required | Notes |
---|---|---|---|
title | Object | Yes | Provide the notification title in the project’s each language code in ISO 639-2 format. Max 140 characters per language. |
body | Object | No | Provide the notification body in the project’s each language code in ISO 639-2 format. Max 140 characters per language. |
deeplink | String | No | A deeplink that will open when the user clicks on the notification. For example:
Ask your implementation manager to get a list of available deeplinks for your app |
segment | Integer | No | ID of the Segment to send the notification to (use the segment endpoint to see the available segment IDs) |
limit | Integer | No | Set a maximum number of recipients chosen randomly |
gc_user_ids | Array of strings | No | A list of GC user IDs you want the notification to be sent to |
Omitting segment
and gc_user_ids
will send the notification to everyone.
Request example
Body should be JSON
{
"title": {
"eng": "Test 1"
},
"segment": 123
}
{
"title": {
"eng": "English title here",
"fre": "Titre en français ici"
},
"body": {
"eng": "The message content in English here",
"fre": "Le contenu du message en français ici"
},
"deeplink": "myapp://activitiesList",
"gc_user_ids": [
"724d4eda-d7f7-4742-be15-6ca948aa11d3",
"16481890-ff1e-4db5-ba39-45792e629f77",
"61abe9b1-5699-4a77-9274-d0e6e67aa6d9"
]
}
Responses
Notifications are sent asynchronously so in the response, the status of the notification will be “pending” and the number of recipients (success_count) will not be available.
Response statuses
Created with success: 201
Validation errors: 400
Check body for error detailsServer error: 500
List Notifications
Retrieve the list of notifications for the project
Endpoint URL
https://api1.greencopper.net/notification/<project-tag>/
HTTP Method
GET
Response example
List Segments
Retrieve the list of available segments for the project.
Endpoint URL
https://api1.greencopper.net/segment/<project-tag>/
HTTP Method
GET
Response example