# status.json format

Haunted House can show your own services. You write a `status.json` file, then load it from
a file on your computer or from an `https://` URL. The app validates the document in your
browser before it shows anything. Nothing is uploaded, stored or logged.

A machine-readable version of this format is in [`status.schema.json`](status.schema.json).
A working sample is in [`../examples/status.example.json`](../examples/status.example.json).

## Limits

- File or response size: at most 256 KiB.
- Timestamps are ISO 8601 in UTC, written as `YYYY-MM-DDTHH:MM:SS[.sss]Z`. Offsets such as
  `+02:00` are rejected. The calendar date must exist (`2026-02-30` is rejected).
- String lengths count Unicode code points, not UTF-16 units.

## Document

| Key             | Type   | Required | Rule                                         |
|-----------------|--------|----------|----------------------------------------------|
| `schemaVersion` | number | yes      | Must be `1`.                                 |
| `services`      | array  | yes      | 1 to 24 services.                            |
| `title`         | string | no       | Up to 60 characters. Shown as the house name.|
| `updatedAt`     | string | no       | Timestamp.                                   |

## Service

| Key           | Type   | Required | Rule                                                     |
|---------------|--------|----------|----------------------------------------------------------|
| `id`          | string | yes      | 1 to 32 characters from `a-z`, `0-9`, `-`. Unique in the document. |
| `name`        | string | yes      | 1 to 40 characters.                                      |
| `status`      | string | yes      | `up`, `degraded` or `down`.                              |
| `description` | string | no       | Up to 200 characters.                                    |
| `incidents`   | array  | no       | Up to 50 incidents. Defaults to an empty list.           |

## Incident

| Key      | Type   | Required | Rule                         |
|----------|--------|----------|------------------------------|
| `at`     | string | yes      | Timestamp.                   |
| `status` | string | yes      | `up`, `degraded` or `down`.  |
| `title`  | string | yes      | 1 to 80 characters.          |
| `detail` | string | no       | Up to 300 characters.        |

The app does not require incidents to be sorted. It shows the newest entry first.

## Unknown keys

Keys that are not listed above are ignored and never shown. They do not cause an error.

## Errors

If validation fails, the app keeps the current view and lists up to 20 errors. Each error has
a JSON path and a reason, for example `$.services[2].status: must be one of up, degraded, down`.
The path `$` is the document root.

## Example

```json
{
  "schemaVersion": 1,
  "title": "The Lantern Lane house",
  "services": [
    {
      "id": "cobweb-cache",
      "name": "Cobweb Cache",
      "status": "degraded",
      "incidents": [
        {
          "at": "2026-10-31T21:15:00Z",
          "status": "degraded",
          "title": "Something is rattling in the pantry",
          "detail": "Hit rate dropped while the cache warmed up."
        }
      ]
    }
  ]
}
```

## Notes

- The JSON Schema cannot express that `id` values are unique. The validator checks this.
- Use invented names and reserved example values (`example.invalid`, `192.0.2.0/24`) if you
  share a file publicly.
