Push Message
You can send API-based push message campaigns using the HTTP API.
Authentication
Authentication is done using an API key, which must be sent in the HTTP header.
X-HACKLE-API-KEY: {YOUR_API_KEY}
API KEY Environment Note
Please note that API integration keys differ for each environment.
Request
POST https://api.hackle.io/v1/push-message/trigger/send
Request Body
Field | Type | Required | Description | Restrict |
---|---|---|---|---|
campaignKey | number | O | The campaign key for the push message | |
users | array | O | List of users to receive the push message | The maximum number of users is limited to 50. |
User Object
Field | Type | Required | Description |
---|---|---|---|
userId | string | X | User ID (required if deviceId is not provided) |
deviceId | string | X | Device ID (required if userId is not provided) |
apiProperties | object | X | Key-value pairs used for personalization the push message. key(string)-value(string|number|boolean) Pair |
Target Users
The target user information must match the cohort user conditions set in the push message campaign.
Push messages will not be sent to users who do not meet the cohort conditions.
Example
curl -i -X POST \
'https://api.hackle.io/v1/push-message/trigger/send' \
-H 'X-HACKLE-API-KEY: YOUR_API_KEY_HERE' \
-H 'Content-Type: application/json' \
-d '{
"campaignKey": 1,
"users": [
{
"userId": "eb24b2d8-21a3-4e95-b801-626ba0904e01",
"apiProperties": {
"productNumber": "123"
}
}
]
}'
Response
The response to the API send request returns either a Success Response or an Error Response object.
Success
200 OK
Field | Data Type | Description |
---|---|---|
dispatchId | string | A unique UUID for the push message request triggered by the API |
message | string | Contains the message "success". |
A successful push message send request does not guarantee that the user actually received the push message.
You can check the final send success statistics on the dashboard.
Error
Field | Data Type | Description |
---|---|---|
code | string | Specific error response code |
message | string | Displays an error message |
Http Status | Code | Message | Description |
---|---|---|---|
401 | INVALID_API_KEY | “Invalid API key“ | When an invalid API KEY is included in the header |
401 | API_KEY_NOT_FOUND | “The API key must be included in the header” | When the API KEY is not included in the header |
400 | EXCEED_USER_MAX_LENGTH | “Max input length exceeded“ | When the request exceeds the maximum number of users that can be sent at once |
400 | CAMPAIGN_NOT_FOUND | “Could not find push message campaign with the given key“ | When there is no API-based campaign matching the provided campaign key |
400 | EMPTY_IDENTIFIER | “At least one identifier should be given“ | When both userId and deviceId are missing in the target user information |
Example
Successful Send Request Example
{
"dispatchId": "bac3da45-f6e3-44ea-989e-e0fa0ffc9f5c",
"message": "success"
}
Failed Send Request Example
{
"code": "INVALID_API_KEY",
"message": "Invalid API key"
}
Updated 4 months ago