Operations

API response standard for every endpoint

Use this page as the single contract for success and error responses. Every JSON route uses the same envelope, status codes, error codes, headers, and serialization rules, so a client can read dates, missing values, empty lists, and identifiers the same way on every endpoint.

The envelope for every JSON route

Move every top level success field into data with the same field name, type and meaning. Keep the HTTP status a route already returns when its payload moves. Change a status and a payload in separate reviewed changes, never together.

Success

HTTP 200
{
  "ok": true,
  "data": { "items": [] }
}
  • ok is true. There is no error field on success.
  • data holds the values. An empty list is an empty array, never null.
  • A list also returns total, limit, offset, sort, filters and hasMore inside data.
  • A detail or create returns one record as data.item.

Error

HTTP 400
{
  "ok": false,
  "error": "Check the marked fields and try again.",
  "code": "validation_error"
}
  • ok is false. There is no data field on error.
  • error is a plain sentence telling the person what to do, with no secret, stack trace, address or internal detail.
  • code is optional and additive. A client uses the status table below, and must not parse message text.
  • Never return 200 with ok false, and never return ok true with error.

Status codes and error codes

Throw HttpError with the status in this table, or return the same status with the error envelope. Include code only when the route builds the response itself.

HTTP status, code name, and when to use it
HTTP statusCode nameWhen to use it
400validation_errorInput the person can fix, checked before any SQL runs. List fallbacks are not 400 errors.
401unauthenticatedSign-in is required. Documented only, with no change to sign-in in this standard.
403forbiddenThe signed-in role does not cover the action. Documented only, with no change to roles or permissions.
404not_foundNo record for that id in this workspace.
409conflictThe request conflicts with current state, such as a duplicate that is already saved.
408request_timeoutThe request timed out. Retryable, as already treated in public site form handling.
429rate_limitedToo many requests or a quota limit. Give wait guidance only from the server, with no exact wait time unless the server provides one.
502upstream_unavailableAn upstream dependency failed. Retryable.
503service_unavailableThe service answered but is not confirmed as live or ready. Retryable.
504upstream_timeoutAn upstream dependency timed out. Retryable.
500internal_errorAny other failure, in plain words with no internal detail.

Exception kept for backward compatibility: an existing route that returns 204 with no body keeps that status and body. POST /api/public/request keeps its 204 handling and must not be converted to JSON in the same change that moves another route. Keep error as a plain string there and add code only as an extra field.

Headers and serialization rules

Apply these rules at the edge for every resource class on the caching page, and inside data for every JSON route.

Content type, cache, and ETag by endpoint class
Endpoint classContent-TypeCache-ControlETag
GET /api/health, public livenessapplication/jsonprivate, no-storeNone. Each check is a fresh request with no sign-in and no cookies.
GET /api/readiness, signed-in readinessapplication/jsonprivate, no-storeNone. Never called from the public status page.
POST /api/public/request, public formapplication/json, or 204 with no body where the route already returns 204private, no-storeNone. A POST is never cached and never reused.
Signed-in /api routesapplication/jsonprivate, no-storeNo shared ETag reuse across people or colleges.

Dates, missing values, lists, and identifiers

  • Times are ISO 8601 in UTC with Z, for example 2026-11-06T14:17:20Z. Date only values are YYYY-MM-DD.
  • A missing value is null, never an empty string, the word null, or zero.
  • An empty list is an empty array, never null. A zero count is the number 0.
  • Identifiers are strings passed back unchanged, including numeric stored values, so leading zeros survive. A missing identifier is null.
  • Counts are JSON numbers and booleans are JSON booleans. Display formatting to local time happens on the client and is never written back as a stored timestamp.

List and detail semantics

  • List params are q, limit, offset, sort and the allowlisted filters already shown on that screen. Limit defaults to 50, falls back to 50 below 1, and clamps to 200 above 200. Offset defaults to 0 and falls back to 0 when negative or not a number.
  • Sort falls back to the endpoint default and the applied value is echoed in data.sort. Every sort ends with id ascending as a tie break. No sort value is interpolated from the request.
  • total is the filtered count before pagination, with the same workspace scope, test exclusion and filters as the items query. An offset at or past total returns items empty with total unchanged.
  • A detail id with no record in the workspace is a 404 with the error envelope, never data.item null with ok true.

Outliers found in this pack and the migration for each

Ship these migrations in this order, one route at a time. Keep the legacy reader in public site code until every route it calls has moved. Do not remove that reader in the same change that moves a route.

Outlier, where found, migration, and compatibility test
OutlierFound inMigrationCompatibility test
Envelope merge precedence differspublic site code merges data over top level fields, while the status page gives top level precedence over nested dataStandardize on top level precedence everywhere. A server writes only the envelope, and a client that accepts legacy forms on read normalizes both forms to the same values.Send a fixture with the same field at top level and inside data, plus a legacy flat fixture, and confirm both readers return the top level value and the legacy values.
Checked time shown as a locale stringLive check display in public site code and on the status pageShow ISO 8601 UTC with Z from the check, with the device local label beside it only as a label. Never write a locale string back as a stored timestamp, and never return an empty string for a missing time.Confirm the shown time parses as ISO UTC, a missing time shows null in JSON and no fabricated time on screen, and response time stays a number of milliseconds.
Cache-Control stated two ways for health endpointsHealth endpoints page states no-store, while the caching page states private, no-store for the live check and signed-in routesUse private, no-store for GET /api/health, GET /api/readiness, POST /api/public/request and signed-in routes, with Content-Type application/json and no ETag on health and readiness routes.Run curl -I for each route and confirm the header, then confirm the live check still runs fresh with no sign-in and no stored details.
Readiness route named in one place onlyOperations and status describe a signed-in readiness check with no route name, while the health endpoints page names GET /api/readinessUse GET /api/readiness as the exact route. Success returns ready fields inside data with exactly database, sign_in and workspace_store as ready or not_ready. A 401 uses code unauthenticated and a 403 uses code forbidden, with no data field and no checks object.Confirm a signed-in call returns the envelope, an unsigned call returns 401 with no data, and the public status page never calls the readiness route.
Legacy error forms still read on the clientPublic site error reader accepts error, error.message, message and nested data formsKeep that reader while routes are migrated. Servers write only the envelope from now on. Add code only as an extra field, and keep error as a plain string that the client displays directly.Confirm a legacy shape still parses, a new envelope shape parses, and a client never needs to parse message text to find the code name.
204 exception for the public form routePublic site form handling for POST /api/public/requestKeep the 204 with no body where the route already returns 204. Do not convert it to JSON in the same change that moves another route. Keep the retry rule that reuses the same request identifier.Confirm a successful form send still hides the form and shows a confirmation, and a failed send keeps entries for one retry with the same request identifier.
Duplicate list alias doubles payloadAPPKIT.md canonical list sample returned the same row array in data.items and in data.casesReturn the row array once, in data.items only. Do not repeat the same array under a second field name. Pagination with limit, offset, sort, filters, total and hasMore already bounds the payload to at most 200 rows.Confirm a list response has data.items with the same rows, fields and order as before, has no data.cases key, and is smaller in bytes, and confirm the pack screen sample still renders the same rows from data.items.

Concrete fix for each endpoint in this pack

Use this table when you move one route at a time. Each row states the shape found in this pack, the exact shape to ship, and the headers and field naming for that route. Keep the HTTP status a route already returns when its payload moves, and change a status and a payload in separate reviewed changes.

Endpoint, shape found in this pack, exact shape to ship, and compatibility test
EndpointShape found in this packExact shape to shipStatus, code, headers, and field namingCompatibility test
GET /api/cases, the sample list in APPKIT.mdTop level fields in an older form, and the same row array under a second field name in data.cases in an older form. The screen sample reads data.items first and data.cases second.HTTP 200, ok true, data with items, total, limit, offset, sort, filters and hasMore. The row array appears once, in data.items only. No data.cases key is returned.List fallbacks are not 400 errors. Limit defaults to 50, falls back to 50 below 1, and clamps to 200 above 200. Offset falls back to 0. Sort falls back to the endpoint default and the applied value is echoed in data.sort. Wire field naming is snake_case. Times are ISO 8601 in UTC with Z or null. Identifiers are strings or null. Content-Type application/json, Cache-Control private, no-store, and no shared ETag.Confirm data.items holds the same rows, fields and order as before, hasMore matches offset plus items length against total, an offset at or past total returns an empty array with total unchanged, and the screen sample renders the same rows from data.items alone.
GET /api/files, list with a ref filterNamed in APPKIT.md with no success shape stated. The screen list needs a bounded list with a total.HTTP 200, ok true, data with items, total, limit, offset, sort, filters and hasMore, using the same list rules as GET /api/cases. The ref filter is echoed in data.filters. The row array appears once, in data.items only.Same list fallbacks and clamps as GET /api/cases. A missing required field on a detail or create request is a 400 validation_error checked before any SQL runs. Wire field naming is snake_case. Content-Type application/json, Cache-Control private, no-store, and no shared ETag.Confirm the same rows render from data.items, the ref filter narrows items and total together, and an empty result returns an empty array, never null.
POST /api/files, create a saved fileNamed in APPKIT.md with no success shape stated.Success is ok true with one record in data.item, with the same timestamp and identifier rules as a list row. Keep the HTTP status a route already returns when the payload moves, and do not change a status and a payload in the same change.A missing required field is a 400 validation_error checked before any SQL runs. A duplicate that is already saved is a 409 conflict. A missing record is a 404 not_found. Error is a plain string with no data field. Code is added only as an extra field where the route builds the response itself. Content-Type application/json, Cache-Control private, no-store.Confirm a create returns data.item with string identifiers and ISO 8601 UTC times, a missing field returns 400 with no data field, and a duplicate returns 409 with no data field.
POST /api/public/request, demo and question formsPublic site code handles a 204 with no body and also reads ok and a plain error string. The route is the only public form route in this pack.Keep the current success handling, including the 204 exception where the route already returns 204. Where the route returns JSON, success is ok true with values in data and no error field. Keep error as a plain string and add code only as an extra field.Do not convert a 204 route to JSON in the same change that moves another route. A retry reuses the same X-Request-Id header value, so a retry does not create a duplicate request. Request fields use the form field names name, email, org, role and message, plus kind and page. Content-Type application/json where JSON is returned, Cache-Control private, no-store, and no ETag. A POST is never cached and never reused.Confirm a successful send still hides the form and shows a confirmation, a failed send keeps entries for one retry with the same request identifier, and a client that reads a legacy error form still reads the new envelope form.
GET /api/health, public livenessAn older flat form with ok, status, service and checked time at the top level, and a client merge that reads data over top level fields.HTTP 200, ok true, data with status live, service campus and checked_at. HTTP 503, ok false, error as a plain sentence, and code service_unavailable, with no data field.Show only live or not live. checked_at is ISO 8601 in UTC with Z or null, never an empty string. No dependency, version, configuration, address or secret field is returned. Content-Type application/json, Cache-Control private, no-store, no ETag, and no cookie. The client merge gives top level precedence over nested data, so a top level status, service and checked_at win over any nested value with the same name.Confirm the envelope form and a legacy flat form both read as live, a fixture with the same field at top level and inside data returns the top level value, a 503 holds no data field, and curl -I shows private, no-store with no ETag.
GET /api/readiness, signed-in readinessNamed as GET /api/readiness on the health endpoints page, and described with no route name on the operations and status pages. No envelope shape was stated on those pages.HTTP 200, ok true, data with status ready, checks with exactly database, sign_in and workspace_store as ready or not_ready, and checked_at. Any not_ready value makes ok false, status not_ready and HTTP 503, with no data field.A 401 uses code unauthenticated and a 403 uses code forbidden, with no data field and no checks object, because no check was run. Sign-in is required and the route is never called from the public status page. Content-Type application/json, Cache-Control private, no-store, and no ETag. No database name, address, version, configuration value or secret is returned.Confirm a signed-in call returns the envelope, an unsigned call returns 401 with no data, a call without the covering role returns 403 with no data, and the public status page calls only GET /api/health.
Every signed-in list and detail routeOlder routes may return top level fields, a duplicate list alias, a locale time string, or an empty string for a missing value.List success is data.items plus total, limit, offset, sort, filters and hasMore. Detail and create success is data.item. Error uses the status and code table on this page.Wire field naming is snake_case. Timestamps ending in _at are ISO 8601 in UTC with Z or null. Date only fields are YYYY-MM-DD or null. Identifiers are strings or null. Counts are JSON numbers and booleans are JSON booleans. Content-Type application/json, Cache-Control private, no-store, and no shared ETag.Confirm a list holds the row array once in data.items, a detail with no record in the workspace returns 404 with no data field, and a legacy shape still parses on read while servers write only the envelope form.
  • Client merge fix to ship with the first route move: in public site code, merge nested data under top level fields, not over them. The merged result keeps top level ok, status, service, checked_at, error and code where a top level value exists, drops the nested data container from the merged view, and still accepts a legacy flat form with no data field.
  • Migrate one route at a time, keep its field names inside data unchanged, keep its HTTP statuses, and add a test that the old client reader still parses the new shape and that a legacy shape still parses.
  • Do not move a 204 route and another route in the same change, and do not rename a field in the same change that moves it.

Migration order and checks before you ship

Apply the order below through the normal build, with no manual step. Each step keeps every existing test passing before the next step starts.

  1. Step 1: Lock the standard on this page

    Use the envelope, status and code table, headers, and serialization rules above for every new route. Do not add a new top level success field, a new error shape, or a new header rule in page text.

  2. Step 2: Fix client merge and time display first

    Change the client merge to top level precedence and change checked time display to ISO UTC with a device label beside it. Add the compatibility tests in the table above before any server route moves.

  3. Step 3: Move one route at a time

    Move one route at a time, keep its fields inside data unchanged in name, keep its statuses, and return a list row array once in data.items only, with no duplicate alias field. The pack screen sample reads data.items first, so the same visible rows render with no client change.

  4. Step 4: Align headers at the edge in the same release

    Set Content-Type application/json and Cache-Control private, no-store for the health, readiness, public form and signed-in classes in the table above. Confirm each header with curl -I before you publish.

  5. Step 5: Confirm the live and readiness checks end to end

    Confirm the public live check shows only live or not live, checked time and response time, and confirms the signed-in readiness check shows only ready or not ready per dependency. Confirm neither check shows a version, configuration value, address, secret or internal error text.

  • Every JSON success has ok true with values in data, and every JSON error has ok false with a plain error sentence and no data field
  • A client derives the code name from the status table and never parses message text, and a legacy shape still parses on read
  • Dates are ISO 8601 UTC or YYYY-MM-DD, missing values are null, empty lists are empty arrays, zero counts are 0, and identifiers are strings
  • List total, limit, offset, sort, filters and hasMore match the items shown, and an offset at or past total returns an empty list with total unchanged
  • A list response contains the row array once in data.items, with no duplicate field repeating the same rows, and the transferred size is smaller for the same visible rows
  • Headers match the table for the route class, and no signed-in response is cached in a shared cache

Use one contract on every endpoint

Apply the envelope and headers on this page to the next route you move, and keep the legacy reader until that move is complete.