Public State
Public state is versioned JSON state scoped by account, project, and environment. It is readable anonymously through the readonly route and readable or writable by developer bearer tokens or project API keys.
Use it for application config, feature flags, settings, announcements, theme values, safe limits, and catalog or inventory data. Do not use it for secrets, private user data, or inventory counts that require reservation-grade consistency.
Most developers should use the SDK, CLI, or console instead of calling these endpoints directly.
Developer Or API-Key Routes
text
GET /v1/{accountId}/projects/{slug}/public-state/{env}
PUT /v1/{accountId}/projects/{slug}/public-state/{env}
PATCH /v1/{accountId}/projects/{slug}/public-state/{env}
GET /v1/{accountId}/projects/{slug}/public-state/{env}/versionsThese routes accept Authorization: Bearer <developer-token> or Authorization: ApiKey <sky_...>.
Anonymous Readonly Route
text
GET /v1/readonly/{accountId}/projects/{slug}/public-state/{env}This route is used by SDK public-state reads. It sets ETag and Cache-Control; development and staging responses use a short cache window, while production responses use a longer one.
Write Semantics
- Public state must be a JSON object.
- Creates use
If-None-Match: *. The write succeeds only when no state exists yet; if state already exists it returns412. OnPATCH, the operations apply to an empty{}document. - Updates use a quoted positive version,
If-Match: "N". A stale or missing version returns412, andIf-Match: "0"always returns412. - When both headers are sent, the server evaluates
If-Matchfirst, following RFC 9110.If-Match: "N"together withIf-None-Match: *is an update-then-create write: it updates versionNif that version exists, and otherwise creates the state.If-Matchtogether with anyIf-None-Matchvalue other than exactly*returns400with{ error: "validation_error", message: "If-None-Match must contain only *" }. - A write with neither header returns
400with{ error: "validation_error", message: "If-Match or If-None-Match header is required" }. - Successful writes return
200withversion,state,comment,createdAt, andstateSizeBytes. - Every accepted
PATCHcreates a new version and returns200, even when the operations leave the data unchanged; thecommentis still recorded on that version. PATCHexpects anopsarray of JSON Patch operations and optionalcomment.