Push API¶
Using our Push API, you can send push notifications from outside of our system; from your servers, inside the app or technically anywhere.
Get Started¶
To use Push API, you need to generate an API endpoint and a Repro API Token for the push notification.
Get the API endpoint and Repro API token¶
Go to MARKETING > PUSH NOTIFICATION and click CREATE NEW PUSH NOTIFICATION
Set a default message in Message form.
Choose API-TRIGGERED DELIVERY and check load balancing options if necessary.
Publish the push notification.
On the next page you can get the API endpoint and Repro API Token.
Send push notification via API¶
Each Push API is associated to a single endpoint which accepts POST
HTTP method.
POST https://marketing.reproio.com/v1/push/<push_id>/deliver
Authentication¶
Set Repro API Token in HTTP header X-Repro-Token
.
Access limit per unit time¶
Access is limited per time for Push API.
The limit is set to 1000 accesses for every 1 minutes per API token.
When the request is completed, there will be a notification at the
X-RateLimit-Limit
header showing the maximum number of requests per time.When the request count exceeds the maximum access number, the following response
HTTP Status 429 (Too Many Requests)
will appear.
For more information on response headers, please see Push API responses.
Warning
The maximum access number may fluctuate without warning.
- The access limit setting value is per API token per function.For example, the push API and the user profile API use the same API token, but they are different functions, so even if they are requested at the same time, each is counted as one request.
API format¶
Set a message in JSON format to the HTTP body. The byte size must be less than or equal to 3MB. Please split user_ids and send multiple requests if you want to send a message which exceeds that size. If the size of each user ID is 15 bytes, you can include about 200,000 IDs at most.
{
"audience": {
"user_ids": [
"user-1234"
]
},
"notification": {
"message": "Hello!",
"sound": "default.wav"
}
}
Audience¶
audience
: Specify distribution targets.user_ids
: Specify an array of the users registered by the User ID API in the app.
Message¶
notification
:This field must include parameters of Standard format or Custom (JSON).If the
notification
field has not been set, the default message set in the dashboard will be sent.
Standard format¶
message
:The notification's message body.
deeplink_url
:When you set Deep Link or URL to the message, the assigned address will be opened by the SDK when the app user taps the notification. The specified page will open if a DeepLink is set (this requires setup on the app side as well), while with a URL the page will be opened within a browser. When left blank, the app will just launch.
Character Limit
Maximum: 255
sound
:The sound file for iOS app. If no file name is provided, the iOS system-sound will be used.
Custom (JSON)¶
When using the following parameters, please specify both simultaneously.
If you want to send a custom payload to only one OS, specify the unwanted parameter as {}
(empty JSON).
custom_payload_ios
:You need to set the content as String for iOS devices.
custom_payload_android
:You need to set the content as String for Android devices.
Use Custom (JSON) notification if you wish to delivery message with additional features such as notification badges, silent notifications or using custom payload.
Note
Android : Your application can receive Custom (JSON) format messages by using onMessageReceived of FirebaseMessagingService.
Android: For Android, within "data" in JSON, you can specify only strings for key-value pairs. For more details, please check the FCM documentation
See also this content for more information.
Scheduling¶
schedule
: Specify the delivery time. (optional)You can reserve the delivery by specifying the time in the parameter. If not specified, it will be delivered immediately.
schedule
should be ISO8601 format.You can schedule a date up to 1 month from the current date.
Push Notifications can be scheduled up to 1000 in an hourly window. Please note that this limit is applied across all API endpoints within the same app.
{
"audience": {
"user_ids": [
"user-1234"
]
},
"notification": {
"message": "Hello!",
"sound": "default.wav"
},
"schedule": "2018-06-20T13:00:00+09:00"
}
Example:¶
Sending a message to single user¶
{
"audience": {
"user_ids": [
"user-1234"
]
},
"notification": {
"message": "Hello!",
"sound": "default.wav"
}
}
Sending message to multiple users¶
{
"audience": {
"user_ids": [
"user-1234",
"user-5678"
]
},
"notification": {
"message": "Hello!",
"sound": "default.wav"
}
}
Using custom payload¶
{
"audience": {
"user_ids": [
"user-1234"
]
},
"notification": {
"custom_payload_ios": "{\"aps\":{\"alert\":{\"title\":\"hello\",\"body\":\"world\"},\"badge\":1}}",
"custom_payload_android": "{\"data\":{\"rpr_title\":\"hello\",\"rpr_body\":\"world\"}}"
}
}
Send Rich Notification¶
When sending a Rich Notification using Push API, add the necessary information for Rich Notifications into the custom payload, as below.
{
"audience": {
"user_ids": [
"user-1234"
]
},
"notification": {
"custom_payload_ios": "{\"aps\": {\"alert\": {\"title\": \"YOUR_NOTIFICATION_TITLE\", \"body\": \"YOUR_NOTIFICATION_BODY\"}, \"mutable-content\": 1}, \"rpr_attachment\": {\"url\": \"IMAGE_URL\", \"type\": \"jpg\"}}",
"custom_payload_android": "{\"data\":{\"rpr_title\":\"YOUR_NOTIFICATION_TITLE\",\"rpr_body\":\"YOUR_NOTIFICATION_BODY\", \"rpr_picture\":\"{\\\"type\\\": \\\"jpg\\\",\\\"url\\\": \\\"IMAGE_URL\\\"}\"}}"
}
}
Note
In order to display Rich Notifications, prior implementation of preparation for receiving Rich Notification is necessary on the app.
Send notification using cURL¶
curl https://marketing.reproio.com/v1/push/xxxx/deliver \
--verbose \
--request POST \
--header "X-Repro-Token: MARKETING-TOKEN" \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--data-binary '{"audience": { "user_ids": ["user-1234", "user-5678"]}}'
Warning
The endpoint domain will be changed from repro.io to reproio.com. You can still use the old domain, but we recommend to use the new domain.
Send notification from dashboard¶
You can send notifications using the Push API from the dashboard. This feature allows marketers to run marketing campaigns without having developer's help.
Please note that there are a few constraints to this feature as the follows:
The message text will be the one that you fill out from the message creation form
The target users must be specified by uploading a file with the list of user IDs you wish to deliver in the below format:
Character Code: UTF8
Newline: LF or CRLF
File size: ~3MB
File format:
user-1234
user-5678
Push API requests¶
Request header
The response header contains the following values.
Header |
Description |
Required |
---|---|---|
Content-Type | Set application/json |
Required |
X-Repro-Token | Set the token retrieved with Get the API endpoint and Repro API token |
Required |
Request body
Set the message to JSON format.
Push API responses¶
Response header
The response header contains the following values.
Status |
Header |
Description |
---|---|---|
Success |
X-RateLimit-Limit |
Access limit per unit time |
Success |
X-RateLimit-Remaining |
The number of requests remaining in the current rate limit window. |
Success |
X-RateLimit-Reset |
The time at which the current rate limit window resets in UTC epoch seconds. (Unix UTC timestamp) |
Request limited |
Retry-After |
The time how long the user agent should wait before making a follow-up request. |
Response body
The list below contains all status codes and error messages of Push API responses.
400 Bad Request¶
You have an error in your request. Please check you have spelled everything correctly.
Response body
{
"error":"message"
}
401 Unauthorized¶
You don't have Repro API Token set.
Response body
{
"status": "unauthorized",
"error": {
"messages": [
"Please include your Repro API Token as \"X-Repro-Token\" HTTP header."
]
}
}
403 Forbidden¶
The specified Repro API Token is invalid.
Response body
{
"status": "forbidden",
"error": {
"messages": [
"Please check your Repro API Token as \"X-Repro-Token\" HTTP header."
]
}
}
404 Not Found¶
The endpoint does not exist.
Response body
{
"status": "not_found",
"error": {
"messages": [
"Not found."
]
}
}
422 Unprocessable Entity¶
The specified parameter(s) is invalid.
Response body
{
"status": "unprocessable_entity",
"error": {
"messages": [
"audience is missing",
"audience[user_ids] is missing"
]
}
}
413 Payload Too Large¶
Request body is too large.
Response body
{
"status": "payload_too_large",
"error": {
"messages": [
"client intended to send too large body"
]
}
}
429 Too Many Requests¶
Too many requests. Please wait the seconds indicated in the Retry-After
header and make a follow-up request.
Response body
{
"status": "too_many_requests",
"error": {
"messages": [
"Too many requests hit the API too quickly."
]
}
}