> ## Documentation Index
> Fetch the complete documentation index at: https://docs.schedkit.net/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Push Notifications API

> Subscribe devices to web push and send test notifications.

## Overview

SchedKit uses Web Push (VAPID) to deliver notifications to subscribed browsers. Notifications fire automatically on `alert` signals, urgent/high incidents, and upcoming assignments.

## Endpoints

| Method   | Path                    | Description                  |
| -------- | ----------------------- | ---------------------------- |
| `GET`    | `/v1/push/vapid-public` | Get VAPID public key         |
| `POST`   | `/v1/push/subscribe`    | Register a push subscription |
| `DELETE` | `/v1/push/subscribe`    | Remove a push subscription   |
| `POST`   | `/v1/push/test`         | Send a test notification     |

***

## GET /v1/push/vapid-public

Returns the VAPID public key needed to subscribe a browser.

```json theme={null}
{ "publicKey": "BIa_HKGuR_doeyRc..." }
```

***

## POST /v1/push/subscribe

Register a browser's push subscription with SchedKit.

```js theme={null}
const reg = await navigator.serviceWorker.ready;
const sub = await reg.pushManager.subscribe({
  userVisibleOnly: true,
  applicationServerKey: vapidPublicKey
});

await fetch('/v1/push/subscribe', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ subscription: sub.toJSON() })
});
```

***

## DELETE /v1/push/subscribe

Unsubscribe the current device. Pass the endpoint to identify the subscription:

```json theme={null}
{ "endpoint": "https://fcm.googleapis.com/fcm/send/..." }
```

***

## POST /v1/push/test

Send a test push notification to all subscriptions for the current user. Useful for verifying the subscription is active.

```json theme={null}
{}
```

***

## Automatic push events

| Trigger                             | Notification                            |
| ----------------------------------- | --------------------------------------- |
| `alert` signal                      | `[~] ALERT SIGNAL — {operator}: {note}` |
| `urgent` or `high` incident created | `[!] URGENT — {title}`                  |
| `alert`-source incident             | `[!] {title}`                           |
| Upcoming assignment                 | `[◷] Upcoming: {event} in 15 min`       |
