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.
Errors
Section titled “Errors”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." }] } }}codeis a machine-readableUPPER_SNAKE_CASEstring 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 (
CONFLICTor a state-specific code likeGRACE_EXPIREDorINVITE_NOT_REDEEMABLE). messageis a human-safe sentence clients can display directly.detailsadds 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.
Request ids
Section titled “Request ids”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_idon 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.
Rate limits
Section titled “Rate limits”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.
Audit details
Section titled “Audit details”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: 01jbz7w2n5r7t9v1x3z5b7d9f1At 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, metrics and logs
Section titled “Health, metrics and logs”/health/liveand/health/readyon a separate internal port (INTERNAL_PORT), answering{"status":"healthy"}.unhealthyis a 503.- Prometheus metrics at
/metricson the same port, named likehttp_requests_totalandhttp_request_duration_seconds. - JSON logs on stdout, with
snake_casefields: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-caseplural nouns, with no/apiprefix 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 useUPPER_SNAKE_CASE. - Permissions are lowercase, like
project:write.