Guide

Getting Started

TrashDB is a RESTful API for provisioning ephemeral database containers. Every container has a TTL, so it is automatically destroyed when the timer reaches zero. No cleanup, no lingering infra.

Authentication

All API requests require an API key passed via the X-Api-Key header. Generate a key from your Dashboard.

# All requests must include:
X-Api-Key: tr_live_xxxxxxxxxxxx

# Example with curl
curl https://api.trashdb.dev/api/v1/containers \
  -H "X-Api-Key: tr_live_xxxxxxxxxxxx"

CI / GitHub Actions

The fastest way to run integration tests with disposable databases. Use the official trashdb/run-tests action — it creates a container, injects the connection string into your environment, runs your tests, and destroys the container when done.

Setup

Save your API key as a repository secret in GitHub: Settings → Secrets and variables → Actions.

# .github/workflows/test.yml
name: CI

on: [push]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: trashdb/run-tests@v1
        with:
          api-key: ${{ secrets.TRASHDB_API_KEY }}
          engine: postgres
          run: npm test

Environment variables

The action automatically exports the right variable for each engine:

EngineEnv varAlso sets
postgresDATABASE_URLPGHOST, PGPORT, PGUSER, PGPASSWORD, PGDATABASE
supabaseDATABASE_URLPGHOST, PGPORT, PGUSER, PGPASSWORD, PGDATABASE
redisREDIS_URL
mongodbMONGODB_URI
chromadbCHROMA_URL
qdrantQDRANT_URL

How it works

  1. The action calls POST /containers to spin up an ephemeral database.
  2. It exports the connection string as DATABASE_URL (and engine-specific vars).
  3. Your test command runs — npm test, pytest, etc.
  4. On exit, the container is destroyed. If something crashes, the TTL auto-cleans it.

Your tests read process.env.DATABASE_URL as usual. No SDK imports, no connection string management, no cleanup code.

Supported Engines

TrashDB currently supports the following database engines:

chromadb

ChromaDB

qdrant

Qdrant

redis

Redis

postgres

PostgreSQL

mongodb

MongoDB

supabase

Supabase

Error Handling

The API returns standard HTTP status codes. Error responses include a JSON body with an internal code and a human-readable message.

StatusMeaning
200Success
201Container created
204Container destroyed
400Bad request — invalid engine or missing field
401Unauthorized — missing or invalid API key
404Container not found
429Rate limited
500Internal server error
// Error response body
{
  "code": ERR_ENGINE_NOT_FOUND,
  "message": "Engine 'mysql' is not supported"
}

// SDK usage
import { TrashDBAPIError } from "@trashdb/ts"

try {
  await client.destroyContainer(id);
} catch (error) {
  if (error instanceof TrashDBAPIError)
    console.error(error.status, error.message);
}