Skip to main content

Create PostgreSQL Database

curl -X POST "https://your-dokploy-instance.com/api/postgres.create" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Production Database",
    "appName": "prod-postgres",
    "databaseName": "myapp",
    "databaseUser": "admin",
    "databasePassword": "SecurePass123!",
    "dockerImage": "postgres:18",
    "environmentId": "env_123456",
    "description": "Main production PostgreSQL database"
  }'
name
string
required
Display name for the PostgreSQL database
appName
string
required
Unique application name used for Docker container identification
databaseName
string
required
Name of the database to create
databaseUser
string
required
Username for database access
databasePassword
string
required
Password for database user. Must match pattern: ^[a-zA-Z0-9@#%^&*()_+\-=[\]{}|;:,.<>?~]*$`
environmentId
string
required
ID of the environment where this database will be deployed
dockerImage
string
default:"postgres:18"
Docker image to use for PostgreSQL
description
string
Optional description of the database instance
serverId
string
Optional server ID for deployment on specific server
postgresId
string
Unique identifier for the created PostgreSQL instance
appName
string
Application name of the database
name
string
Display name of the database

Get PostgreSQL Database

curl -X GET "https://your-dokploy-instance.com/api/postgres.one?postgresId=pg_123456" \
  -H "Authorization: Bearer YOUR_API_TOKEN"
postgresId
string
required
ID of the PostgreSQL database to retrieve
postgresId
string
Database identifier
name
string
Display name
appName
string
Application name
databaseName
string
Database name
databaseUser
string
Database username
dockerImage
string
PostgreSQL Docker image
applicationStatus
string
Current status: idle, running, done, or error
externalPort
number
External port for database access (if configured)

Deploy PostgreSQL

curl -X POST "https://your-dokploy-instance.com/api/postgres.deploy" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "postgresId": "pg_123456"
  }'
postgresId
string
required
ID of the PostgreSQL database to deploy

Start PostgreSQL

curl -X POST "https://your-dokploy-instance.com/api/postgres.start" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "postgresId": "pg_123456"
  }'
postgresId
string
required
ID of the PostgreSQL database to start

Stop PostgreSQL

curl -X POST "https://your-dokploy-instance.com/api/postgres.stop" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "postgresId": "pg_123456"
  }'
postgresId
string
required
ID of the PostgreSQL database to stop

Update PostgreSQL

curl -X POST "https://your-dokploy-instance.com/api/postgres.update" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "postgresId": "pg_123456",
    "name": "Updated Database Name",
    "description": "Updated description",
    "memoryLimit": "2g",
    "memoryReservation": "1g",
    "cpuLimit": "1",
    "cpuReservation": "0.5"
  }'
postgresId
string
required
ID of the PostgreSQL database to update
name
string
New display name
description
string
New description
memoryLimit
string
Maximum memory (e.g., “2g”, “512m”)
memoryReservation
string
Guaranteed memory allocation
cpuLimit
string
Maximum CPU cores
cpuReservation
string
Guaranteed CPU allocation

Save External Port

curl -X POST "https://your-dokploy-instance.com/api/postgres.saveExternalPort" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "postgresId": "pg_123456",
    "externalPort": 5432
  }'
postgresId
string
required
ID of the PostgreSQL database
externalPort
number
Port number for external access. Set to null to remove external port.

Save Environment Variables

curl -X POST "https://your-dokploy-instance.com/api/postgres.saveEnvironment" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "postgresId": "pg_123456",
    "env": "POSTGRES_MAX_CONNECTIONS=200\nPOSTGRES_SHARED_BUFFERS=256MB"
  }'
postgresId
string
required
ID of the PostgreSQL database
env
string
Environment variables in KEY=VALUE format, separated by newlines

Reload PostgreSQL

curl -X POST "https://your-dokploy-instance.com/api/postgres.reload" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "postgresId": "pg_123456",
    "appName": "prod-postgres"
  }'
postgresId
string
required
ID of the PostgreSQL database
appName
string
required
Application name of the database

Rebuild PostgreSQL

curl -X POST "https://your-dokploy-instance.com/api/postgres.rebuild" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "postgresId": "pg_123456"
  }'
postgresId
string
required
ID of the PostgreSQL database to rebuild

Remove PostgreSQL

curl -X POST "https://your-dokploy-instance.com/api/postgres.remove" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "postgresId": "pg_123456"
  }'
postgresId
string
required
ID of the PostgreSQL database to remove

Connection String Format

postgresql://[databaseUser]:[databasePassword]@[appName]:5432/[databaseName]
Example:
postgresql://admin:SecurePass123!@prod-postgres:5432/myapp
For external connections:
postgresql://admin:[email protected]:5432/myapp

Build docs developers (and LLMs) love