Menu
Platform
AI
App store purchases
Database
Flags
Jobs and cron
Localization
Monitoring
Notifications
Payments
Queues
Sandboxes
Webhooks
Getting Started
Authentication
KV Store
Deploy & Infrastructure
Reference
Database quickstart
A managed Postgres database, bound to your app as DATABASE_URL.
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.
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 serves reads at api.sylphx.com; its create, delete, restore and connect are not served.
#1. Create the database
kind is database. tier sets its size (hobby is the smallest), and
projectId ties it to the project it serves:
sylphx api POST /v1/resources -d '{"name":"shop-main","kind":"database","tier":"hobby","projectId":"'$PROJECT_ID'","env":"production"}'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
sylphx api GET /v1/resourcesFind 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:
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.
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.
#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:
import postgres from 'postgres'
const sql = postgres(process.env.DATABASE_URL!)
const [row] = await sql`select version()`#Delete it
sylphx api DELETE /v1/resources/$RESOURCE_IDA database with active bindings is refused, so remove the binding first with
sylphx api POST /v1/resources/$RESOURCE_ID:unbind -d '{"environmentId":"$ENV_ID"}'.