# Action Buttons

A notification can carry up to three buttons. Instead of reading an alert and then opening a laptop to do something about it, you act from the lock screen: open the run, fire the restart, copy the code.

## The three types

| Type | What the button does | `value` holds |
|------|----------------------|---------------|
| `view` | Opens a URL | The URL, e.g. `https://status.example.com` |
| `http` | Sends an HTTP request in the background | A JSON string: `{"url":"…","method":"POST","headers":{…},"body":"…"}` |
| `copy` | Copies text to the clipboard | The literal text to copy |

For `http`, only `url` is required — `method` defaults to `GET`. When `body` is present and no content type is set, `Content-Type: application/json` is added automatically.

`http` and `copy` run without opening the app, even when it is closed. `view` brings the app or browser to the foreground.

## Where buttons appear

Buttons render in the system notification on both iOS and Android, whether the app is open, in the background or closed, and they also live inside the message itself. That second part matters: swipe the banner away and the buttons are still there when you open the message later.

- **Labels** are shown exactly as you send them on both platforms. If iOS can't prepare the custom buttons in time, it falls back to a generic label per type — **Open**, **Run**, **Copy** — and the buttons still work.
- **Lock screen.** `http` and `copy` run from the lock screen without unlocking. `view` opens the app or browser, so the phone asks to unlock first. On Android the buttons show on the lock screen only if it is set to show notification content.
- **Failed requests.** If an `http` request fails (a non-2xx/3xx status or a network error), a notification with a **Retry** button appears. A request that may have reached your server is never retried on its own.
- **App version.** System notification buttons need the Pocket Alert app 2.0.1 or later. Older versions show the buttons only inside the message.

## Approval workflows

Two `http` buttons — **Approve** and **Decline** — turn a notification into a one-tap control panel. The pattern works for anything that pauses waiting on a human:

- A deploy pipeline that blocks on manual approval
- An LLM agent that needs sign-off before it spends money or touches production
- A refund above a threshold
- A door, a gate, a light, a garage

The request goes straight from the phone to your endpoint. Pocket Alert does not proxy it, and does not see the response body.

> **Warning: Idempotency is yours**
>
> Tapping the same `http` button twice sends the request twice — we do not block repeats. If double-firing is expensive, make the endpoint idempotent.

## Buttons from webhooks

Webhooks can carry an action template with `%path%` placeholders, filled from the incoming payload. A Sentry alert can arrive with a working **Open issue** button pointing at that specific issue; a Stripe event with a **View payment** button for that charge.

Substituted values are JSON-escaped before the template is parsed, so a payload field containing quotes cannot break out and rewrite the URL. If a button resolves to something invalid, for example a **Runbook** button when the alert has no runbook URL, only that button is dropped; the rest of the buttons and the message are still delivered. A malformed button never costs you the alert.

You can set the template in the console when creating or editing a webhook, or through the [webhooks API](https://info.pocketalert.app/api/webhooks/create.md#action-buttons-template).

## Limits and validation

- Maximum **3** buttons per message; they render in the order you send them.
- The `actions` array may be at most **2048 bytes** once JSON-encoded. It travels inside the push, which is capped at 4 KB, so a long `message` is shortened to make room.
- `view` and `http` require a valid `http(s)` URL. Anything else returns `400` on the API; in a webhook template the invalid button is dropped.
- Unknown `type` values return `400`.

> **Warning: Paid feature**
>
> Action buttons are stripped from messages on free plans, server-side. The message itself is delivered normally.

## Related

- [Create Message](https://info.pocketalert.app/api/messages/create.md) — the `actions` array and full request reference
- [Priority levels](https://info.pocketalert.app/features/priority-levels.md) — how loudly the alert lands
- [Webhook Settings](https://info.pocketalert.app/api/webhooks/settings.md) — action templates on incoming webhooks
