No account required

Ephemeral PostgreSQL for AI Agents

One API call. A live PostgreSQL database in ~30 seconds. Auto-deleted after your TTL. No keys, no signup, no cleanup.

Works with LangChain, LlamaIndex, AutoGPT, CrewAI — and any HTTP client. Use as a temporary PostgreSQL sandbox, AI agent memory store, or testing database.

🤖
LangChain memory
Use SQLChatMessageHistory without a persistent DB
🧪
PostgreSQL sandbox
Test schema migrations and queries safely
🔁
CI / test fixtures
Spin up isolated DBs per test run, auto-cleaned
🚀
Prototype fast
No signup, no infra — start querying in 30s
📤
Step 1
Create the database
POST to /ephemeral/create with a TTL (1–60 min). You get back a database ID, username, password, and database name immediately. Save the password — it is only shown in this response.
🔄
Step 2
Wait for it to be ready
Poll GET /ephemeral/{id} every few seconds. Status goes provisioning → starting → running (~15–30s). Once running, the response includes host, port, and a ready-to-use connection string.
🐘
Step 3
Connect and run SQL
Use the connection string with any PostgreSQL driver. Or skip the driver entirely and POST SQL directly to /ephemeral/{id}/sql — returns rows, column names, and affected row count as JSON.
🗑️
Step 4
Auto-deleted at expiry
The TTL countdown starts the moment the database reaches running status. When it expires, everything is deleted automatically. No cleanup, no lingering resources.

Limits & constraints

TTL
1 – 60 min
default 60, server-enforced
Concurrent DBs
2 per IP
at any time
Create rate
5 / 10 min
successful only
SQL rows
500 max
per /sql request

Need longer-lived or higher-performance databases? Create a free account for persistent databases with no TTL.

API Reference

POST/v1/ephemeral/createNo auth
Request body
{
  "ttl": 60   // minutes (1–60)
}
Response 201
{
  "status": "success",
  "data": {
    "id": "a1b2c3d4...",
    "status": "provisioning",
    "ttlMinutes": 2,
    "username": "myuser",
    "password": "mypass",   // shown once — save it
    "database": "mydb",
    "pollUrl": "/v1/ephemeral/a1b2c3d4"
  }
}

Host and connection string are not available yet — the database is still starting. Retrieve them from GET /v1/ephemeral/:id once status=running.

GET/v1/ephemeral/:idNo auth

Retrieves the current status of the database, the time remaining before auto-deletion, and — once the database is ready — the full connection details.

Tip: Poll every 3–5s until status=running. The TTL countdown starts at that moment. Use secondsRemaining to know how much time is left.
Response 200 — while running
{
  "status": "success",
  "data": {
    "id": "a1b2c3d4...",
    "status": "running",
    "ttlMinutes": 2,
    "secondsRemaining": 87,
    "expiresAt": "2025-01-01T12:02:00Z",
    "host": "a1b2c3d4.db.dbaas.dev",
    "port": 31042,
    "username": "myuser",
    "password": "mypass",
    "database": "mydb",
    "connectionString": "postgresql://myuser:mypass@
  a1b2c3d4.db.dbaas.dev:31042/mydb"
  }
}
POST/v1/ephemeral/:id/sqlNo auth · No driver needed
Request body
{
  "sql": "SELECT * FROM memory"
}

Full DDL and DML supported. COPY ... FROM PROGRAM is blocked. Results capped at 500 rows.

Response 200
{
  "status": "success",
  "data": {
    "command": "SELECT 2",
    "rowsAffected": 2,
    "columns": ["id","role","content"],
    "rows": [
      {"id":1,"role":"user","content":"..."},
      {"id":2,"role":"assistant","content":"..."}
    ],
    "rowCount": 2
  }
}

Code Examples

No database driver needed. Send SQL as HTTP — works from Python requests, fetch, curl, or any HTTP client. Ideal for LangChain agents and sandboxed testing.
import requests, time

API = "https://api.dbaas.dev/v1"

# Step 1 — Request a new ephemeral database
# Returns your credentials immediately (id, username, password, database name).
db = requests.post(f"{API}/ephemeral/create", json={"ttl": 3}).json()["data"]
db_id = db["id"]
print(f"Created: {db_id}  user={db['username']}  db={db['database']}")

# Step 2 — Wait for the database to be ready (~15–30s)
# Poll GET /:id — status goes provisioning → starting → running.
# Once running, secondsRemaining shows how long until auto-deletion.
for _ in range(30):
    status = requests.get(f"{API}/ephemeral/{db_id}").json()["data"]["status"]
    print(f"  status: {status}")
    if status == "running":
        break
    time.sleep(3)

# Step 3 — Run SQL over HTTP — no database driver or pg client needed
# Works from Python, Node, curl, or any tool that can send HTTP requests.
def sql(query):
    return requests.post(
        f"{API}/ephemeral/{db_id}/sql",
        json={"sql": query}
    ).json()["data"]

sql("CREATE TABLE memory (id SERIAL, role TEXT, content TEXT)")
sql("INSERT INTO memory (role, content) VALUES ('user', 'What is 2+2?')")
sql("INSERT INTO memory (role, content) VALUES ('assistant', '4')")

result = sql("SELECT * FROM memory ORDER BY id")
for row in result["rows"]:
    print(f"[{row['role']}] {row['content']}")
# → {"command":"SELECT 2","columns":["id","role","content"],"rows":[...],"rowCount":2}

# Step 4 — Auto-deleted at TTL expiry. No cleanup. No lingering resources.

Error Codes

HTTP StatusReason
400Invalid TTL (must be 1–60) or malformed JSON body — does not count against your rate limit
404Database ID not found or already expired / deleted
410 GoneDatabase TTL has elapsed (expired)
422SQL syntax error — response body contains the PostgreSQL error message
429 (concurrent)Already have 2 active ephemeral databases from this IP
429 (rate limit)Exceeded 5 successful creates per 10 minutes from this IP
503Database not yet running — keep polling GET /:id until status=running

Ephemeral databases run on shared infrastructure. All activity is logged. Do not store sensitive data. Privacy Policy

DBaaS.dev — Managed PostgreSQL for Developers