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

A slug that is not a published, public status page answers 404, and so does every subscribe request until the status site that the emailed links point to is configured. Status pages are published by PerkHost operators.

Reading a page

Status page read routes
RouteAuthQuerySuccess
GET /public/status/{slug}Publicnone200, the page: overall, groups of components with status, uptime and responseMs, activeIncidents, activeMaintenances, upcomingMaintenances
GET /public/status/{slug}/historyPublicmonth as YYYY-MM, optional200, the incidents and maintenances of that UTC month, previousMonth, nextMonth and truncated
GET /public/status/{slug}/incidents/{incidentId}Publicnone200, 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.
  • overall is the worst status of any component; when nothing is worse than operational it is maintenance if a component is under maintenance. A page with no components is operational.
  • uptime has one entry for each of the last 90 UTC days, oldest first and ending today. A day with no checks has uptimeBp null: no data is not 100 %. uptimeBp and uptimeBp90 are hundredths of a percent (9981 is 99.81 %); uptimeBp90 counts checks over the whole window, not the mean of the days. responseMs lists the days that have an average and a 95th percentile, in milliseconds.
  • groups[].name is null for components that belong to no group; that entry comes first. Components inside an incident or a maintenance are listed by id, and history and the incident route include components to map an id to its name.
  • history lists incidents by the time they started and maintenances by the time they were due to start, newest first, at most 200 of each (truncated says there were more). Without month it is the current month; the first month accepted is 2020-01. previousMonth and nextMonth are the nearest months that have an entry. upcomingMaintenances lists 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 month answers 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-After header.

Subscription routes

Status page subscription routes
RouteAuthRequest bodySuccess
POST /public/status/{slug}/subscribersPublicemail, optional componentIds (up to 50)202, a message, the same for every address
POST /public/status/subscribers/confirmPublic, emailed tokentoken204
POST /public/status/subscribers/unsubscribePublic, emailed tokentoken204
POST /public/status/subscribers/{subscriberId}/unsubscribe/{signature}Public, signature from the email headernone204
POST /public/status/subscribers/preferencesPublic, emailed tokentoken200, pageName, components (id, name) and componentIds
PUT /public/status/subscribers/preferencesPublic, emailed tokentoken, componentIds200, the preferences, as for the read

How a subscription works

  1. 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.
  2. 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.
  3. 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.
  4. Later emails carry a manage link. Its token reads the choices with POST /public/status/subscribers/preferences, changes them with PUT on the same path, and ends the subscription with POST /public/status/subscribers/unsubscribe, which is safe to repeat.
  • componentIds lists 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-Unsubscribe header, 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-After header.

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.

  1. Read the raw request body bytes before any JSON parsing: the signature covers the exact bytes.
  2. Parse the header t=<unix seconds>,v1=<hex>[,v1=<hex>]. Reject the request when t is more than a few minutes from your clock.
  3. Compute HMAC-SHA256, hex, over the text <t>.<raw body> keyed by your signing secret (the whsec_ value).
  4. Accept the request when your value equals any v1 in the header, compared in constant time.
  5. 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 v1 values, 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 one v1, 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.