# Notification routes

> How the account notification routes authenticate, the errors and upgrade bodies they share, and an index of every saved place, contact, device, history, sunrise and outlook route.

API reference · Reference · https://wxalerts.org/docs/api/notifications/

Base URL: `https://api.wxalerts.org`

These routes are what the account page and the apps use to manage who is
told about weather, and where. They are **not** data routes: there is no API
key access, no `/v1` mirror and no anonymous use, apart from the few link and
status routes marked as such on their pages. They act on one account, the
signed-in one, and nothing here can read or change another account's data.

The matching guides are [Saved places](/docs/alerts/saved-places/),
[Rules and channels](/docs/alerts/rules-and-channels/),
[Webhooks](/docs/alerts/webhooks/),
[Guardian Line](/docs/alerts/guardian-line/) and
[Notification history](/docs/alerts/notification-history/).

## The pages

| Page | Routes |
| --- | --- |
| [Saved places](/docs/api/notifications-places/) | list, add, edit and remove saved places, with their sunrise, outlook, tropical, winter and lightning settings |
| [Text message enrollment](/docs/api/notifications-sms/) | the account holder's own phone number: start, verify, remove |
| [Contacts and people](/docs/api/notifications-contacts/) | people, contacts (text, voice, email, webhook), invitations, webhook tests, per-place rules, email confirm and unsubscribe links |
| [Guardian Line enrollment](/docs/api/notifications-guardian-line/) | the assisted calling tier for a voice contact |
| [Push devices](/docs/api/notifications-devices/) | phone installs, browser subscriptions and anonymous installs |
| [Notification history](/docs/api/notifications-history/) | the 90 day delivery log |
| [SPC outlook notifications](/docs/api/notifications-outlook/) | status, notification cards, what the outlook says at a place, unsubscribe |
| [Sunrise and sunset notifications](/docs/api/notifications-sky/) | status, evaluation cards, feedback, previews, unsubscribe |

The inbound webhooks that Twilio calls (text replies, call keypad presses,
call status) live under the same `/notifications` prefix but are not part of
the public API and are not documented here.

## Authentication

| Kind | Meaning |
| --- | --- |
| Signed in | A browser **session cookie**, or a **Bearer** access token from the WxAlerts phone app (`Authorization: Bearer ...`). Used by most routes here |
| Session only | Cookie only. A Bearer token gets `401`. Used by the text message enrollment routes |
| Link token | The signed `t` query parameter in an emailed link. No sign-in |
| None | Anyone |
| Device secret | The `X-Device-Secret` header of an anonymous push install, plus `X-Requested-With` |

An [API key](/docs/developers/api-keys/) is never accepted as a sign-in. A
Bearer token that is an API key (`wx_live_...`) gets `401` with
`detail.code` of `api_key_not_accepted`. A Home Assistant token works on the
Home Assistant routes only and gets `403` with `detail.code` of
`token_out_of_scope` here.

### CSRF header

Every method other than `GET` that uses a **cookie** must send
`X-Requested-With: wxalerts`, or it is refused with `403` and
`{"detail": "Missing X-Requested-With header."}`. A request that carries a
Bearer token is exempt. The anonymous device routes always require the header,
because they carry neither cookie nor Bearer token.

### Sign-in errors

| Status | Body | When |
| --- | --- | --- |
| `401` | `{"detail": "Not signed in."}` | no cookie and no Bearer token |
| `401` | `{"detail": "Session expired."}` | the cookie names no live session |
| `401` | `{"detail": "Access token is not valid."}` with `WWW-Authenticate: Bearer` | the Bearer token failed verification. Refresh it and retry |
| `401` | `{"detail": {"code": "api_key_not_accepted", "message": "..."}}` | an API key was sent as the Bearer credential |
| `403` | `{"detail": {"code": "account_disabled", "message": "..."}}` | the account is disabled |
| `403` | `{"detail": {"code": "account_deleted", "message": "..."}}` | a Bearer token for a deleted account |
| `403` | `{"detail": {"code": "token_out_of_scope", "message": "..."}}` | a Home Assistant token used outside its integration routes |
| `403` | `{"detail": "Missing X-Requested-With header."}` | a cookie write without the CSRF header |

## Error shape

Most errors in this area are `{"detail": "A sentence."}`, written to be shown
to a person. A request body that fails validation returns `422` in the
standard shape, one object per problem:

```json
{
  "detail": [
    {
      "type": "greater_than_equal",
      "loc": ["body", "lat"],
      "msg": "Input should be greater than or equal to -90",
      "input": -95,
      "ctx": { "ge": -90 }
    }
  ]
}
```

`loc` starts with `body`, `query` or `path` and names the field. Some routes
also refuse with a plain `422` and a sentence in `detail`; each route lists
those.

### Upgrade bodies (`402`)

`402 Payment Required` means the request was well formed and the account's
plan has no room for it. The body is machine readable so a client can offer
the upgrade. It is sent with `Cache-Control: no-store`. Two shapes exist.

A place limit, from `POST /notifications/places`:

```json
{
  "detail": "Your Free plan includes 1 place. Supporter includes 5.",
  "error": "place_limit_reached",
  "tier": "free",
  "tier_label": "Free",
  "max_places": 1,
  "places_used": 1,
  "upgrade_tier": "pro"
}
```

A channel the plan does not include, from `POST /notifications/sms`,
`POST /notifications/contacts` and `POST /notifications/contacts/{contact_id}/invite`:

```json
{
  "detail": "Text messages are part of Supporter, and your account is on Free. Every alert stays free on the live map and in the apps.",
  "error": "channel_requires_tier",
  "channel": "sms",
  "tier": "free",
  "tier_label": "Free",
  "required_tier": "pro",
  "upgrade_tier": "pro"
}
```

`error` is `sms_requires_tier` on the text enrollment route, `plan_required`
for a voice contact, and `channel_requires_tier` otherwise. `channel` is
`sms`, `email`, `webhook` or `voice`. `upgrade_tier` is `null` when no plan on
sale includes the channel.

Attaching a contact to a place beyond the plan's recipient count is also a
`402`, but with a plain `{"detail": "..."}` body. See
[`PUT /notifications/places/{place_id}/contacts/{contact_id}`](/docs/api/notifications-contacts/#put-notificationsplacesplace_idcontactscontact_id).

### Plan limits

The account's limits come back on the list routes (`max_places`,
`contacts_per_place`, `max_devices`) so a client can stop before the API
refuses.

| Plan key | Label | Places | Recipients per place | Channels |
| --- | --- | --- | --- | --- |
| `free` | Free | 1 | 1 | push, email, webhook |
| `legacy_supporter` | Donor | 5 | 1 | push, email, webhook |
| `pro` | Supporter | 5 | 5 | push, email, text, voice, webhook |
| `business` | Business | 10 | 5 | push, email, text, voice, webhook |
| `business_50` | retired larger business plan | 50 | 10 | push, email, text, voice, webhook |

Text and voice also have monthly allowances on the paid plans. Life-safety
warnings never count against them. See [pricing](/pricing/).

## Caching and rate limits

Every response here is `Cache-Control: no-store`, except where a route says
otherwise: the two `/status` routes and `GET /notifications/web-push/key`
are `public, max-age=300`. There is no per-route request limit on the signed
in routes. The anonymous device routes are limited per client address (see
[Push devices](/docs/api/notifications-devices/)), and text verification
codes are limited per number (see
[Text message enrollment](/docs/api/notifications-sms/)). A limit answers
`429` with a `Retry-After` header in seconds.

## Timestamps and units

Timestamps are ISO 8601 in UTC, written with a `Z` suffix, for example
`2026-11-23T18:04:11.532Z`, unless a field says it is local clock text
(`event_clock`, `valid_clock`). Coordinates are decimal degrees, latitude
-90 to 90 and longitude -180 to 180. Radii are kilometers; durations are
minutes or seconds as the field says.
