Rensei docs

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.

POST
/api/cli/programs/{programId}/state

Authorization

headerAuthorizationBearer <rsk_live_*>

Rensei API key presented as Authorization: Bearer rsk_live_. Required API-key scopes are recorded per operation in x-rensei-required-scopes.

Path Parameters

programId*string
Match^prog_[0-9a-f]{32}$

Request Body

application/json
  1. body
key*string
Match^[a-z0-9][a-z0-9._-]*$
Length1 <= length <= 128
value*unknown
expectedVersion?|
Range1 <= value <= 9007199254740991

Response Body

State key written.

application/json
  1. response
ledgerVersion*string
programVersion*string
entry*
created*boolean
Example Request
curl -X POST 'https://app.rensei.ai/api/cli/programs/string/state' \  -H 'Content-Type: application/json' \  -d '{  "key": "string",  "value": null}'
Example Response
{  "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}