# Send Push Message

{% hint style="info" %}
The HTTP API can only be used in a server environment.
{% endhint %}

You can use the HTTP API to send API-triggered Push Message campaigns.

Authentication is performed using the SDK Key.

* Add the SDK Key to the HTTP header as shown below.
* You can find the SDK Key in the Hackle Dashboard under [SDK Integration Info](https://dashboard.hackle.io/config/sdk-setting).

```http
X-HACKLE-API-KEY: {YOUR_SERVER_SDK_KEY}
```

### Request

{% hint style="warning" %}
The target user information must match the cohort user conditions configured in the Push Message campaign.\
That is, the Push Message will not be sent to users who do not match the cohort conditions.
{% endhint %}

```http
POST https://api.hackle.io/v1/push-message/trigger/send
```

#### Request Body

| Field       | Type                 | Required | Description                          | Restrict                                      |
| ----------- | -------------------- | -------- | ------------------------------------ | --------------------------------------------- |
| campaignKey | number               | O        | Campaign Key for the Push Message    |                                               |
| users       | array`<User object>` | O        | List of users to receive the message | **Maximum number of users cannot exceed 50.** |

**User Object**

| Field         | Type   | Required | Description                                                                                                                                                                        |
| ------------- | ------ | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| userId        | string | X        | User ID (Hackle ID can be used)                                                                                                                                                    |
| deviceId      | string | X        | Device ID (Hackle ID can be used)                                                                                                                                                  |
| apiProperties | object | X        | Key-value pairs used for [Push Message personalization](https://docs.hackle.io/en/development-guide/http-api/pages/jijFoP1pGiiQp2cBF8S9#2-2-개인화-메세지-작성). key(string)-value(string) |

#### Example

```shell
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 API returns a Success Response or Error Response object as the result of the send request.

#### Success (200)

{% hint style="info" %}
**A successful response to the Push Message send request does not guarantee that the user actually received the Push Message.**

Statistics on final delivery success can be checked in the Dashboard.
{% endhint %}

| Field      | Data Type | Description                                                   |
| ---------- | --------- | ------------------------------------------------------------- |
| dispatchId | string    | Unique UUID for the Push Message request triggered by the API |
| message    | string    | Contains the value "success".                                 |

**example**

```json
{
    "dispatchId": "bac3da45-f6e3-44ea-989e-e0fa0ffc9f5c",
    "message": "success"
}
```

#### Error

| Field   | Data Type | Description                    |
| ------- | --------- | ------------------------------ |
| code    | string    | A specific response error code |
| message | string    | A message describing the error |

**example**

```json
{
    "code": "INVALID_API_KEY",
    "message": "Invalid API key"
}
```

**error case**

| 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      | "API key not found"                                       | When no API KEY is included in the header                                             |
| 400         | EXCEED\_USER\_MAX\_LENGTH | "Max input length exceeded"                               | When the maximum number of target users that can be sent at once is exceeded          |
| 400         | CAMPAIGN\_NOT\_FOUND      | "Could not find push message campaign with the given key" | When no API-triggered campaign exists matching the given campaign key                 |
| 400         | EMPTY\_IDENTIFIER         | "At least one identifier should be given"                 | When neither userId nor deviceId is present in the target user info for the push send |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hackle.io/en/development-guide/http-api/api-push-message-send.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
