Namespaces and keys
State lives in namespaces of your account. A namespace is 1 to 128 letters, digits,., _ or -; a key is 1 to 512
bytes of UTF-8 (slashes allowed); a value is up to 1 MiB of bytes. Every key has a version that starts at 1 and grows by
one with every write.
Conditional writes
SendIf-Match: "<version>" on a PUT or DELETE to change the key only while it is still at that version, or
If-None-Match: * on a PUT that must create it. A mismatch answers 412 version_mismatch with currentVersion, and
nothing is written. This is how two sandboxes update one key without losing a write: read, change, write with the version
you read, and repeat on 412 (the TypeScript SDK’s state.update() does exactly this).
From inside a sandbox
Every sandbox findsSTYNE_SANDBOX_TOKEN, STYNE_SANDBOX_ID, STYNE_API_URL and, when it has a name,
STYNE_SANDBOX_NAME in its environment. The token opens the sandbox’s own namespace (its name, else its id) and nothing
else of your account, so no API key has to enter the sandbox:
403 forbidden.
Surviving a kill
The namespace of a named sandbox is its name. Kill it, create a new sandbox with the samemetadata["styne.name"], and the
new one reads the same state through /sandboxes/{new id}/state and its own token. An unnamed sandbox’s namespace is its
id: after a kill, read it with an API key at /state/{old id}.
Durability
A write answers once it is applied, and itsdurability field (also the styne-durability header) says how safe it is:
A write that answered
disk survives a restart of the store, of the API and of every sandbox. disk covers the store’s
primary machine: whether a second machine also holds it depends on the region’s replication, so treat the state store as
durable storage, not as a backup.
Limits and billing
A write past a ceiling answers
507 state_quota_exceeded with what you hold now; overwriting with a smaller value always
fits. Stored bytes are billed per GiB-month, metered every 15 minutes, to the API key of the account’s latest write (for a
sandbox, the key that created it); see billing.