Introducing a new way to review your PRs.

Read the announcement

rajnandan1 / kener

Stunning status pages, batteries included!

View on GitHub

19 documents · Updated Nov 23, 2026

docs / public-api-v4

Version 4 public API

The version 4 public API is the program interface for managing Kener's status product. It lets an integration read and change site configuration, status pages, monitors, monitoring data, images, incidents, comments, maintenance schedules, and maintenance events through related REST routes. It is a child of the API and integration surface and connects to public status pages, monitoring history, and incidents and maintenance events.

API boundary

The v4 API is served below /api/v4. It uses an API key in a Bearer authorization header for all of its routes. The server checks that the key is active before it resolves a route and returns JSON errors for missing or invalid credentials. Write bodies follow the shared v4 request contract before a route saves data. The unversioned /api/status route is the separate public status check and is not part of the v4 resource set. (src/hooks.server.ts• L9-21, src/hooks.server.ts• L94-121)

The API uses resource-shaped JSON rather than one fixed response wrapper. Collection reads return a named array such as monitors, pages, incidents, or maintenances. Single-resource reads and writes return a named object such as monitor or incident. Validation failures use an error object with a code and message. API writes use the same domain actions as the dashboard, so alerts, cache updates, subscriber messages, and related records follow the same business rules. (src/…/api.ts• L8-15, src/…/api.ts• L37-69, src/…/no-direct-db-writes.test.ts• L3-11, src/…/write-parity.test.ts• L668-675)

References: src/hooks.server.ts• L9-21 src/hooks.server.ts• L94-121 src/…/no-direct-db-writes.test.ts• L3-11 src/…/write-parity.test.ts• L668-675

Resource map

The API models the status system as a set of linked resources. A page, incident, or maintenance points to monitors by tag. A maintenance owns its generated events. An incident owns its comments. Monitoring data belongs to one monitor and is addressed by a minute-aligned timestamp. Images provide reusable assets for site content and return an asset URL.

flowchart LR
    Site[Site configuration]
    Page[Status page]
    Monitor[Monitor]
    Data[Monitoring data]
    Incident[Incident]
    Comment[Incident comment]
    Maintenance[Maintenance]
    Event[Maintenance event]
    Image[Uploaded image]

    Page -->|monitor tags| Monitor
    Monitor -->|timestamped samples| Data
    Incident -->|monitor tags and impact| Monitor
    Incident -->|nested comments| Comment
    Maintenance -->|monitor tags and impact| Monitor
    Maintenance -->|scheduled occurrences| Event
    Site -->|site-wide settings| Page
    Site -->|content assets| Image

The route shape follows these relationships. Parent identifiers are not only labels: nested routes verify that the child belongs to the parent. This prevents a valid comment or event from being accessed through the wrong parent route. (src/hooks.server.ts• L135-203, src/…/+server.ts• L37-83, src/…/+server.ts• L44-67)

References: src/…/+server.ts• L37-83 src/…/+server.ts• L44-67

Site configuration

Site configuration exposes the values that control the shared status experience. The collection route returns all stored settings. The key route reads or updates one allowed setting at a time, so integrations can change one site concern without sending the full site configuration.

RouteMethodsResource role
/api/v4/siteGETRead all site settings as site_data.
/api/v4/site/:config_keyGETRead one setting.
/api/v4/site/:config_keyPATCHValidate and replace one setting value.

Keys have a known data type. String settings remain strings while object settings are returned as JSON values. The API accepts only known keys and validates each value before it stores the change. Secret fields in supported OIDC and CAPTCHA settings are masked in responses. When a PATCH omits an existing secret or sends its mask, the stored secret remains private and is preserved; a mask sent for a setting with no stored secret is not saved as a credential, so CAPTCHA protection stays fail-closed when its keys are incomplete. (src/…/+server.ts• L5-18, src/…/+server.ts• L11-54, src/…/+server.ts• L57-128, src/…/siteDataKeys.ts• L12-18, src/…/siteDataController.ts• L75-131, src/…/captchaController.ts• L63-91)

References: src/…/+server.ts• L5-18 src/…/+server.ts• L11-128 src/…/server.test.ts• L25-60

Status pages

Status pages define the public surfaces that group monitors and control how incidents, maintenance, history, and page branding appear. The page response includes its path, display text, settings, timestamps, and an ordered list of monitor tags.

RouteMethodsResource role
/api/v4/pagesGETList pages with their monitor links.
/api/v4/pagesPOSTCreate a page and optionally attach monitors.
/api/v4/pages/:page_pathGETRead one page by its public path.
/api/v4/pages/:page_pathPATCHChange page content, settings, path, or the full monitor list.
/api/v4/pages/:page_pathDELETERemove a non-home page.

The home page has no stored path. The API exposes it through the ~home path token so that it can use the same item route as other pages. The home page cannot be renamed or deleted. Page paths are made URL-friendly and must be unique. (src/…/+server.ts• L16-33, src/…/+server.ts• L49-163, src/…/+server.ts• L45-63, src/…/+server.ts• L81-124, src/…/+server.ts• L253-284)

Page settings support partial updates. An omitted setting stays unchanged, and a supplied monitor array replaces the page's current monitor links. Each referenced monitor must already exist, and a monitor tag cannot appear twice in the list. (src/…/+server.ts• L152-231)

References: src/…/+server.ts• L16-33 src/…/+server.ts• L45-150 src/…/+server.ts• L152-284

Images

The image resource lets an integration upload a site asset and receive a stable asset URL. It accepts base64 image data and can fit the image to requested bounds before storage.

RouteMethodsResource role
/api/v4/imagesPOSTValidate, process, store, and return image metadata.

The upload response includes an image ID, asset URL, MIME type, dimensions, and stored size. The service accepts PNG, JPEG, WebP, HEIC, and HEIF input, rejects SVG content, checks that the declared type matches the data, and limits the upload to 2 MB and 4096 pixels on each side. max_width and max_height preserve the image shape unless force_dimensions requests an exact crop. Invalid input returns BAD_REQUEST without storing an image, while a storage failure returns a fixed INTERNAL_ERROR response. (src/…/+server.ts• L7-37, src/…/server.test.ts• L36-139, src/…/imageController.ts• L28-136)

References: src/…/+server.ts• L7-37 src/…/server.test.ts• L36-183 src/…/imageController.ts• L28-136

Monitors and monitoring data

Monitors are the primary objects that Kener checks and displays. A monitor has a stable tag, a name, a check type, status settings, visibility, and type-specific data. The tag is the route key and cannot change through the API.

RouteMethodsResource role
/api/v4/monitorsGETList monitors with optional status, category, type, and hidden-state filters.
/api/v4/monitorsPOSTCreate a monitor. The tag and name are required.
/api/v4/monitors/:monitor_tagGETRead one monitor.
/api/v4/monitors/:monitor_tagPATCHChange monitor settings while keeping its tag.
/api/v4/monitors/:monitor_tagDELETERemove the monitor and its linked operational data.

Monitor reads mask secrets in type-specific data. Updates merge supplied type data and monitor settings with stored values, so a masked secret can be returned by a client without replacing the stored secret. New heartbeat monitors can receive a generated secret, while proxy and heartbeat values are checked before the monitor is saved. (src/…/+server.ts• L91-150)

Deleting a monitor also removes data and links that use its tag. This includes links from pages, incidents, and maintenances, along with related alert and group records. Integrations should therefore treat monitor deletion as a domain-wide change rather than only a configuration change. (src/…/+server.ts• L20-155, src/…/+server.ts• L172-186)

Monitoring data records the observed status and latency for a monitor at a UTC timestamp. The range route reads a half-open time window, while the timestamp route reads or changes one minute-aligned point. Both routes also support API-written data for manual correction or externally supplied observations.

RouteMethodsResource role
/api/v4/monitors/:monitor_tag/dataGETRead points between start_ts and end_ts.
/api/v4/monitors/:monitor_tag/dataPATCHWrite one status and latency across a time range.
/api/v4/monitors/:monitor_tag/data/:timestampGETRead one point.
/api/v4/monitors/:monitor_tag/data/:timestampPATCHWrite or change one point.

The API normalizes data timestamps to the start of a UTC minute. Valid status values are UP, DOWN, and DEGRADED. A manual write updates the latest-value view and requests alert evaluation after the data write. (src/…/+server.ts• L15-139, src/…/+server.ts• L15-154)

References: src/…/+server.ts• L20-155 src/…/+server.ts• L22-186 src/…/+server.ts• L15-139 src/…/+server.ts• L15-154

Incidents and comments

Incidents represent operational problems that can be shown on status pages. An incident has a time window, state, source, public URL, and optional monitor links. Each monitor link carries an impact value so one incident can describe different effects across services.

RouteMethodsResource role
/api/v4/incidentsGETList incidents. Filter by time range or monitor tags.
/api/v4/incidentsPOSTCreate an incident and optionally link monitors.
/api/v4/incidents/:incident_idGETRead one incident.
/api/v4/incidents/:incident_idPATCHChange its title, time window, or monitor links.
/api/v4/incidents/:incident_idDELETERemove the incident and its related records.
/api/v4/incidents/:incident_id/commentsGETList active comments for the incident.
/api/v4/incidents/:incident_id/commentsPOSTAdd a comment and set the incident state.
/api/v4/incidents/:incident_id/comments/:comment_idGETRead one comment belonging to the incident.
/api/v4/incidents/:incident_id/comments/:comment_idPATCHChange comment text, time, or state.
/api/v4/incidents/:incident_id/comments/:comment_idDELETEHide the comment from active comment reads.

Incident and comment times use UTC seconds and are normalized to minute starts. Comment states are INVESTIGATING, IDENTIFIED, MONITORING, and RESOLVED. A comment changes the incident state. A resolved comment sets the incident end time, while a later non-resolved comment can reopen it and clear that end time. An incident update can also clear its end time by sending end_date_time: null. Comment posts drive incident subscriber notices through the shared incident flow. (src/…/+server.ts• L18-79, src/…/+server.ts• L82-173, src/…/+server.ts• L68-145, src/…/+server.ts• L34-93, src/…/+server.ts• L92-175, src/…/incidentController.ts• L429-549)

Deleting a comment makes it inactive rather than removing its history. Deleted comments are absent from active comment lists and return 404 from their item route. A resolved comment cannot be dated before the incident start, and an invalid update leaves the comment unchanged. (src/…/+server.ts• L63-83, src/…/write-parity.test.ts• L729-761, src/…/incidentController.ts• L444-459)

References: src/…/+server.ts• L18-173 src/…/+server.ts• L23-159 src/…/+server.ts• L34-93 src/…/+server.ts• L37-233 src/…/incidentController.ts• L429-549

Maintenance schedules and events

A maintenance is a schedule definition. It contains a title, optional description, start time, recurrence rule, duration, active state, and monitor impacts. The system turns that definition into maintenance events, which represent individual scheduled occurrences and carry their own status and time window.

sequenceDiagram
    participant Client
    participant Maintenance as Maintenance resource
    participant Events as Maintenance events
    participant Status as Public status surface

    Client->>Maintenance: Create or update schedule
    Maintenance->>Events: Create or refresh occurrences
    Client->>Events: Read or change one occurrence
    Events-->>Status: Expose scheduled maintenance window

The schedule and event resources have separate routes. A schedule change refreshes generated events: for a one-time schedule it replaces the existing event, while for a recurring schedule it replaces only future SCHEDULED events. An event change can edit its window or move it to COMPLETED or CANCELLED; the event route does not accept a status transition and time-window edit in the same request. (src/…/maintenanceController.ts• L364-427, src/…/+server.ts• L79-204, src/…/+server.ts• L103-178)

RouteMethodsResource role
/api/v4/maintenancesGETList schedules. Filter by active state or monitor tag.
/api/v4/maintenancesPOSTCreate a schedule and its monitor links.
/api/v4/maintenances/:maintenance_idGETRead one schedule.
/api/v4/maintenances/:maintenance_idPATCHChange schedule fields, active state, or the full monitor list.
/api/v4/maintenances/:maintenance_idDELETERemove the schedule, its events, and its monitor links.
/api/v4/maintenances/eventsGETSearch events across schedules with filters and pagination.
/api/v4/maintenances/:maintenance_id/eventsGETList events for one schedule with pagination.
/api/v4/maintenances/:maintenance_id/events/:event_idGETRead one event belonging to the schedule.
/api/v4/maintenances/:maintenance_id/events/:event_idPATCHEdit its time window or complete or cancel it.
/api/v4/maintenances/:maintenance_id/events/:event_idDELETEDelete one event belonging to the schedule.

Maintenance times use UTC seconds and are aligned to minute starts. Recurrence uses an iCalendar RRULE string. Monitor impacts can be UP, DOWN, DEGRADED, or MAINTENANCE. Event list responses include both event fields and schedule fields, which lets a consumer build an event view without a second schedule lookup. Schedule and event writes reject invalid windows before they change stored data. (src/…/api.ts• L296-368, src/…/api.ts• L404-426, src/…/+server.ts• L34-209, src/…/+server.ts• L79-204, src/…/+server.ts• L103-178, src/…/+server.ts• L14-107)

References: src/…/maintenanceController.ts• L364-427 src/…/+server.ts• L34-209 src/…/+server.ts• L35-204 src/…/+server.ts• L44-214

Route-level relationships

The API uses a consistent relationship pattern: collection routes create or find a resource, item routes use that resource's stable key, and nested routes operate on children in the parent's scope. The following keys have distinct meanings.

ResourceRoute keyChild or linked resourceRelationship rule
Site settingconfig_keyNoneThe key must be in the allowed site setting set.
Pagepage_pathMonitor tags~home addresses the stored home page; monitor tags must exist.
Monitormonitor_tagMonitoring dataThe tag is stable and identifies all data routes for that monitor.
Incidentincident_idMonitor tags and commentsComment routes require both a valid incident and a comment belonging to it.
Maintenancemaintenance_idMonitor tags and eventsEvent routes require both a valid maintenance and an event belonging to it.
Monitoring pointtimestampNoneThe timestamp is interpreted as a UTC second value and aligned to a minute.
ImageidAsset URLThe returned ID identifies the stored asset URL; the upload route is write-only in v4.

The API also returns public URLs for incidents, maintenances, and maintenance events. Consumers should use those returned links because a maintenance schedule and one of its event records have different public-resource identities. Monitor deletion can remove the links that use a monitor tag, while incident and maintenance deletion removes their nested child relationships. (src/…/api.ts• L201-213, src/…/api.ts• L302-319, src/…/api.ts• L357-368, src/…/api.ts• L404-419, src/…/api.ts• L568-587, src/…/+server.ts• L172-186, src/…/+server.ts• L148-158, src/…/+server.ts• L44-74)

References: src/…/+server.ts• L45-62 src/…/+server.ts• L37-83 src/…/+server.ts• L44-67 src/…/+server.ts• L12-37

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep route parameter parsing and middleware resource lookup aligned. A route can return a false NOT_FOUND or read the wrong parent if their key rules diverge.
  • Keep the ~home page token aligned across page responses, page updates, and path lookup. A mismatch can make the home page unreadable after a read-modify-write cycle.
  • Keep monitor-tag validation aligned with page, incident, and maintenance association writes. A monitor deletion must also preserve the intended cleanup of all tag-based links and related monitor records.
  • Keep minute alignment and half-open range rules aligned between monitoring-data reads, writes, and updated_count responses.
  • Keep maintenance schedule changes aligned with event regeneration rules. A change to recurrence, start time, or duration can replace one-time events or future recurring events without changing past completed or cancelled events.
  • Keep event parent checks and returned event URLs aligned. An event ID is valid only inside its owning maintenance route, and its public URL can use a different resource path.
  • Keep incident comment state changes aligned with incident end-time changes, direct incident reopening, and subscriber notices.
  • Keep image validation and processing limits aligned with the returned MIME type, dimensions, stored size, asset URL, and fixed error responses.
  • Keep site-setting allowlists, value validators, and secret restore rules aligned with the settings consumed by the public status surface. A masked OIDC or CAPTCHA secret must not overwrite a real stored secret or become a new credential.

Important failure modes

TriggerConsequenceGuard
Missing or inactive Bearer API keyThe v4 request returns 401 and no resource lookup runs.Send an active API key in Authorization: Bearer <key>.
Unknown page path, monitor tag, incident ID, or maintenance IDThe route returns 404 before the resource handler runs.Resolve parent resources with the same route key used by the API.
Comment or event ID belongs to a different parentThe nested route returns 404 even when the child ID exists.Use the child ID with its owning incident or maintenance ID.
Invalid site key or valueThe site update returns 404 for an unknown key or 400 for an invalid value.Use the supported key and its expected string or object value.
A masked secret is sent for a setting with no stored secretThe mask is not saved as a credential. A dependent CAPTCHA provider remains misconfigured and rejects verification.Send a real secret when setting it for the first time. Omit an existing secret to preserve it.
Range start is not less than range endMonitoring data read or write returns 400.Send a UTC-second range with start_ts < end_ts.
Maintenance event status is combined with time fieldsThe event update returns 400 and applies no update.Use one request for a window edit or a separate request for completion or cancellation.
Home page is sent as a normal mutable path or delete targetThe page update or delete returns 400.Address the home page as ~home and keep its path unchanged.
Monitor deletion is treated as a local configuration changePage, incident, maintenance, monitoring-data, alert, or group records can disappear with the monitor.Check all tag-based relationships before deleting a monitor.
Resolved comment is dated before the incident startThe comment write returns 400 and does not save the comment or incident change.Use a comment timestamp at or after the incident start.
Image data is empty, invalid, oversized, unsafe, or mismatched with its MIME typeThe upload returns 400 and stores no image. A storage failure returns 500 without exposing the database error.Send valid non-SVG PNG, JPEG, WebP, HEIC, or HEIF data within the size and dimension limits.

Key files

FileWhy to read it
src/hooks.server.tsDefines the v4 authentication boundary and the shared lookup rules for route-level resources.
src/…/api.tsDefines the public resource shapes and request fields across all v4 domains.
src/…/+server.ts and src/…/+server.tsShow the whole-site and single-setting configuration relationship.
src/…/server.test.tsShows secret masking, partial secret preservation, and the fail-closed behavior for masked CAPTCHA credentials.
src/…/+server.ts and src/…/+server.tsShow page lifecycle, home-page addressing, settings patches, and monitor links.
src/…/+server.ts and src/…/imageController.tsShow image upload validation, processing limits, stored metadata, and asset URLs.
src/…/server.test.tsShows accepted image output, resize behavior, rejected input, and the fixed storage-failure response.
src/…/+server.ts and src/…/+server.tsShow monitor lifecycle, the stable tag resource key, secret handling, and domain-wide cleanup on deletion.
src/…/+server.ts and src/…/+server.tsShow range and point monitoring-data access under a monitor.
src/…/+server.ts and src/…/+server.tsShow incident filters, monitor impact links, direct reopening, and incident lifecycle.
src/…/+server.ts and src/…/+server.tsShow the incident comment child resource, state changes, resolution and reopen behavior, validation, and soft deletion.
src/…/incidentController.tsShows the shared incident rules for comment state, incident time, and subscriber notices.
src/…/+server.ts and src/…/+server.tsShow schedule creation, recurrence, monitor impacts, and schedule lifecycle.
src/…/+server.tsShows cross-schedule event search and the combined event response.
src/…/+server.ts and src/…/+server.tsShow parent-scoped event access and event state transitions.
src/…/write-parity.test.tsShows the intended parity between v4 writes and the dashboard's domain actions.