Skip to content

Standards

Plat5’s own services and starters follow a shared set of conventions for errors, request ids, pagination, health checks, and telemetry. Your services can follow the same conventions to give clients one error parser, uniform pagination, and correlated logs and traces out of the box.

Plat5 services and the gateway return errors in one JSON envelope:

{
"error": {
"type": "invalid_request_error",
"code": "VALIDATION_ERROR",
"message": "Title is required.",
"request_id": "7d6f1c2e-4b0a-4e8e-9a51-3f2b8c1d9e04",
"details": { "fields": [{ "path": "title", "message": "Title is required." }] }
}
}
  • code is a machine-readable UPPER_SNAKE_CASE string clients branch on alongside the HTTP status. Your services can define whatever domain codes fit them.
  • 422 means the input is wrong. 409 means the current state refuses it (CONFLICT or a state-specific code like GRACE_EXPIRED or INVITE_NOT_REDEEMABLE).
  • message is a human-safe sentence clients can display directly.
  • details adds structured context, like the fields of a 422 or the permissions that would have passed a 403.

Follow the same envelope in your services so clients handle gateway and app errors with one code path. Reference: errors.

The gateway gives every request an X-Request-ID and returns it on every response. The same id is in:

  • the error body, as request_id
  • the gateway’s log line for the request
  • your service’s log lines, when it logs the header it receives
  • the trace, as request_id on the request span
  • the audit event, as request_id

Don’t make your own and don’t set it on responses. Pass traceparent on to anything you call, so the trace follows.

Collection endpoints use cursor pagination (limit and starting_after), returning the collection under its plural name plus has_more, ordered by ULID id (audit logs newest first):

{ "tasks": [ … ], "has_more": true }

Plat5’s lists work this way, and so do the starters’. Full contract and defaults: Lists and pagination.

Limited routes return X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset. Over the limit is a 429 RATE_LIMITED with Retry-After and details.retry_after_seconds. Your service does nothing: the gateway sets them. Reference: rate limits, gateway.

On a write, your service says what changed in X-Plat5-Audit-Details: one JSON object, with each change as from and to. On a create, it sends the new id in X-Plat5-Audit-Created.

X-Plat5-Audit-Details: {"title":{"from":"Launch","to":"Launch v2"}}
X-Plat5-Audit-Created: 01jbz7w2n5r7t9v1x3z5b7d9f1

At most 4096 bytes, and never a secret. Plat5 stores them with the event and removes them before the response reaches the client. See audit.

  • /health/live and /health/ready on a separate internal port (INTERNAL_PORT), answering {"status":"healthy"}. unhealthy is a 503.
  • Prometheus metrics at /metrics on the same port, named like http_requests_total and http_request_duration_seconds.
  • JSON logs on stdout, with snake_case fields: request_id, route, method, status, duration_ms.
  • OpenTelemetry traces over OTLP, with W3C trace context.

Reference: health checks, telemetry.

Plat5’s own APIs follow these conventions (and the starters do too):

  • Paths are kebab-case plural nouns, with no /api prefix and no version segment. A route inside a project sits under the project’s path, /orgs/{organization}/projects/{project}/…, and the user’s own routes under /user/…. (The control plane requires lowercase canonical paths without trailing slashes.)
  • Ids in Plat5 are lowercase ULIDs with no prefix. Only secrets carry one: personal user keys (acme-uk-1-…), org-scoped member and service account keys (acme-mk-1-…), and invite tokens (acme-i-1-…), so secret scanners can find them.
  • Fields, log fields and metrics in Plat5 services use snake_case, and error codes use UPPER_SNAKE_CASE.
  • Permissions are lowercase, like project:write.