Bindings
On this page
Binding typesConfiguring bindingsListing bindingsUsing bindings in deploysAccessing bindings in your codeAllowed bindingsBindings connect your deployed functions to platform resources like key-value stores, databases, object storage, and message queues. Attach bindings at deploy time and access them through fold in your function code via @fold-run/runtime.
Binding types
| Type | Description | fold accessor |
|---|---|---|
key-value |
Key-value storage for fast reads | fold.kv |
database |
SQL database (per-organization) | fold.db |
object-storage |
Object storage for files and blobs | fold.storage |
queue |
Message queue for async processing | fold.queue |
Configuring bindings
Bindings are set up by your team admin in the dashboard at app.fold.run/console/bindings. Each binding has a logical name (like user-cache) and a type (key-value, database, object-storage, queue).
If you need a new binding, ask your team admin to create one from the dashboard.
Listing bindings
curl "https://api.fold.run/bindings" \
-H "Authorization: Bearer YOUR_TOKEN"Response:
{
"bindings": [
{
"id": "bind_abc123def456",
"tenant_id": "my-tenant",
"name": "user-cache",
"type": "key-value",
"resource_id": "kv-namespace-id"
}
]
}Using bindings in deploys
Attach bindings when deploying by including them in the intent.bindings array:
curl -X POST https://api.fold.run/deploy \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "my-api",
"code": "...",
"intent": {
"bindings": ["key-value:user-cache"]
}
}'The binding format is TYPE:name — the type and the logical name you gave it when creating the binding.
Or with the CLI via fold.json:
{
"name": "my-api",
"entrypoint": "function.ts",
"intent": {
"bindings": ["key-value:user-cache"]
}
}Accessing bindings in your code
Use @fold-run/runtime to access bindings through the typed fold object — no raw binding names needed:
import { defineHandler, type FoldContext } from '@fold-run/runtime';
export default defineHandler(async (fold: FoldContext) => {
// KV — key-value store
const cached = await fold.kv.get('session:abc');
await fold.kv.put('session:abc', 'value');
// DB — SQL database
const rows = await fold.db
.prepare('SELECT * FROM orders WHERE user_id = ?')
.bind('user-123')
.all();
// Storage — object storage
const file = await fold.storage.get('report.pdf');
await fold.storage.put('output.json', JSON.stringify({ ok: true }));
// Queue — async message passing
await fold.queue.send({ type: 'email', to: 'user@example.com' });
return fold.json({ ok: true });
});Each fold accessor maps to the binding attached to your function via fold.json or the dashboard (Functions → Bindings). The runtime resolves the correct resource at deploy time — you never reference binding names in code.
For the full fold API reference, see the `@fold-run/runtime` README.
Allowed bindings
Each organization has an allowlist of permitted binding types. If you try to deploy with a binding type that isn't allowed for your organization, the deploy will fail with BINDING_NOT_FOUND.
Contact your team admin or configure additional bindings in the dashboard.