API
API reference: status pages
The public routes that read a status page, with its incidents and history, and the ones a status site uses to subscribe an address and manage the subscription.
Paths are relative to https://api.perkhost.com/api/v1. These routes need no sign-in: the person subscribing is a visitor. The subscription routes answer by page slug or by a token from an emailed link, never by a workspace id. A token that is malformed, unknown or revoked answers 404, with the same message, so a link reveals nothing about other subscribers.
Only published public pages take subscribers
Reading a page
| Route | Auth | Query | Success |
|---|---|---|---|
| GET /public/status/{slug} | Public | none | 200, the page: overall, groups of components with status, uptime and responseMs, activeIncidents, activeMaintenances, upcomingMaintenances |
| GET /public/status/{slug}/history | Public | month as YYYY-MM, optional | 200, the incidents and maintenances of that UTC month, previousMonth, nextMonth and truncated |
| GET /public/status/{slug}/incidents/{incidentId} | Public | none | 200, one incident with its timeline and the names of its components |
- Every 200 answer carries
generatedAt. These answers can be cached for 30 seconds and served stale for another 60 while they refresh, so a new incident can take up to 90 seconds to reach a cache; the server itself keeps no copy. A read that fails is never marked cacheable. overallis the worst status of any component; when nothing is worse than operational it ismaintenanceif a component is under maintenance. A page with no components isoperational.uptimehas one entry for each of the last 90 UTC days, oldest first and ending today. A day with no checks hasuptimeBpnull: no data is not 100 %.uptimeBpanduptimeBp90are hundredths of a percent (9981 is 99.81 %);uptimeBp90counts checks over the whole window, not the mean of the days.responseMslists the days that have an average and a 95th percentile, in milliseconds.groups[].nameis null for components that belong to no group; that entry comes first. Components inside an incident or a maintenance are listed by id, andhistoryand the incident route includecomponentsto map an id to its name.historylists incidents by the time they started and maintenances by the time they were due to start, newest first, at most 200 of each (truncatedsays there were more). Withoutmonthit is the current month; the first month accepted is 2020-01.previousMonthandnextMonthare the nearest months that have an entry.upcomingMaintenanceslists up to 20 scheduled windows.- Only published incidents are shown. A slug that is unknown, not published, private or malformed answers the same 404, and so does an incident id that is unknown, a draft or not on that page. A bad
monthanswers 400. - The routes are rate limited per client address, 240 requests a minute across all three, and a limited request gets 429 with a
Retry-Afterheader.
Subscription routes
| Route | Auth | Request body | Success |
|---|---|---|---|
| POST /public/status/{slug}/subscribers | Public | email, optional componentIds (up to 50) | 202, a message, the same for every address |
| POST /public/status/subscribers/confirm | Public, emailed token | token | 204 |
| POST /public/status/subscribers/unsubscribe | Public, emailed token | token | 204 |
| POST /public/status/subscribers/{subscriberId}/unsubscribe/{signature} | Public, signature from the email header | none | 204 |
| POST /public/status/subscribers/preferences | Public, emailed token | token | 200, pageName, components (id, name) and componentIds |
| PUT /public/status/subscribers/preferences | Public, emailed token | token, componentIds | 200, the preferences, as for the read |
How a subscription works
- Send the address to
POST /public/status/{slug}/subscribers. The answer is always the same 202 message, whether the address is new, waiting, already confirmed or refused, so the route never reveals who is subscribed. Nothing is sent to an address until it confirms. - A confirmation email carries a link. The link is valid for 48 hours, and an address that has not confirmed gets at most one confirmation email every 6 hours, however often it is submitted.
- The status site posts the token from the link to
POST /public/status/subscribers/confirm. An expired link answers 410, and the person subscribes again. - Later emails carry a manage link. Its token reads the choices with
POST /public/status/subscribers/preferences, changes them withPUTon the same path, and ends the subscription withPOST /public/status/subscribers/unsubscribe, which is safe to repeat.
componentIdslists the components to follow. An empty list, or none, means every component. An id that does not belong to the page answers 400.- Confirm and unsubscribe are POST, never GET, so a mail scanner that opens every link in a message cannot confirm or unsubscribe anyone. The confirm and manage tokens travel in the request body, not in a URL that a server logs.
- When the API's public address is configured, each notification email also carries a one-click unsubscribe link in its
List-Unsubscribeheader, which a mail app posts to without opening a page. Its signature sits in the URL path and can only unsubscribe that one address; it cannot read or change preferences. A wrong or foreign signature answers 404, and the route is rate limited per client address. - The routes are rate limited per address and per client address, and a limited request gets 429 with a
Retry-Afterheader.
Receiving status webhooks
A status page can also post each notification to an https endpoint. Endpoints are added, rotated, disabled and removed by PerkHost operators; this section is for the person who writes the receiver. A delivery is a POST with a JSON body { id, type, created, page, incident | maintenance } and these headers: X-PerkHost-Signature, X-PerkHost-Event (the type) and X-PerkHost-Delivery (unique per delivery). The type is one of incident.created, incident.updated, incident.resolved, maintenance.scheduled, maintenance.rescheduled, maintenance.cancelled, maintenance.started and maintenance.completed. A maintenance.rescheduled body carries the new startsAt and endsAt and the replaced window as previousStartsAt and previousEndsAt; a maintenance.cancelled body carries the cancelled window and its status is cancelled.
- Read the raw request body bytes before any JSON parsing: the signature covers the exact bytes.
- Parse the header
t=<unix seconds>,v1=<hex>[,v1=<hex>]. Reject the request whentis more than a few minutes from your clock. - Compute HMAC-SHA256, hex, over the text
<t>.<raw body>keyed by your signing secret (thewhsec_value). - Accept the request when your value equals any
v1in the header, compared in constant time. - Deduplicate on
X-PerkHost-Delivery(a retry after a lost response repeats the same id) and answer 2xx quickly.
- The signing secret is shown once, when the endpoint is created or its secret is rotated, and cannot be read again.
- After a rotation the replaced secret keeps signing for 24 hours: during that time every request carries two
v1values, the new secret's first. Switch your receiver to the new secret inside that window; a receiver that holds either secret verifies the request without a change. When the window ends the header carries onev1, so a receiver that still holds only the replaced secret no longer verifies requests. Rotating again inside the window ends the oldest secret at once, so only the two most recent secrets are ever valid. - Any 2xx is success. Anything else, a redirect included (never followed), a timeout of 10 seconds or a refused connection is retried after 30 seconds, 2 minutes, 10 minutes and 30 minutes, and the delivery is marked failed after 5 attempts. A target that is not allowed (a private or reserved address, or plain http) is not retried: the delivery fails at once.
- An endpoint that fails 10 delivery attempts in a row is disabled automatically and the operators are told. Only a delivered request resets the count, however far apart the failures are. A disabled endpoint receives nothing: the notices still waiting for it are marked failed, and neither they nor the ones it missed are sent again after an operator re-enables it.