# create-db (/docs/postgres/npx-create-db) > For the complete Prisma documentation index, see [llms.txt](https://www.prisma.io/docs/llms.txt). A markdown version of any docs page is available by appending `.md` to its URL. Create a temporary Prisma Postgres database with one command and no sign-up, for prototypes, tests and coding agents. Claim it with a Prisma account to keep it. Location: Postgres > create-db [`create-db`](https://create-db.prisma.io/) is an open-source CLI tool that provisions temporary [Prisma Postgres](https://www.prisma.io/docs/postgres) databases with a single command. * **Fast setup:** No sign-up required to create a temporary Prisma Postgres database. * **Lifetime:** 24 hours by default; `--ttl` sets 30m or 1h to 24h. * **Keep for free:** Claim the database with a Prisma account, using the claim URL in the CLI output. ## Prerequisites [#prerequisites] To use `npx create-db`, you need: * **Node.js** 20.5 or newer (we recommend the latest LTS version). * **npm** (comes with Node.js) to run `npx` commands. You don't need a Prisma account to create a temporary database. To keep one, claim it with a Prisma account ([details below](#claiming-your-database)). ### Option 1: Using the web interface (recommended) [#option-1-using-the-web-interface-recommended] The [create-db web application](https://create-db.prisma.io) provides a browser-based interface for creating and managing your databases. #### Key features: [#key-features] * No installation required - works directly in your web browser * Visual interface for database management * Connection string display and copying * Built-in schema viewer and editor * Direct integration with Prisma Studio * Database claiming workflow #### Getting started: [#getting-started] 1. Visit [create-db.prisma.io](https://create-db.prisma.io) in your web browser 2. Click "Create with the web interface" 3. Modify your schema and interact with the Studio 4. Copy the provided connection strings for your project 5. Claim your database to make it permanent ### Option 2: Using the CLI [#option-2-using-the-cli] You can create a database using one of the following options: #### Option 1: Quick start with default settings [#option-1-quick-start-with-default-settings] Run the following command in your terminal: #### bun ```bash bunx create-db@latest ``` #### pnpm ```bash pnpm dlx create-db@latest ``` #### yarn ```bash yarn dlx create-db@latest ``` #### npm ```bash npx create-db@latest ```
* The `@latest` tag automatically downloads and runs the latest version of the tool, so no global installation is required. * After a few seconds, you'll receive a **connection string** and a **claim URL**. * By default, `create-db` detects your approximate location and provisions the database in the closest available region, falling back to `us-east-1` if detection fails. To choose a region yourself, use the `--region` flag. See [the section below](#available-cli-options) to view all the CLI options. #### Option 2: Choose a region interactively [#option-2-choose-a-region-interactively] If you want to select a region manually: #### bun ```bash bunx create-db@latest --interactive ``` #### pnpm ```bash pnpm dlx create-db@latest --interactive ``` #### yarn ```bash yarn dlx create-db@latest --interactive ``` #### npm ```bash npx create-db@latest --interactive ```
* This opens a region selection menu (for example, `us-east-1`, `eu-west-3`). * Alternatively, you can use the shorthand `-i`: #### bun ```bash bunx create-db@latest -i ``` #### pnpm ```bash pnpm dlx create-db@latest -i ``` #### yarn ```bash yarn dlx create-db@latest -i ``` #### npm ```bash npx create-db@latest -i ``` To view all options and regions: #### bun ```bash bunx create-db@latest --help ``` #### pnpm ```bash pnpm dlx create-db@latest --help ``` #### yarn ```bash yarn dlx create-db@latest --help ``` #### npm ```bash npx create-db@latest --help ``` #### CLI output walkthrough [#cli-output-walkthrough] Here is an example output: ``` ┌ 🚀 Creating a Prisma Postgres database │ ◇ Database created successfully! │ │ ● Database Connection │ │ │ Connection String: │ │ postgres://:@db.prisma.io:5432/postgres?sslmode=require │ │ ◆ Claim Your Database │ │ Keep your database for free: │ │ https://create-db.prisma.io/claim?projectID=proj_...&utm_source=create-db&utm_medium=cli │ │ Database will be deleted on if not claimed. │ └ Done! ``` Once you have the output, take the connection string and add it to your `.env` file as `DATABASE_URL`. If the file already has a `DATABASE_URL`, replace that value instead of adding a second one: ```text DATABASE_URL="postgres://:@db.prisma.io:5432/postgres?sslmode=require" ``` If you don't have a `.env` file yet, you can skip the copy step by creating the database with `npx create-db@latest --env .env` instead. This creates the file with `DATABASE_URL` and `CLAIM_URL` and prints only a confirmation, so the claim URL is in `CLAIM_URL` rather than in the terminal. On a file that already exists, `--env` appends both lines without removing an existing `DATABASE_URL`, so delete the old line yourself. You can now follow the [Prisma Postgres quickstart guide](https://www.prisma.io/docs/v7/prisma-orm/quickstart/prisma-postgres) to connect your Prisma project to this database. If you're using other tools or libraries, use the standard PostgreSQL connection string with any PostgreSQL-compatible client, such as `psql`, `pgAdmin`, `node-postgres`, or an ORM of your choice. Detailed instructions are available in [Connecting to your database](https://www.prisma.io/docs/postgres/database/connecting-to-your-database). ## Use create-db with coding agents [#use-create-db-with-coding-agents] Coding agents such as Claude Code, Cursor, and Codex can create a database for a task without a human signing up first. Run the command with `--json` so the agent gets machine-readable output: #### bun ```bash bunx create-db@latest --json ``` #### pnpm ```bash pnpm dlx create-db@latest --json ``` #### yarn ```bash yarn dlx create-db@latest --json ``` #### npm ```bash npx create-db@latest --json ``` ```json { "success": true, "connectionString": "postgres://:@db.prisma.io:5432/postgres?sslmode=require", "claimUrl": "https://create-db.prisma.io/claim?projectID=proj_...&utm_source=create-db&utm_medium=cli", "deletionDate": "2026-10-13T08:44:59.650Z", "region": "eu-west-3", "name": "2026-10-12T08:44:55.985Z", "projectId": "proj_..." } ``` The agent reads `connectionString` and sets it as `DATABASE_URL` for the task. Keep it out of the `.env` file your team shares, so the agent never points at a database someone else is using. If the service returns an error, the JSON has `"success": false` and a `message`, and the command exits with code 1. If a flag value is invalid or the service can't be reached, the command prints an error to stderr instead of JSON and exits with code 1. To write `DATABASE_URL` and `CLAIM_URL` to a separate env file instead of printing JSON, or to let the database expire sooner than 24 hours: #### bun ```bash bunx create-db@latest --env .env.local ``` #### pnpm ```bash pnpm dlx create-db@latest --env .env.local ``` #### yarn ```bash yarn dlx create-db@latest --env .env.local ``` #### npm ```bash npx create-db@latest --env .env.local ``` #### bun ```bash bunx create-db@latest --json --ttl 1h ``` #### pnpm ```bash pnpm dlx create-db@latest --json --ttl 1h ``` #### yarn ```bash yarn dlx create-db@latest --json --ttl 1h ``` #### npm ```bash npx create-db@latest --json --ttl 1h ``` When an agent creates databases: * Create one database per task, not one per test run. Database creation is rate-limited per IP address. * When the work should be kept, show the human the `claimUrl`. Claiming needs a Prisma account, so a person has to do it. * Treat the database as disposable until it is claimed: it is deleted when its time to live runs out. To make this the agent's default, add a short block to your project's `AGENTS.md`: ```markdown ## Database rules - For a task that needs a scratch database, run `npx create-db@latest --json` and use `connectionString` as `DATABASE_URL` for that task only, never in the shared `.env`. - Create one database per task. It is deleted after 24 hours unless claimed. - If the work should be kept, show me the `claimUrl`. Claiming needs my Prisma account. ``` Claude Code doesn't always read `AGENTS.md`, for example when your project also has a `CLAUDE.md`. Add the line `@AGENTS.md` to a `CLAUDE.md` next to your `AGENTS.md` so Claude Code imports these rules. For the reasoning behind these rules and more examples, see [Give your agent a database](https://www.prisma.io/blog/give-your-agent-a-database) and [What to put in your AGENTS.md so your agent handles the database right](https://www.prisma.io/blog/agents-md-for-databases). ## Claiming your database [#claiming-your-database] Databases created with `npx create-db` are **temporary**. A database is deleted **24 hours** after creation unless you claim it. With `--ttl`, it is deleted after the time you set instead (30 minutes to 24 hours), and the CLI output shows that deletion time. You can prevent this by **claiming the database** using the claim URL shown in the CLI output: ``` ◆ Claim Your Database │ │ Keep your database for free: │ │ https://create-db.prisma.io/claim?projectID=proj_...&utm_source=create-db&utm_medium=cli │ │ Database will be deleted on if not claimed. ``` To claim your database and make it permanent: 1. Copy the **claim URL** from the CLI output. 2. Open it in your browser and click **Claim database**. 3. Log in to Prisma with GitHub or Google, or [sign up](https://console.prisma.io/sign-up?utm_source=docs\&utm_medium=content\&utm_content=postgres) if you don't have an account yet. 4. Choose a **Workspace** that has capacity for creating new projects. 5. Click **Authorize Prisma Create DB** to confirm. 6. You'll be redirected to a success page. Then, click **Go use your database** to view and manage the claimed database in your workspace. When you claim a database: * It's moved into a workspace in your Prisma account ([Console](https://console.prisma.io/?utm_source=docs\&utm_medium=content\&utm_content=postgres)). * It's no longer auto-deleted. * You can continue using it as a permanent database instance. ## Available CLI options [#available-cli-options] Here are the CLI flags for the `npx create-db` command: | Flag | Shorthand | Description | | ------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `--region ` | `-r` | AWS region for the database.
**Available regions:** `ap-southeast-1`, `ap-northeast-1`, `eu-central-1`, `eu-west-3`, `us-east-1`, `us-west-1`. Without it, `create-db` picks the region closest to you (fallback `us-east-1`). | | `--interactive` | `-i` | Run in interactive mode to select a region. | | `--json` | `-j` | Output machine-readable JSON. | | `--env ` | `-e` | Write `DATABASE_URL` and `CLAIM_URL` to the specified `.env` file. If the file exists, the two lines are appended. | | `--ttl ` | `-t` | Auto-delete after `30m`, or `1h` to `24h`. The default and maximum is `24h`. | | `--copy` | `-c` | Copy the connection string to your clipboard. | | `--quiet` | `-q` | Only output the connection string. | | `--open` | `-o` | Open the claim URL in your browser. | | `--help` | `-h` | Display help for the command. | To list the regions you can create a database in, run the `regions` subcommand. Add `--json` for machine-readable output. #### bun ```bash bunx create-db@latest regions ``` #### pnpm ```bash pnpm dlx create-db@latest regions ``` #### yarn ```bash yarn dlx create-db@latest regions ``` #### npm ```bash npx create-db@latest regions ``` ``` ● Available Prisma Postgres regions: │ │ │ ap-southeast-1 - Asia Pacific (Singapore) │ │ ap-northeast-1 - Asia Pacific (Tokyo) │ │ eu-central-1 - Europe (Frankfurt) │ │ eu-west-3 - Europe (Paris) │ │ us-east-1 - US East (N. Virginia) │ │ us-west-1 - US West (N. California) ``` To view all CLI options, use the `--help` or `-h` flag. The output lists the commands, then the options of the default `create` command: #### bun ```bash bunx create-db@latest --help ``` #### pnpm ```bash pnpm dlx create-db@latest --help ``` #### yarn ```bash yarn dlx create-db@latest --help ``` #### npm ```bash npx create-db@latest --help ``` ``` Usage: create-db [options] [command] Instantly create a temporary Prisma Postgres database Available subcommands: create (default), regions Options: -V, --version output the version number -h, --help display help for command Commands: create [options] Create a new Prisma Postgres database regions [options] List available Prisma Postgres regions Usage: create-db create [options] Create a new Prisma Postgres database Options: -r, --region [string] AWS region for the database; Alias: r (choices: "ap-southeast-1", "ap-northeast-1", "eu-central-1", "eu-west-3", "us-east-1", "us-west-1") -i, --interactive [boolean] Run in interactive mode to select a region; Alias: i (default: false) -j, --json [boolean] Output machine-readable JSON; Alias: j (default: false) -e, --env [string] Write DATABASE_URL and CLAIM_URL to the specified .env file; Alias: e -t, --ttl [string] Auto-delete after (30m, 1h-24h); Alias: t -c, --copy [boolean] Copy the connection string to your clipboard; Alias: c (default: false) -q, --quiet [boolean] Only output the connection string; Alias: q (default: false) -o, --open [boolean] Open the claim URL in your browser; Alias: o (default: false) -h, --help display help for command ``` ## Related pages - [`Best Postgres for AI apps`](https://www.prisma.io/docs/postgres/best-postgres-for-ai-apps): Why Prisma Postgres works well for AI and LLM workloads: built-in pooling, edge connectivity, pgvector, and MCP support. - [`Database`](https://www.prisma.io/docs/postgres/database): Overview of Prisma Postgres database operations, connections, pooling, backups, and query analysis. - [`Error reference`](https://www.prisma.io/docs/postgres/error-reference): Error reference documentation for Prisma Postgres - [`Migrate a local Postgres database to the cloud (Prisma Postgres)`](https://www.prisma.io/docs/postgres/import-from-existing-database): Move a local or hosted PostgreSQL database to Prisma Postgres in three steps: create the database, pg_dump, pg_restore. - [`Migrate from Early Access`](https://www.prisma.io/docs/postgres/migrate-from-ea-to-ga): Move your Prisma Postgres Early Access database to a new PostgreSQL 17 database with dump and restore.