# Home Assistant instances

> Register a Home Assistant instance, read the quota, rotate its broker password, send heartbeats and revoke it, plus the deprecated single-login routes.

API reference · Reference · https://wxalerts.org/docs/api/home-assistant/

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

The [WxAlerts Home Assistant integration](/docs/integrations/home-assistant/)
signs in from Home Assistant, registers itself as an instance and gets a login
for the MQTT broker, over which everything else (alerts, storm cells, current
conditions and forecasts) is published. The website's Credentials page calls
the same routes with the session cookie. How instances count against the plan
is in [Manage instances and options](/docs/integrations/home-assistant/manage-instances/).

These routes are for the integration and the website. Write your own client only
if you are replacing the integration; for your own alerts over MQTT use an
[MQTT credential](/docs/api/mqtt-credentials/) instead.

## Access

Every route takes a signed-in account from the browser session or a Bearer
token. The integration's token is a Home Assistant sign-in, and it works only on
these `/integrations/home-assistant/` routes. The CSRF header is needed for a
cookie request that changes something and never for Bearer. The shared rules and
errors are in [Sessions, Bearer and CSRF](/docs/api/sign-in/#sessions-bearer-and-csrf).
Responses are `Cache-Control: no-store`.

Home Assistant is part of the Supporter plan. The quota is 1 instance, plus 1 for
each capacity pack. Revoking is allowed on any plan.

Errors that several routes share:

| Status | Body | When |
| --- | --- | --- |
| `403` | `{"detail": {"code": "supporter_required", "message": "...", "upgrade_url": "https://wxalerts.org/pricing/"}}` | registering or rotating on an account without the plan |
| `409` | `{"detail": {"code": "instance_limit", "message": "...", "limit": 1, "used": 1, "upgrade_url": "https://wxalerts.org/pricing/"}}` | the quota is full |
| `404` | `{"detail": {"code": "instance_not_found", "message": "No such Home Assistant instance."}}` | the instance id is not on this account (for rotate and delete, a revoked instance counts as unknown too) |
| `422` | default list | `instance_id` does not match `^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$` |

## `POST /integrations/home-assistant/instances`

Registers an instance and returns its broker login. This is the only response
that carries the password. The CSRF header is needed for a cookie request.

Body (JSON, optional):

| Field | Type | Default | Bounds |
| --- | --- | --- | --- |
| `instance_id` | string or null | a generated `manual-` id | Home Assistant's installation id. Pattern `^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$` |
| `name` | string or null | `Home Assistant` | Home Assistant's location name, at most 200 characters in the request. Stored cleaned: control characters dropped, whitespace collapsed, truncated to 100 characters |

A new instance answers `201`. Registering the same `instance_id` again answers
`200`: it rotates the password and keeps the username and the slot.

| Field | Type | Description |
| --- | --- | --- |
| `instance_id` | string | |
| `name` | string | |
| `username` | string | the broker username |
| `password` | string | shown once |
| `host` | string | `mqtt.wxalerts.org` |
| `port` | integer | 443 |
| `ws_path` | string | `/mqtt` |
| `transport` | string | `websockets` |
| `tls` | boolean | `true` |
| `topic_prefix` | string | the instance's own topic prefix, `wxalerts/u/<username>/` |
| `topics_version` | integer | present as `2` when the V2 topics are published for this instance. Absent otherwise |
| `v2_user_id` | integer | with `topics_version`: the account id for the topic names |
| `v2_instance` | string | with `topics_version`: the instance's key in the topic names. With the above, an instance reads alerts at `V2/<v2_user_id>/NWS/#` and the rest at `V2/<v2_user_id>/HA/<v2_instance>/<subtopic>` |

```json
{ "instance_id": "9f2c4b7e1a3d5c68", "name": "Home", "username": "ha-a1b2c3d4e5f6", "password": "...",
  "host": "mqtt.wxalerts.org", "port": 443, "ws_path": "/mqtt", "transport": "websockets", "tls": true,
  "topic_prefix": "wxalerts/u/ha-a1b2c3d4e5f6/", "topics_version": 2, "v2_user_id": 12345, "v2_instance": "a1b2c3d4e5f6" }
```

Errors: `403 supporter_required`, `409 instance_limit`, `422` as above.

## `GET /integrations/home-assistant/instances`

The quota and the instances. Any plan: a Free account sees `limit` 0. The quota is
applied before it answers, so an account whose plan lapsed sees its
deactivated instances and why. Revoked instances are not listed.

| Field | Type | Description |
| --- | --- | --- |
| `limit` | integer | the quota |
| `used` | integer | active instances |
| `instances[].instance_id` | string | |
| `instances[].name` | string | |
| `instances[].username` | string | |
| `instances[].created_at` | string | |
| `instances[].last_seen_at` | string or null | the last heartbeat |
| `instances[].active` | boolean | |
| `instances[].deactivated_reason` | string or null | `plan_lapsed` or `over_limit` |
| `instances[].topics_version`, `v2_user_id`, `v2_instance` | | as for registering, present only when the V2 topics are published |

```json
{ "limit": 1, "used": 1, "instances": [ { "instance_id": "9f2c4b7e1a3d5c68", "name": "Home", "username": "ha-a1b2c3d4e5f6",
  "created_at": "2026-11-10T14:00:00Z", "last_seen_at": "2026-11-23T16:59:00Z", "active": true, "deactivated_reason": null } ] }
```

## `DELETE /integrations/home-assistant/instances/{instance_id}`

Revokes an instance. Answers `204`. Its login stops working and its slot is
free. The publisher marks the instance offline, ends any session still open on
the broker and clears its retained topics. Allowed on any plan. `404
instance_not_found` if it is not yours.

## `POST /integrations/home-assistant/instances/{instance_id}/rotate`

A new broker password for one instance. Answers `200` with the same body as
registering, including `password`. Fails with `403 supporter_required`,
`409 instance_limit` or `404 instance_not_found`; a revoked instance is `404`.
No body.

## `POST /integrations/home-assistant/instances/{instance_id}/heartbeat`

The instance says it is alive. Records `last_seen_at` and takes the location
name if it changed. Body (optional): `{"name": string or null}`, at most 200
characters; a blank name is ignored.

Answers `200` with one instance, as in the list. A revoked instance still
answers, with `active` `false` and `deactivated_reason` `revoked`, so the
integration can tell the person instead of registering again. A deactivated one
shows `plan_lapsed` or `over_limit`. `404 instance_not_found` only when the id
was never on the account.

## Deprecated routes

The first release had one login per account. These three routes remain and answer
with `Deprecation: true` and a `Link` header pointing at the instances routes.
New code should not use them.

### `POST /integrations/home-assistant/credentials`

Gives the first (oldest visible) instance a new password. With none, makes a
manual instance named `Home Assistant`, which takes a slot. Answers `201` for a
new login and `200` otherwise. CSRF header for a cookie.

| Field | Type | Description |
| --- | --- | --- |
| `username` | string | |
| `password` | string | shown once |
| `broker_url` | string | the broker URL |
| `ws_url` | string | `wss://mqtt.wxalerts.org/mqtt` |
| `host`, `port`, `ws_path`, `transport`, `tls` | | as above |
| `topic_prefix` | string | |
| `topics_version`, `v2_user_id`, `v2_instance` | | as above |

Errors: `403 supporter_required`, `409 instance_limit`.

### `GET /integrations/home-assistant/credentials`

The first instance's login without its password: `username`, `created_at`,
`last_rotated_at` (string or null), `active`. `403 supporter_required` when the
plan does not include it; `404 {"detail": {"code": "no_login", "message": "No Home Assistant login yet."}}`
when none exists.

### `DELETE /integrations/home-assistant/credentials`

Revokes the first instance. Answers `204`. `404 {"detail": {"code": "no_login",
"message": "No Home Assistant login to revoke."}}` when none exists.
