- Tenant-scoped — all agents in your workspace read and write the same store
- Namespaces — created implicitly on first write, no setup required
- TTL — optional per-key expiration in seconds
- Pattern search — find keys with glob patterns like
cart:*:items - Any JSON value — objects, arrays, strings, numbers, booleans (up to 256 KB per entry)
KV Store vs Memory
The KV Store holds business state; Memory holds conversation context. A value youset() comes back exactly as stored, for as long as you need it — while Memory content is trimmed and summarized as the conversation grows.
| Need | Use |
|---|---|
| Cart contents, feature flags, counters, preferences, idempotency keys | KV Store |
| Message history, conversation summaries, session status, follow-ups | Memory |
Quick Start
import { KV } from '@runflow-ai/sdk/kv'.
Static Shortcuts
For one-off reads and writes, the static methods use thedefault namespace:
Namespaces
Namespaces isolate keys by domain. They are implicit: a namespace exists as soon as its first key is written, and disappears when its last key is deleted.., _ and - (max 128 characters, must start with a letter or digit).
TTL and Expiration
Passttl (in seconds) to make an entry expire automatically. Expired keys behave exactly like missing keys — get() returns null, has() returns false, and listings skip them.
Setting a key without
ttl clears any previous TTL — the entry becomes persistent. To keep a key expiring, pass ttl on every write.getEntry():
Pattern Search
keys() and getAll() accept a glob pattern: * matches any sequence of characters, ? matches exactly one.
Pagination
Listings return up to 100 items by default (max 1000). For large namespaces, uselistKeys() / listEntries(), which also return the total count:
Common Patterns
Cart / conversation state with TTL
Feature flags
Idempotency / deduplication
Managing Data in the Dashboard
Every namespace is browsable in the platform under KV Store in the sidebar:- Browse namespaces with live key counts
- Filter keys with the same glob patterns (
cart:*:items) - Inspect full JSON values and TTLs
- Delete individual keys or clear a whole namespace
Local Development
Outside the platform, the SDK follows the same convention as Memory: withRUNFLOW_ENV=development (or RUNFLOW_LOCAL_MEMORY=true) values are stored as JSON files under .runflow/kv/ in your project — no API required.
KvProvider interface (same pattern as custom memory providers).
Limits and Validation
| Constraint | Value |
|---|---|
| Value size | 256 KB per entry (JSON-serialized) |
| Key length | 1–512 characters, no control characters |
| Namespace | Letters, digits, ., _, - — max 128 chars |
| TTL | Integer ≥ 1 (seconds); omit for persistent |
| List page size | Default 100, max 1000 |
null / undefined values | Rejected — use delete() to remove a key |
Method Reference
| Method | Returns | Description |
|---|---|---|
get(key) | T | null | Value, or null when missing/expired |
getEntry(key) | KvEntry | null | Value plus expiresAt, createdAt, updatedAt |
set(key, value, { ttl? }) | { key, namespace, expiresAt } | Create or overwrite a key |
has(key) | boolean | Whether the key exists and is not expired |
delete(key) | boolean | true if the key existed |
keys(pattern?) | string[] | Key names, optionally filtered by glob |
getAll(pattern?) | KvEntry[] | Entries with values, optionally filtered |
listKeys(options?) | { keys, total } | Paginated key metadata |
listEntries(options?) | { items, total } | Paginated entries |
clear() | number | Delete all keys in the namespace |
listNamespaces() | KvNamespaceSummary[] | All namespaces with key counts |
KV (operating on the default namespace), plus KV.namespace(name) to get a scoped instance and KV.namespaces() to list namespaces.
REST API
Everything above is also exposed as authenticated REST endpoints under/api/v1/runtime/v1/kv — see the Runtime REST API reference if you’re integrating without the SDK.
Next Steps
Memory
Conversation history — use KV for state, Memory for dialogue
Tools
Read and write KV state from custom tools
Abandoned Cart Recovery
Complete project: KV cart state + Memory follow-ups
Schedule
Combine KV state with scheduled follow-ups