# API reference

> Base URL, authentication, formats, errors, limits, and discovery files for the public Opush HTTP API.

The Opush API is plain HTTP. You can call it with `curl`, any HTTP library, or a no-code tool that sends webhooks. The push endpoints use the common push URL format, so existing clients and integrations work too.

## Base URL [#base-url]

```text
https://opu.sh
```

All endpoints on this page sit at the root of `opu.sh`. Enterprise deployments run on their own host, which may include a path prefix such as `https://opush.example.com/api`. Put the prefix in front of every path. See [Enterprise](/docs/enterprise).

## Endpoints [#endpoints]

| Area | Endpoints | Reference |
|---|---|---|
| Push | `/{device_key}`, `/push`, `/c/{push_key}` | [Push](/docs/api/push) |
| Questions | `/ask`, `/ask/{question_id}` | [Ask](/docs/api/ask) |
| Escalation alerts | `/alerts/{alert_id}` | [Alerts](/docs/api/alerts) |
| Heartbeats | `/hb/{check_id}` | [Heartbeats](/docs/api/heartbeats) |
| Status pages | `/s/{slug}`, `status.json`, `feed.atom`, `badge.svg` | [Status pages](/docs/api/status-pages) |
| MCP | `/mcp`, `/mcp/{device_key}` | [MCP server](/docs/agents/mcp) |
| Health | `/healthz`, `/ping`, `/info` | [Below](#health-checks) |

The `/v1` API is private. The Opush apps and web console use it, and it isn't covered here.

## Authentication [#authentication]

Most endpoints use a **secret in the URL** instead of a header. Whoever has the URL can use it, so treat each one like a password.

| Secret | Where you get it | What it allows |
|---|---|---|
| Device key (`YOUR_KEY`, 22 characters) | Your push URL in the app or web console | Send pushes and questions to that device, use `/mcp/{device_key}` |
| Channel key | The channel's push URL | Send pushes to a team channel |
| Check ID | A heartbeat's check-in URL | Check in for that heartbeat |
| Question ID (`q_…`) | The `/ask` response | Read or cancel that question |
| Alert ID (`al_…`) | The push response with `escalate` | Read or cancel that alert |

None of these give access to your account. If a URL leaks, replace it. The old one stops working right away:

- **Device key**: in the app, on the device's push URL (the web console can't change a device's key).
- **Channel key**: on the channel's page, in the app or the web console (the channel owner).
- **Check ID**: delete the heartbeat and create a new one. A check ID can't be changed.
- **Question and alert IDs** stop working on their own when the question or alert ends.

For account access, such as reading monitors or posting status page incidents, use [MCP](/docs/agents/mcp) with OAuth or a token (`Authorization: Bearer omt_…`).

Public status pages need no authentication at all.

<Callout type="info" title="Enterprise servers">
An enterprise server can also require HTTP Basic Auth on push and `/ask`. Send `Authorization: Basic …`. If it does, send MCP tokens in the `X-Opush-Token` header instead.
</Callout>

## Requests [#requests]

Push and `/ask` accept parameters in three ways:

- **Query string:** `?title=Hello&group=ci`. Good for `GET` and simple tools.
- **Form:** `application/x-www-form-urlencoded` or `multipart/form-data`.
- **JSON:** `Content-Type: application/json`. Best for code. Numbers and booleans can be real JSON types.

Text must be UTF-8. URL-encode values in paths and query strings.

## Responses [#responses]

### Push endpoints [#push-endpoints]

Push endpoints answer in the push response format. The HTTP status always matches `code`.

```json
{
  "code": 200,
  "message": "success",
  "timestamp": 1793546000,
  "data": { "escalation": { "alert_id": "al_…", "status_url": "https://opu.sh/alerts/al_…" } }
}
```

| Field | Meaning |
|---|---|
| `code` | Same as the HTTP status |
| `message` | `success`, another short status like `scheduled`, or an English error message |
| `timestamp` | Server time in Unix seconds |
| `data` | Only present when there is something to report |

Errors use the same shape, for example `{ "code": 400, "message": "failed to get device token: device key not found", "timestamp": 1793546000 }`.

### Other endpoints [#other-endpoints]

`/ask` and `/alerts` return plain JSON objects. Their errors look like this:

```json
{ "error": { "code": "not_found", "message": "Question not found." } }
```

`code` is a stable machine-readable string. `message` is for developers and can change.

### Formats [#formats]

- Field names use `snake_case`.
- Times are RFC 3339 strings in UTC, like `2026-11-04T09:30:00Z`. The `timestamp` in push responses is Unix seconds.
- IDs have a prefix (`q_`, `al_`, `sch_`) and are otherwise opaque. Don't parse them.

## Errors [#errors]

| Status | Meaning |
|---|---|
| `400` | Bad request: unknown key, invalid parameter, or broken JSON. Read `message`. |
| `401` | Authentication required (MCP without a token, or an enterprise server with Basic Auth) |
| `403` | Not allowed: the account was suspended, or a plan limit was reached. Read `message` |
| `404` | Not found |
| `413` | The push is larger than 4096 bytes |
| `429` | Too many requests. Wait for `Retry-After` |
| `500` | Delivery failed. Try again later |
| `503` | The device can't be reached, or the server is busy |

## Rate limits [#rate-limits]

When you go over a limit, you get `429` with a `Retry-After` header in seconds. When the server is briefly busy, you can get `503` with `Retry-After` too.

- Each device can receive a limited number of pushes per minute.
- A batch push can include a limited number of device keys.
- How many pushes, texts, calls, and monitors you get depends on your plan. See [Pricing](/pricing).

Don't hard-code limits. Retry after the time the server tells you.

## Versioning [#versioning]

- Push endpoints keep the same URL format, parameters and responses.
- Changes are additive: new fields, new endpoints, new values. Ignore fields you don't know, and handle unknown values in fields like `status`.
- The MCP server supports protocol versions `2025-11-25`, `2025-06-18`, `2025-03-26`, and `2024-11-05`.

## Health checks [#health-checks]

| Endpoint | Response |
|---|---|
| `GET /healthz` | Plain text `ok` |
| `GET /ping` | `{ "code": 200, "message": "pong", "timestamp": … }` |
| `GET /info` | `{ "version": "…", "build": "", "arch": "workers", "commit": "", "devices": 0 }`, the server info format push clients expect. The official server doesn't share its device count. |

## CORS [#cors]

CORS is enabled for `/mcp`, the discovery files below, and status page JSON (`status.json`), so browser code on any site can call them.

Push, `/ask`, and `/alerts` don't send CORS headers. Call them from a server, a script, or a backend function, not from browser code on another site. That also keeps your device key out of public web pages.

## Discovery [#discovery]

Opush publishes machine-readable files so AI agents and tools can find the API on their own. All of them allow CORS.

| File | What it describes |
|---|---|
| `/.well-known/api-catalog` | The API catalog (RFC 9727, `application/linkset+json`): MCP and the API, with links to docs and status |
| `/.well-known/mcp/server-card.json` | The MCP Server Card: tools, sign-in methods, and the endpoint. Also at `/.well-known/mcp.json` |
| `/.well-known/oauth-protected-resource` | OAuth protected resource metadata (RFC 9728), also at `/.well-known/oauth-protected-resource/mcp` |
| `/.well-known/oauth-authorization-server` | OAuth authorization server metadata (RFC 8414) |

```bash
curl https://opu.sh/.well-known/mcp/server-card.json
```
