# Status updates API

Read AppPortal service health, follow RSS and manage email and verified webhook updates.

Source: https://appportal.io/docs/api/status

Use `https://status.appportal.io` for AppPortal platform health and service updates. It is independent
of customer application telemetry. The [operation reference](https://appportal.io/docs/api/reference/status) and
[OpenAPI JSON](https://appportal.io/docs/api/contracts/status.json) describe public reads, email and webhook subscriptions, and RSS.

## Read service health

`GET /status` returns a consistent overview of components, active incidents, recorded uptime,
maintenance windows and monitoring freshness. Read `monitoring.state` alongside `overall`: a stored
Operational status does not prove a recent successful check. `generatedAt` is the response time,
not a new observation. A failure returns `503`, not an empty healthy overview.

| Request | Result |
| --- | --- |
| `GET /status/components` | Components and their nullable last-check times |
| `GET /status/incidents` | Active incidents and their updates, newest incident first |
| `GET /status/incidents/{incidentId}` | One incident, including a resolved incident |
| `GET /status/maintenance` | Windows with state derived at read time |
| `GET /status/history` | Recorded UTC days grouped by component |

Use `includeResolved=true` to include resolved incidents; other values exclude them. An optional
incident `limit` must be decimal text from 1 to 100. History `days` defaults to 90 and clamps integer
text to 1–90 days per component. A nonempty unknown `componentId` returns `404`; an empty value
returns an empty list. Query filters do not apply to the overview.

`uptimePercent` is successful checks divided by total checks, multiplied by 100, for the recorded
component and UTC day. Missing days and components with no history are absent, not 100% coverage.
An uptime day includes up to ten related monitor-incident IDs; `incidentLinksTruncated: true`
indicates more links exist. The overview and history read may choose different ten links when
more than ten episodes overlap a day.

Incident `resolvedAt` and component `lastCheckedAt` can be null. `postmortemUrl` and
`monitorEpisodeId` appear only when available. Update `postedBy` is the fixed `AppPortal` service byline. Operator identities remain internal.
A maintenance window becoming Complete does not establish that a component recovered.
Public JSON reads use `Cache-Control: no-store` and require no account credential.

For read errors, use the HTTP status and the stable `code` from the operation reference.
The JSON body includes the existing `error` message and a `traceId` that matches the
`X-AppPortal-TraceId` response header. Include that identifier if you contact support.

## Choose your updates

Read `GET /status/subscriptions/options` for service IDs and email/webhook availability. An empty
`componentIds` list selects all current and future services. RSS is available at
[`/status/feed.xml`](https://status.appportal.io/status/feed.xml) without a subscription.
It contains the latest 50 published incident and maintenance changes, with a 60-second cache.
A maintenance end is an event, not proof that a service recovered.

## Confirm email updates

Send `POST /status/subscriptions` from the Status site's own origin with `Content-Type: application/json`
and an `Origin` header exactly matching that origin:

```json
{
  "requestId": "88f726a3-d14c-4fd3-a810-e5cc05762efe",
  "channel": "email",
  "email": "morgan@trailworks.example",
  "componentIds": [],
  "consent": true
}
```

Use a new UUIDv4 for a new request. Reuse it when retrying the same normalized email and selected
services. A `202` means the confirmation request is saved; it does not mean the mailbox is verified
or a message reached the inbox. Open the confirmation email and explicitly confirm the subscription.
Pending confirmation links expire after 30 minutes.

JSON mutations accept at most 4,096 UTF-8 bytes within 10 seconds, with at most 16 selected service IDs.
Unknown fields and unknown service IDs are rejected. Email addresses are trimmed and lowercased;
service IDs are deduplicated and sorted before retry comparison.

## Manage a subscription

Mail links carry a private capability in a fragment. The Status page removes the fragment and keeps
the capability in memory. It sends `Authorization: Bearer <mail-link capability>` only to the exact
same-origin subscription routes. Keep capabilities out of request URLs, logs, persistent storage and referrers.
They grant access to one subscription, not an AppPortal account or operator tools.

| Request | Purpose |
| --- | --- |
| `GET /status/subscriptions/session` | Inspect the current state, masked email, service selection, revision and link expiry |
| `POST /status/subscriptions/confirm` | Confirm with the current `revision` and `consent: true` |
| `PUT /status/subscriptions/preferences` | Save the current `revision`, `componentIds` and `consent: true` |
| `POST /status/subscriptions/unsubscribe` | Cancel with the current `revision` |

Mutations also require the exact Origin and JSON content type. Management links expire after 90 days.
No GET confirms or cancels a subscription. All subscription routes reject query strings.
The `/api/status/status/...` compatibility aliases have the same behavior.

## Verify a webhook endpoint

On the Status page, choose **Choose webhook updates**, enter your endpoint, select services and
confirm endpoint control and consent. The pending page shows a masked **Private management token**;
save it securely. After your endpoint completes verification, select **Reload current subscription**.
When returning later, choose **Manage a webhook subscription** and paste your saved token. The page
keeps it in memory only; reloading clears it. Email links keep their existing confirmation flow.

API clients can check `webhookAvailable` and send same-origin JSON to `POST /status/subscriptions/webhooks`:

```json
{
  "requestId": "42301ac7-1532-44c5-8bbc-c61b80f8ece8",
  "channel": "webhook",
  "endpoint": "https://hooks.your-company.com/appportal-status",
  "componentIds": [],
  "consent": true
}
```

Use an HTTPS hostname on port 443 with a valid matching TLS certificate. The endpoint must have
public IPv4 A records. IPv6-only endpoints, literal IP URLs, private/local destinations, URL
credentials and fragments are not supported. Cloudflare's native TCP restrictions can also block
endpoints hosted on Cloudflare IPs. Redirects are never followed.

The initial `202 pending` response includes a `managementToken`. Preserve that private capability
securely: an exact request-ID retry returns pending but does not reveal the token again. Creation
allows one verification request per endpoint per hour, with 100 requests per hour overall.

Your endpoint receives a verification POST with this shape:

```json
{"schemaVersion": 1, "type": "verification", "challenge": "<random challenge>"}
```

Return a 2xx response with exactly one `AppPortal-Webhook-Challenge` header containing that challenge.
An ordinary 2xx without the matching header does not verify ownership. The subscription becomes
active only after this response; verification expires after 30 minutes. Changes published before
activation are not replayed. An empty `componentIds` list includes current and future services.

Use `Authorization: Bearer <managementToken>` for these routes:

| Request | Purpose |
| --- | --- |
| `GET /status/subscriptions/webhooks/session` | Read pending/active/unsubscribed state, endpoint hostname, service selection, revision and capability expiry |
| `PUT /status/subscriptions/webhooks/preferences` | Save the current `revision`, `componentIds` and `consent: true` after verification |
| `POST /status/subscriptions/webhooks/unsubscribe` | Cancel pending or active consent with the current `revision` |

Mutations require the exact Status Origin and JSON content type. Reload the session after a revision
conflict. Cancellation remains available when webhook delivery is disabled. To change an endpoint,
cancel and submit a new request with fresh owner proof. Cancelled or expired verification releases
the endpoint; the hourly request limit still applies. Management lasts 90 days, after which the
subscription expires. If you lose the capability, a pending verification expires after 30 minutes;
active consent lasts until cancelled or its 90-day expiry.

Updates have `schemaVersion`, `type: "status-update"`, `deliveryId`, stable `eventId`, `kind`, `title`,
`message`, `state`, `componentIds`, `occurredAt` and a public status `url`. Store `deliveryId` to
deduplicate requests; it is also the `Idempotency-Key` header. This protocol does not sign deliveries.
A 2xx acknowledges endpoint acceptance, not downstream completion. Payloads are limited to 32 KiB
and each attempt has an eight-second deadline. The response body is ignored.

Only failures before a POST can be sent retry, at most three preparations five minutes apart.
Non-2xx responses, including 429/5xx and redirects, are terminal rejections. A lost response,
malformed response or interruption after the attempt starts is UNKNOWN and is never retried
automatically. Notifications expire within 24 hours; cancellation clears queued content. A request
already in flight can still be accepted, but its receipt cannot restore cancelled consent.

## Handle a retry

| Response | Next action |
| --- | --- |
| `400` | Correct the body, content type, bounds or query string |
| `401` | Request a fresh email link; the capability is missing, expired or no longer valid |
| `403` | Use the Status site's exact origin |
| `409` | Reload and review the session; use a new request ID if the original request changed |
| `429` | Wait for `Retry-After`; the response also includes `retryAfterSeconds` |
| `503` | Keep the request and retry later; check channel availability |

For email, exact request-ID retries return the original pending result. Repeated confirmation or unsubscribe
with a valid management link returns its current state. A preference retry with an older revision
succeeds only when its normalized selection already matches the saved selection. Other stale
changes require review; do not overwrite them automatically.

Subscription responses are private and use `Cache-Control: no-store`. Public health reads and RSS
never return subscriber lists or private delivery records.
