# Per-app KV store

Every app gets a small key/value store on the platform — handy for feature flags, counters, session state, and small caches without spinning up a table for them. Not a replacement for PocketBase: keep larger or structured data there.

Endpoints (authenticate with a full-scope API token — KV is excluded from the narrow deploy/env/read scopes entirely):
```
GET    /apps/<app>/kv          # list keys (size + expiry, no values)
GET    /apps/<app>/kv/<key>    # read a value (404 if missing or expired)
PUT    /apps/<app>/kv/<key>    # write a value (optional ttlSeconds)
DELETE /apps/<app>/kv/<key>    # delete a key
```

Limits: keys up to 256 chars, values up to 1 MB. Keys belong to one app, but the size quota is shared across every app on the owning account: the owner's plan sets it (the `kvStorageMb` limit), never above 256 MB per account, and a collaborator's writes count against the owner's quota. Expiring keys: pass `ttlSeconds` alongside `value` on write; expired keys read as 404 and are cleaned up automatically. Access is owner + admin collaborators — viewers can't read values, since flags and session state can be sensitive.

Values are encrypted at rest with the platform's AES-256-GCM key; keys and metadata remain queryable. Limits count plaintext UTF-8 bytes. The owner's `GET /account/export` includes decrypted KV rows under each app's `kv` field.

Example (a flag that expires after a day):
```sh
curl -X PUT https://api.percher.run/apps/my-app/kv/launch-banner \
  -H "Authorization: Bearer $PERCHER_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"value": "on", "ttlSeconds": 86400}'
```

Full guide: https://percher.app/docs/kv-store
