Ephemeral databases
The create → use → destroy pattern for AI agents — provision a database via the API, run work against it, and tear it down.
An ephemeral database is one that exists only for the duration of a task: an agent creates it, uses it, and destroys it. Silos makes this practical because provisioning is fast, isolation is automatic, and idle databases scale to zero.
This page walks the full pattern with real API and CLI calls.
Create → use → destroy
Create the database
Provision a database under your project. Over the REST API:
curl -X POST "https://api.silos.sh/v1/projects/{project_id}/databases" \
-H "Authorization: Bearer $SILOS_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "database": { "name": "agent-task-8f3a" } }'Or from the CLI:
silos db create agent-task-8f3aYou get back the database's identifier and the details you need to connect.
Get a connection string
Fetch the connection string for the new database:
silos db connection-string agent-task-8f3aIt has the standard Postgres shape, with TLS required:
postgres://user:password@db-xxxx.silos.sh/main?sslmode=requireUse it
Connect with any Postgres client or driver and do the work — the engine is real PostgreSQL, so the agent has full SQL, transactions, and JSON at its disposal.
psql "postgres://user:password@db-xxxx.silos.sh/main?sslmode=require" \
-c "CREATE TABLE findings (id bigserial primary key, payload jsonb);"Destroy it
When the task is finished, delete the database so it stops consuming storage and billing:
curl -X DELETE "https://api.silos.sh/v1/projects/{project_id}/databases/{database_id}" \
-H "Authorization: Bearer $SILOS_API_KEY"Or from the CLI:
silos db delete agent-task-8f3aDoing it from an agent
The same flow expressed as steps an agent runs in sequence — API for create and destroy, the connection string for the work in between:
# 1. Create an isolated database for this task
silos db create "agent-task-$RUN_ID"
# 2. Get its connection string
DATABASE_URL=$(silos db connection-string "agent-task-$RUN_ID")
# 3. Do the work (any Postgres client)
psql "$DATABASE_URL" -f ./task.sql
# 4. Tear it down
silos db delete "agent-task-$RUN_ID"# 1. Create
DB=$(curl -s -X POST \
"https://api.silos.sh/v1/projects/$PROJECT_ID/databases" \
-H "Authorization: Bearer $SILOS_API_KEY" \
-H "Content-Type: application/json" \
-d "{ \"database\": { \"name\": \"agent-task-$RUN_ID\" } }")
# 2. Use the returned connection details to run work, then...
# 3. Destroy when done
curl -s -X DELETE \
"https://api.silos.sh/v1/projects/$PROJECT_ID/databases/$DATABASE_ID" \
-H "Authorization: Bearer $SILOS_API_KEY"Need a copy of an existing database's data for a task instead of a blank one? Create a branch — a copy-on-write fork — use it, then delete it. Same ephemeral lifecycle, but seeded with real data.
Why this is cheap
Because compute is only billed while a database is actually serving queries, an agent can keep many ephemeral databases around without paying for them to sit idle. Deleting them when done removes even the storage cost. See Lifecycle for the economics and cleanup strategies.