# Sending pushes

> Every way to send a push to Opush, what the server returns, and how errors and limits work.

You send a push with one HTTP request to `https://opu.sh`. There are several ways to write that request. They all accept the same [parameters](/docs/push/parameters) and produce the same notification, so pick whichever fits your tool.

The push URL uses the common format and parameter names, so tools that send pushes by URL (Uptime Kuma, Apprise, iOS Shortcuts, your own scripts) work with Opush too.

## Path segments (GET) [#path-segments-get]

Put the text right in the URL. This is the quickest way to send from a terminal or a tool that only takes a URL.

| URL | What you get |
|---|---|
| `https://opu.sh/YOUR_KEY/<body>` | Body only |
| `https://opu.sh/YOUR_KEY/<title>/<body>` | Title and body |
| `https://opu.sh/YOUR_KEY/<title>/<subtitle>/<body>` | Title, subtitle, and body |

```bash
curl https://opu.sh/YOUR_KEY/Server%20alert/prod-1/CPU%20at%2095%25
```

URL-encode each segment. If your text contains `/` or is long, use query parameters or JSON instead.

## Query parameters (GET) [#query-parameters-get]

Add any parameter to the query string. You can mix this with path segments.

```bash
curl "https://opu.sh/YOUR_KEY/Disk%20almost%20full?group=servers&level=timeSensitive&url=https://grafana.example.com"
```

You can also put everything in the query:

```bash
curl "https://opu.sh/YOUR_KEY?title=Build%20passed&body=main%20%23128&group=ci"
```

## Form data (POST) [#form-data-post]

Send the parameters as `application/x-www-form-urlencoded` or `multipart/form-data`. `curl --data-urlencode` handles the encoding for you.

```bash
curl -X POST https://opu.sh/YOUR_KEY \
  --data-urlencode "title=Nightly report" \
  --data-urlencode "body=3 new signups, 0 errors" \
  --data-urlencode "group=reports"
```

POST also works on the path forms, such as `https://opu.sh/YOUR_KEY/<title>/<body>`. The extra parameters go in the request body.

## JSON (POST) [#json-post]

Send a JSON body to `https://opu.sh/push` with your key in `device_key`. This is the cleanest option for code: no URL encoding, and numbers can be real numbers.

<Tabs items={["curl", "JavaScript", "Python"]}>
<Tab value="curl">

```bash
curl -X POST https://opu.sh/push \
  -H "Content-Type: application/json" \
  -d '{
    "device_key": "YOUR_KEY",
    "title": "Payment failed",
    "body": "Invoice #1042 for $49.00",
    "level": "timeSensitive",
    "group": "billing"
  }'
```

</Tab>
<Tab value="JavaScript">

```js
const res = await fetch("https://opu.sh/push", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    device_key: "YOUR_KEY",
    title: "Payment failed",
    body: "Invoice #1042 for $49.00",
    level: "timeSensitive",
    group: "billing",
  }),
});
console.log(await res.json());
```

</Tab>
<Tab value="Python">

```python
import requests

res = requests.post("https://opu.sh/push", json={
    "device_key": "YOUR_KEY",
    "title": "Payment failed",
    "body": "Invoice #1042 for $49.00",
    "level": "timeSensitive",
    "group": "billing",
})
print(res.json())
```

</Tab>
</Tabs>

`/push` accepts POST only. You can also POST JSON to `https://opu.sh/YOUR_KEY`, in which case you don't need `device_key` in the body.

## Several devices at once [#several-devices-at-once]

To send the same push to more than one device, use `device_keys` in a JSON body sent to `/push`. It can be an array or a comma-separated string.

```bash
curl -X POST https://opu.sh/push \
  -H "Content-Type: application/json" \
  -d '{
    "device_keys": ["KEY_FOR_IPHONE", "KEY_FOR_ANDROID"],
    "title": "Release v2.0 is out"
  }'
```

`device_keys` only works in a JSON body. There is a maximum number of keys per request. If you go over it, you get a `400` error that states the limit.

When the same push reaches several devices on one account, opening or dismissing it on one device clears it on the others.

## How parameters are combined [#how-parameters-are-combined]

You can put a parameter in the path, the query, and the body at the same time. When the same name appears more than once, this order wins:

1. Path segments
2. Query string
3. Request body (form or JSON)

Parameter names are not case-sensitive: `isArchive` and `isarchive` are the same.

## Responses [#responses]

Every response is JSON in the push response format (`code`, `message`, `timestamp`). The HTTP status matches `code`.

```json
{ "code": 200, "message": "success", "timestamp": 1793546000 }
```

| Field | Meaning |
|---|---|
| `code` | Same as the HTTP status |
| `message` | `success` on success. `scheduled` when the push was [scheduled](/docs/push/parameters#scheduling) for later. Otherwise a short English explanation of the error. |
| `timestamp` | Server time in Unix seconds |
| `data` | Extra details, only when there is something to report (for example, the schedule ID and time) |

A batch request (`device_keys`) always returns `200`. Check each device in `data`:

```json
{
  "code": 200,
  "message": "success",
  "timestamp": 1793546000,
  "data": [
    { "code": 200, "device_key": "KEY_FOR_IPHONE" },
    { "code": 400, "device_key": "KEY_FOR_ANDROID", "message": "failed to get device token: device key not found" }
  ]
}
```

## Errors [#errors]

| Status | When it happens | What to do |
|---|---|---|
| `400` | The key doesn't exist, a parameter is invalid (for example, a broken button), or the JSON can't be parsed | Read `message`, fix the request |
| `403` | The account was suspended, or the device already has as many [scheduled pushes](/docs/push/schedule) as your plan allows | Contact support, or cancel a schedule |
| `404` | The URL isn't a push URL (the key must be exactly 22 letters and digits) | Copy the push URL again from the app or web console |
| `413` | The push is larger than 4096 bytes, the limit set by Apple's push service | Shorten the text, or move long content behind a `url` |
| `429` | Too many pushes in a short time, or your plan's pushes for today are used up | Wait for the number of seconds in the `Retry-After` header, then retry. For the daily limit, that can be until midnight UTC |
| `500` | Delivery to Apple or Google failed | Retry later |
| `503` | The device can't be reached (its push token expired), or the server is busy | Open the Opush app on the device to refresh its token. If the server is busy, wait for `Retry-After` |

A `503` saying the device is unreachable keeps coming back until the app is opened on that device.

## Limits [#limits]

- Each push must fit in 4096 bytes after Opush builds the notification.
- Each device can receive a limited number of pushes per minute. Over that, you get `429` with `Retry-After`.
- Your plan also sets how many pushes you can send. See [Pricing](/pricing).

Don't hard-code limits in your scripts. Handle `429` and retry after the time the server tells you.

## Health checks [#health-checks]

These endpoints help monitoring tools and push clients check the server:

| Endpoint | Response |
|---|---|
| `GET https://opu.sh/ping` | `{ "code": 200, "message": "pong", ... }` |
| `GET https://opu.sh/healthz` | Plain text `ok` |
| `GET https://opu.sh/info` | Server version |
