Claimable Postgres
Instant Postgres databases for local development, demos, prototyping, and test environments. No account required. Databases expire after 72 hours unless claimed to a Neon account.
Quick Start
CODEBLOCK0
Parse connection_string and claim_url from the JSON response. Write connection_string to the project's .env as DATABASE_URL.
For other methods (CLI, SDK, Vite plugin), see Which Method? below.
Which Method?
- - REST API: Returns structured JSON. No runtime dependency beyond
curl. Preferred when the agent needs predictable output and error handling. - CLI (
npx neon-new@latest --yes): Provisions and writes .env in one command. Convenient when Node.js is available and the user wants a simple setup. - SDK (
neon-new/sdk): Scripts or programmatic provisioning in Node.js. - Vite plugin (
vite-plugin-neon-new): Auto-provisions on vite dev if DATABASE_URL is missing. Use when the user has a Vite project. - Browser: User cannot run CLI or API. Direct to https://neon.new.
REST API
Base URL: INLINECODE12
Create a database
CODEBLOCK1
| Parameter | Required | Description |
|---|
| INLINECODE13 | Yes | Tracking tag that identifies who provisioned the database. Use "agent-skills" when provisioning through this skill. |
| INLINECODE15 |
No | Enable logical replication (default: false, cannot be disabled once enabled) |
The connection_string returned by the API is a pooled connection URL. For a direct (non-pooled) connection (e.g. Prisma migrations), remove -pooler from the hostname. The CLI writes both pooled and direct URLs automatically.
Response:
CODEBLOCK2
Check status
CODEBLOCK3
Returns the same response shape. Status transitions: UNCLAIMED -> CLAIMING -> CLAIMED. After the database is claimed, connection_string returns null.
Error responses
| Condition | HTTP | Message |
|---|
| Missing or empty INLINECODE23 | 400 | INLINECODE24 |
| Invalid database ID |
400 |
Database not found |
| Invalid JSON body | 500 |
Failed to create the database. |
CLI
CODEBLOCK4
Provisions a database and writes the connection string to .env in one step. Always use @latest and --yes (skips interactive prompts that would stall the agent).
Pre-run Check
Check if DATABASE_URL (or the chosen key) already exists in the target .env. The CLI exits without provisioning if it finds the key.
If the key exists, offer the user three options:
- 1. Remove or comment out the existing line, then rerun.
- Use
--env to write to a different file (e.g. --env .env.local). - Use
--key to write under a different variable name.
Get confirmation before proceeding.
Options
| Option | Alias | Description | Default |
|---|
| INLINECODE35 | INLINECODE36 | Skip prompts, use defaults | INLINECODE37 |
| INLINECODE38 |
-e | .env file path |
./.env |
|
--key |
-k | Connection string env var key |
DATABASE_URL |
|
--prefix |
-p | Prefix for generated public env vars |
PUBLIC_ |
|
--seed |
-s | Path to seed SQL file | none |
|
--logical-replication |
-L | Enable logical replication |
false |
|
--ref |
-r | Referrer id (use
agent-skills when provisioning through this skill) | none |
Alternative package managers: yarn dlx neon-new@latest, pnpm dlx neon-new@latest, bunx neon-new@latest, deno run -A neon-new@latest.
Output
The CLI writes to the target .env:
CODEBLOCK5
SDK
Use for scripts and programmatic provisioning flows.
CODEBLOCK6
Returns databaseUrl (pooled), databaseUrlDirect (direct, for migrations), claimUrl, and claimExpiresAt (Date object). The referrer parameter is required.
Vite Plugin
For Vite projects, vite-plugin-neon-new auto-provisions a database on vite dev if DATABASE_URL is missing. Install with npm install -D vite-plugin-neon-new. See the Claimable Postgres docs for configuration.
Agent Workflow
API path
- 1. Confirm intent: If the request is ambiguous, confirm the user wants a temporary, no-signup database. Skip this if they explicitly asked for a quick or temporary database.
- Provision: POST to
https://neon.new/api/v1/database with {"ref": "agent-skills"}. - Parse response: Extract
connection_string, claim_url, and expires_at from the JSON response. - Write .env: Write
DATABASE_URL=<connection_string> to the project's .env (or the user's preferred file and key). Do not overwrite an existing key without confirmation. - Seed (if needed): If the user has a seed SQL file, run it against the new database:
psql "$DATABASE_URL" -f seed.sql
- 6. Report: Tell the user where the connection string was written, which key was used, and share the claim URL. Remind them: the database works now; claim within 72 hours to keep it permanently.
- Optional: Offer a quick connection test (e.g.
SELECT 1).
CLI path
- 1. Check .env: Check the target
.env for an existing DATABASE_URL (or chosen key). If present, do not run. Offer remove, --env, or --key and get confirmation. - Confirm intent: If the request is ambiguous, confirm the user wants a temporary, no-signup database. Skip this if they explicitly asked for a quick or temporary database.
- Gather options: Use defaults unless context suggests otherwise (e.g., user mentions a custom env file, seed SQL, or logical replication).
- Run: Execute with
@latest --yes plus the confirmed options. Always use @latest to avoid stale cached versions. --yes skips interactive prompts that would stall the agent.
npx neon-new@latest --yes --ref agent-skills --env .env.local --seed ./schema.sql
- 5. Verify: Confirm the connection string was written to the intended file.
- Report: Tell the user where the connection string was written, which key was used, and that a claim URL is in the env file. Remind them: the database works now; claim within 72 hours to keep it permanently.
- Optional: Offer a quick connection test (e.g.
SELECT 1).
Output Checklist
Always report:
- - Where the connection string was written (e.g.
.env) - Which variable key was used (
DATABASE_URL or custom key) - The claim URL (from
.env or API response) - That unclaimed databases are temporary (72 hours)
Claiming
Claiming is optional. The database works immediately without it. To optionally claim, the user opens the claim URL in a browser, where they sign in or create a Neon account to claim the database.
- - API/SDK: Give the user the
claim_url from the create response. - CLI:
npx neon-new@latest claim reads the claim URL from .env and opens the browser automatically.
Users cannot claim into Vercel-linked orgs; they must choose another Neon org.
Defaults and Limits
| Parameter | Value |
|---|
| Provider | AWS |
| Region |
us-east-2 |
| Postgres | 17 |
Region cannot be changed for claimable databases. Unclaimed databases have stricter quotas. Claiming resets limits to free plan defaults.
| Unclaimed | Claimed (Free plan) |
|---|
| Storage | 100 MB | 512 MB |
| Transfer |
1 GB | ~5 GB |
| Branches | No | Yes |
| Expiration | 72 hours | None |
Auto-provisioning
If the agent needs a database to fulfill a task (e.g. "build me a todo app with a real database") and the user has not provided a connection string, provision one via the API and inform the user. Include the claim URL so they can keep it.
Safety and UX Notes
- - Do not overwrite existing env vars. Check first, then use
--env or --key (CLI) or skip writing (API) to avoid conflicts. - Ask before running destructive seed SQL (
DROP, TRUNCATE, mass DELETE). - For production workloads, recommend standard Neon provisioning instead of temporary claimable databases.
- If users need long-term persistence, instruct them to open the claim URL right away.
- After writing credentials to an .env file, check that it's covered by .gitignore. If not, warn the user. Do not modify
.gitignore without confirmation.
Claimable Postgres
用于本地开发、演示、原型设计和测试环境的即时Postgres数据库。无需注册账户。数据库在72小时后过期,除非认领到Neon账户。
快速开始
bash
curl -s -X POST https://neon.new/api/v1/database \
-H Content-Type: application/json \
-d {ref: agent-skills}
从JSON响应中解析connectionstring和claimurl。将connectionstring作为DATABASEURL写入项目的.env文件。
其他方法(CLI、SDK、Vite插件)请参见下方的选择哪种方法?。
选择哪种方法?
- - REST API:返回结构化JSON。除curl外无需运行时依赖。当代理需要可预测的输出和错误处理时推荐使用。
- CLI(npx neon-new@latest --yes):一步完成数据库配置和.env文件写入。当Node.js可用且用户希望简单设置时非常方便。
- SDK(neon-new/sdk):用于Node.js中的脚本或编程式配置。
- Vite插件(vite-plugin-neon-new):在vite dev时如果缺少DATABASE_URL则自动配置数据库。当用户使用Vite项目时使用。
- 浏览器:用户无法运行CLI或API。直接访问https://neon.new。
REST API
基础URL: https://neon.new/api/v1
创建数据库
bash
curl -s -X POST https://neon.new/api/v1/database \
-H Content-Type: application/json \
-d {ref: agent-skills}
| 参数 | 必需 | 描述 |
|---|
| ref | 是 | 标识谁配置了数据库的跟踪标签。通过此技能配置时使用agent-skills。 |
| enablelogicalreplication |
否 | 启用逻辑复制(默认:false,启用后无法禁用) |
API返回的connection_string是一个池化连接URL。如需直接(非池化)连接(例如Prisma迁移),从主机名中移除-pooler。CLI会自动写入池化和直接两种URL。
响应:
json
{
id: 019beb39-37fb-709d-87ac-7ad6198b89f7,
status: UNCLAIMED,
neonprojectid: gentle-scene-06438508,
connection_string: postgresql://...,
claim_url: https://neon.new/claim/019beb39-...,
expires_at: 2026-01-26T14:19:14.580Z,
created_at: 2026-01-23T14:19:14.580Z,
updated_at: 2026-01-23T14:19:14.580Z
}
检查状态
bash
curl -s https://neon.new/api/v1/database/{id}
返回相同的响应结构。状态转换:UNCLAIMED -> CLAIMING -> CLAIMED。数据库被认领后,connection_string返回null。
错误响应
| 条件 | HTTP | 消息 |
|---|
| 缺少或空的ref | 400 | Missing referrer |
| 无效的数据库ID |
400 | Database not found |
| 无效的JSON主体 | 500 | Failed to create the database. |
CLI
bash
npx neon-new@latest --yes
一步完成数据库配置并将连接字符串写入.env。始终使用@latest和--yes(跳过会导致代理停滞的交互式提示)。
运行前检查
检查目标.env中是否已存在DATABASE_URL(或选定的键)。如果找到该键,CLI将退出而不进行配置。
如果键已存在,向用户提供三个选项:
- 1. 移除或注释掉现有行,然后重新运行。
- 使用--env写入不同的文件(例如--env .env.local)。
- 使用--key写入不同的变量名。
在继续之前获取确认。
选项
| 选项 | 别名 | 描述 | 默认值 |
|---|
| --yes | -y | 跳过提示,使用默认值 | false |
| --env |
-e | .env文件路径 | ./.env |
| --key | -k | 连接字符串环境变量键 | DATABASE_URL |
| --prefix | -p | 生成的公共环境变量前缀 | PUBLIC_ |
| --seed | -s | 种子SQL文件路径 | 无 |
| --logical-replication | -L | 启用逻辑复制 | false |
| --ref | -r | 引用者ID(通过此技能配置时使用agent-skills) | 无 |
替代包管理器:yarn dlx neon-new@latest、pnpm dlx neon-new@latest、bunx neon-new@latest、deno run -A neon-new@latest。
输出
CLI写入目标.env:
DATABASE_URL=postgresql://... # 池化(用于应用程序查询)
DATABASEURLDIRECT=postgresql://... # 直接(用于迁移,例如Prisma)
PUBLICPOSTGRESCLAIM_URL=https://neon.new/claim/...
SDK
用于脚本和编程式配置流程。
typescript
import { instantPostgres } from neon-new;
const { databaseUrl, databaseUrlDirect, claimUrl, claimExpiresAt } = await instantPostgres({
referrer: agent-skills,
seed: { type: sql-script, path: ./init.sql },
});
返回databaseUrl(池化)、databaseUrlDirect(直接,用于迁移)、claimUrl和claimExpiresAt(Date对象)。referrer参数是必需的。
Vite插件
对于Vite项目,vite-plugin-neon-new在vite dev时如果缺少DATABASEURL则自动配置数据库。使用npm install -D vite-plugin-neon-new安装。配置请参见Claimable Postgres文档。
代理工作流程
API路径
- 1. 确认意图: 如果请求不明确,确认用户想要一个临时的、无需注册的数据库。如果他们明确要求快速或临时数据库,则跳过此步骤。
- 配置: POST到https://neon.new/api/v1/database,参数为{ref: agent-skills}。
- 解析响应: 从JSON响应中提取connectionstring、claimurl和expiresat。
- 写入.env: 将DATABASEURL=写入项目的.env(或用户偏好的文件和键)。未经确认不要覆盖现有键。
- 种子数据(如果需要): 如果用户有种子SQL文件,针对新数据库运行:
bash
psql $DATABASE_URL -f seed.sql
- 6. 报告: 告知用户连接字符串写入位置、使用的键,并分享认领URL。提醒他们:数据库现在即可使用;在72小时内认领可永久保留。
- 可选: 提供快速连接测试(例如SELECT 1)。
CLI路径
- 1. 检查.env: 检查目标.env中是否已存在DATABASE_URL(或选定的键)。如果存在,不要运行。提供移除、--env或--key选项并获取确认。
- 确认意图: 如果请求不明确,确认用户想要一个临时的、无需注册的数据库。如果他们明确要求快速或临时数据库,则跳过此步骤。
- 收集选项: 除非上下文另有建议(例如用户提到自定义环境文件、种子SQL或逻辑复制),否则使用默认值。
- 运行: 使用@latest --yes加上确认的选项执行。始终使用@latest以避免过时的缓存版本。--yes跳过会导致代理停滞的交互式提示。
bash
npx neon-new@latest --yes --ref agent-skills --env .env.local --seed ./schema.sql
- 5. 验证: 确认连接字符串已写入目标文件。
- 报告: 告知用户连接字符串写入位置、使用的键,以及认领URL在环境文件中。提醒他们:数据库现在即可使用;在72小时内认领可永久保留。
7.