Skip to main content

Variables API

Fast key-value store for LLM state — counters, flags, last-seen timestamps, partial progress.


Variables API

The Variables API is a fast key-value store for ephemeral state. Unlike memories (which are indexed, searchable, and structured), variables are optimized for quick read/write access — perfect for counters, flags, and session state.

Endpoints

POST /var

Set or update a variable.

curl -X POST https://synapse.schaefer.zone/var \
  -H "Authorization: Bearer YOUR_MIND_KEY" \
  -H "Content-Type: application/json" \
  -d '{"key": "last_session_at", "value": "2026-06-27T14:00:00Z"}'

GET /var/:key

Get a single variable.

curl -H "Authorization: Bearer YOUR_MIND_KEY" \
     https://synapse.schaefer.zone/var/last_session_at

Response:

{ "key": "last_session_at", "value": "2026-06-27T14:00:00Z", "updated_at": "..." }

GET /var

List all variables.

curl -H "Authorization: Bearer YOUR_MIND_KEY" \
     https://synapse.schaefer.zone/var

DELETE /var/:key

Delete a variable.

curl -X DELETE -H "Authorization: Bearer YOUR_MIND_KEY" \
     https://synapse.schaefer.zone/var/last_session_at

When to Use Variables vs Memory

Use Case Use
User name, preferences Memory (searchable, structured)
Last session timestamp Variable (ephemeral state)
Counter (e.g. messages sent) Variable (frequent updates)
Workflow state ("step 3 of 5 done") Variable (transient)
Long-form project notes Memory (full-text indexed)
Reusable scripts Script store (named, versioned)

Common Patterns

Track last session

# At session end
curl -X POST .../var -d '{"key": "last_session_at", "value": "'$(date -Iseconds)'"}'

# At session start
LAST=$(curl .../var/last_session_at | jq -r .value)
curl .../memory/diff?since=$(date -d "$LAST" +%s)

Counter pattern

# Increment
N=$(curl .../var/api_calls | jq -r .value)
curl -X POST .../var -d "{\"key\": \"api_calls\", \"value\": $((N+1))}"

Feature flags

curl -X POST .../var -d '{"key": "feature_x_enabled", "value": "true"}'

# Check
ENABLED=$(curl .../var/feature_x_enabled | jq -r .value)
if [ "$ENABLED" = "true" ]; then ... fi

Next Steps