# kv.entry.put

Writes one entry into the project's key-value store

# kv.entry.put

```
kv.entry.put --key TEXT --value JSON [--ttl DURATION] [--durable] → entry
```

Writes one entry into the project's key-value store. Write `--value` under `--key` in the project's key-value store (`--durable` for the disk-backed one), expiring after `--ttl` (a duration such as 600s or 1d; omitted, it never expires). Adds `entry: { key, ttl? }` and keeps the rest of the payload. An empty `--value` is refused.

## Flags

- `--key` (required): The entry to write. Usually a {{ }} expression.
- `--value` (required): What to store — a literal or {{ expr }}; a whole {{ }} keeps its type.
- `--ttl`: How long the entry lives, e.g. 600s, 10m or 1d. Omitted: it never expires.
- `--durable`: Use the disk-backed store, which survives a restart. Default: the in-memory one.

## Examples

### Remember an OAuth state for ten minutes

```
| kv.entry.put --key "oauth:state:{{ input.random.value }}" --value "{{ { started: new Date().toISOString() } }}" --ttl 10m
```

Read it back with `kv.entry.get --key …`; the payload passes on with `entry` added.

It answers:

```json
{
  "entry": {
    "key": "oauth:state:3f9c",
    "ttl": "600s"
  }
}
```

### Cache a query result across restarts

```
| kv.entry.put --key "home:posts" --value "{{ input.query.rows }}" --ttl 5m --durable
```

## Used in

- [Sign in with Google (OAuth login)](/examples/oauth-login-google.md)
