Compare-and-set write of one structured program state key.
Latest-wins per key with history: every write appends one versioned row. Omit expectedVersion (or null) to create the key; pass a version to require the current version to match. A mismatch is refused with 409, never merged. A program holds at most 1,000 distinct keys: creating one more is refused with 422 (existing keys keep writing; state is append-only, so keys are never removed). Queue actions append, claim and complete operate on the queue key with an explicit expectedVersion (null creates it). Append requires id, projectId and title; claim and complete require id. claimedBy is the server-derived principal ref. Non-open claims and completion by another principal are refused with typed codes. Every queue mutation appends a history row; queues over 16 KiB are refused. The author is derived from the authenticating principal and is never read from the body.
AuthorizationBearer <rsk_live_*>Rensei API key presented as Authorization: Bearer rsk_live_. Required API-key scopes are recorded per operation in x-rensei-required-scopes.
programId*string^prog_[0-9a-f]{32}$application/json- body
key*string^[a-z0-9][a-z0-9._-]*$1 <= length <= 128value*unknownexpectedVersion?|1 <= value <= 9007199254740991State key written.
application/json- response
ledgerVersion*stringprogramVersion*stringentry*created*booleancurl -X POST 'https://app.rensei.ai/api/cli/programs/string/state' \ -H 'Content-Type: application/json' \ -d '{ "key": "string", "value": null}'{ "ledgerVersion": "rensei.session-ledger/v1alpha1", "programVersion": "rensei.session-ledger.program/v1alpha1", "entry": { "ledgerVersion": "rensei.session-ledger/v1alpha1", "programVersion": "rensei.session-ledger.program/v1alpha1", "programId": "string", "key": "string", "version": 1, "value": null, "author": { "kind": "human", "id": "string" }, "createdAt": "2019-08-24T14:15:22Z" }, "created": true}Read the structured program state, latest-wins per key.
The queryable half of the ledger: one JSON value per key with its version, author and timestamp. With ?key=<key> reads that key append history newest-first (use limit to bound it); without it reads the latest value of the 500 most recently written keys (sorted by key), with truncated and the total keyCount when the program holds more. Visibility matches the program itself.
List typed session-ledger sessions for the authenticated organization.
Keyset-paginated index of admitted ledger sessions, newest first. Scoped to the authenticated organization and clipped to the calling credential project fence. Filters: projectId, graphId, phase. The response carries `nextCursor` only when more rows exist; pass it back verbatim as `cursor`. This is an index for recovering a sessionId - the canonical SessionRef, receipt bundle and event replay stay on the per-session routes.