---
title: Database quickstart
description: Create a Postgres database, wait for it to be ready, and bind it to an environment so your app receives its connection.
type: tutorial
product: database
summary: A managed Postgres database, bound to your app as DATABASE_URL.
updated: 2026-10-01
order: 1
---

A database in Sylphx is a managed resource of your organization. You create it,
wait until it is ready, and bind it to an environment; from then on, your
services in that environment receive its connection as an environment
variable. Credentials are never copied by hand.

<Callout tone="note" title="Today this runs on the management API">
Databases are provisioned with the managed-resources calls on this page, which is also what the console uses. The `databases` collection of the [API reference](/docs/api/databases) serves reads at api.sylphx.com; its `create`, `delete`, `restore` and `connect` are not served.
</Callout>

<Prerequisites
	items={[
		'An account, and a project with an environment — see the Hosting quickstart',
		'The CLI signed in (`sylphx login`) or `SYLPHX_API_KEY` set',
	]}
/>

## 1. Create the database

`kind` is `database`. `tier` sets its size (`hobby` is the smallest), and
`projectId` ties it to the project it serves:

<CodeTabs>
	<CodeTab
		label="CLI"
		language="bash"
		code={`sylphx api POST /v1/resources -d '{"name":"shop-main","kind":"database","tier":"hobby","projectId":"'$PROJECT_ID'","env":"production"}'`}
	/>
	<CodeTab
		label="cURL"
		language="bash"
		code={`curl -X POST https://api.sylphx.com/v1/resources \
  -H "Authorization: Bearer $SYLPHX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"shop-main","kind":"database","tier":"hobby","projectId":"'$PROJECT_ID'","env":"production"}'`}
	/>
</CodeTabs>

The call answers `202` with an operation: provisioning continues in the
background. Optional fields are `storageGb` and, for a database you want to
retry safely, a caller-chosen `requestId`.

## 2. Wait until it is ready

```bash
sylphx api GET /v1/resources
```

Find the resource by `name`. Its `id` starts with `res_`, and its `status` is
`ready` once the database serves. Read one by id with
`GET /v1/resources/$RESOURCE_ID`.

## 3. Bind it to an environment

A binding gives an environment's services the database's connection:

```bash
sylphx api POST /v1/resources/$RESOURCE_ID/bindings -d '{"projectId":"'$PROJECT_ID'","environmentId":"production"}'
```

`environmentId` takes an `env_…` id, or `production`, `staging` or
`development` together with `projectId`. `role` defaults to `primary`.

The services in that environment now receive `DATABASE_URL`, the pooled
connection for application queries, and `DATABASE_URL_UNPOOLED`, the direct
one for migrations and anything that needs a session of its own. The URLs
carry the credentials, so they stay in the environment and never enter your
repository.

<Callout tone="note" title="Pooled and direct are two jobs, not two options">
Application queries go through the pooled `DATABASE_URL`, which survives a
serverless app opening many connections at once. Schema changes and anything
that needs a session of its own — `SET`, `LISTEN`, an advisory lock held across
statements — go through `DATABASE_URL_UNPOOLED`.
</Callout>

## 4. Use it

Redeploy the environment so running services pick the variables up
(`POST /v1/projects/$PROJECT_ID/environments/$ENV_ID/deployments/redeploy`),
then connect from your app with any Postgres client:

```ts
import postgres from 'postgres'

const sql = postgres(process.env.DATABASE_URL!)
const [row] = await sql`select version()`
```

## Delete it

```bash
sylphx api DELETE /v1/resources/$RESOURCE_ID
```

A database with active bindings is refused, so remove the binding first with
`sylphx api POST /v1/resources/$RESOURCE_ID:unbind -d '{"environmentId":"$ENV_ID"}'`.

## Next

<RelatedDocs
	links={[
		{
			href: '/docs/database/migrations',
			label: 'Migrations',
			description: 'Evolve the schema safely, over the direct connection.',
		},
		{
			href: '/docs/database/query-guide',
			label: 'Query guide',
			description: 'Reading and writing rows, with Drizzle or plain SQL.',
		},
		{
			href: '/docs/database/backups',
			label: 'Backups and restore',
			description: 'What is kept, for how long, and how to restore.',
		},
	]}
/>
