Skip to main content

Basic encode

curl -X POST https://api.spectralmemory.com/encode \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "user_id": "alice",
    "label": "USER.gpu",
    "value": "RTX5090"
  }'
Each encode call re-encodes the full FDM block. All previously stored facts are preserved — only the specified label is updated.

Value constraints

Values are UTF-8 encoded and truncated to 4 bytes (32 bits). Values longer than 4 characters are silently truncated server-side.
ValueStored as
RTX5090RTX5 (truncated)
10241024
trainingtrai (truncated)
yesyes
For values longer than 4 characters, use abbreviations:
{"label": "TASK.current", "value": "train"}
{"label": "PROJ.status", "value": "run"}
{"label": "USER.gpu", "value": "5090"}

Overwriting a fact

Encode the same label with a new value. The channel is overwritten and the full block is re-encoded:
{"user_id": "alice", "label": "USER.gpu", "value": "A100"}

Multiple facts

Call /encode once per label. Each call updates the specified channel and re-emits the composite signal with all stored facts:
# Encode three facts
curl -X POST .../encode -d '{"user_id":"alice","label":"USER.gpu","value":"5090"}'
curl -X POST .../encode -d '{"user_id":"alice","label":"TASK.current","value":"train"}'
curl -X POST .../encode -d '{"user_id":"alice","label":"PROJ.token_budget","value":"1024"}'
After three calls, the [MEM] block encodes all three facts simultaneously across their respective carrier frequencies.

Usage tracking

Each encode call increments your monthly usage counter. /flush, /decode, and /context do not count against your limit.