# Send a push from your backend.

> Send push notifications from your backend with the Pocket Alert API. One authenticated HTTP POST from Node, Python, PHP, or Go reaches your phone in a second.

<!-- source: https://pocketalert.app/use-cases/api-alerts -->

The Pocket Alert API sends a push notification to your phone with a single authenticated HTTP POST. Fire it from Node, Python, PHP, or Go — title, message, priority level — and it hits your iPhone or Android almost instantly.

## Three steps to your first API push

1. **Get an API key** — Create an API key on the API Keys page and keep it in an environment variable.
2. **Send a request** — POST a JSON title and message to the messages endpoint with the key in the Token header.
3. **Ship it** — Your phone buzzes within a second. Add application and device targeting as your needs grow.

## Notifications, one request away

The API powers every Pocket Alert alert. Wire it into your backend with a single request.

- **Plain REST, no SDK** — One authenticated POST sends a push from the HTTP client you already use. No SDK, queue, or broker involved.
- **Any language** — Node, Python, PHP, Go, and Ruby can all fire a Pocket Alert notification.
- **Key-based auth** — Your API key rides in the Token header over HTTPS. Create, scope, and rotate keys on your own schedule.
- **Full control** — Route with application_id and target a single device_id, or omit it to reach every device, in one call.
- **Sub-second delivery** — Pushes reach your iPhone or Android in well under a second, quick enough to drive real-time backend alerts.
- **CLI & webhook ready** — The same API powers the CLI and webhooks. Start with code and layer in either one later.

## Send your first API notification

### 1. Get an API key

Create a key on the [API Keys](https://pocketalert.app/account/apikeys) page and send it in the `Token` header on every request.

### 2. POST a message

```
curl -X POST 'https://api.pocketalert.app/v1/messages' \
  -H 'Token: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{"title":"Order shipped","message":"Order #1024 is on its way","application_id":"qm47b9pzxzxg"}'
```

### 3. From your code

Call it from wherever an endpoint errors or a custom event fires, for example after a failed health check or a new order:

```
await fetch("https://api.pocketalert.app/v1/messages", {
  method: "POST",
  headers: { Token: process.env.POCKETALERT_KEY, "Content-Type": "application/json" },
  body: JSON.stringify({
    title: "API health check failed",
    message: "GET /v1/orders returned 500",
    application_id: "qm47b9pzxzxg",
    level: "high",
  }),
});
```

The full [getting-started docs](https://info.pocketalert.app/getting-started.html) cover application and device targeting.

## FAQ

### How do I send a notification via API?

POST to the Pocket Alert messages API with your key in the Token header and a JSON body holding the title and message. The notification lands on your phone right away.

### How does API authentication work?

Authenticate with an API key from the Settings page, sent in the Token header over HTTPS. Create and rotate keys whenever you need, and scope alerts per application.

### Which languages are supported?

Any language that makes an HTTP request works: Node, Python, PHP, Go, Ruby, and Rust. Nothing to install, just a plain REST call from the HTTP client you already use.

### What can I control in the request?

Set the title and message, route to a specific application with application_id, target one device with device_id (or omit it to reach every device), and set the priority with level — from silent to critical. A critical message breaks through Do Not Disturb on Android and cuts through Focus on iPhone.

### Is there a CLI or webhook option too?

Yes. The Pocket Alert CLI wraps the same API for scripts and CI. If you would rather skip code, create a webhook and point a service at its receive URL.
