API: Databases
REST API endpoints for managed database instances.
API: Databases
Endpoints
| Method | Path | Description |
|---|---|---|
| POST | /v1/databases | Create a database |
| GET | /v1/databases | List all databases |
| GET | /v1/databases/{id} | Get database details |
| DELETE | /v1/databases/{id} | Delete a database |
POST /v1/databases
Request Body
{
"metadata": {
"name": "production-db",
"labels": {"env": "production"}
},
"spec": {
"engine": "postgresql",
"type": "db-s-4vcpu-8gb",
"version": "15",
"vpc_id": "vpc-abc123",
"storage_gb": 100,
"replicas": 2,
"backup_enabled": true,
"backup_schedule": "0 2 *"
}
}
Response (201)
{
"id": "db-a1b2c3",
"metadata": {
"name": "production-db",
"labels": {"env": "production"},
"created_at": "2025-01-15T10:30:00Z"
},
"spec": {
"engine": "postgresql",
"type": "db-s-4vcpu-8gb",
"version": "15",
"vpc_id": "vpc-abc123",
"storage_gb": 100,
"replicas": 2,
"backup_enabled": true,
"backup_schedule": "0 2 *"
},
"status": {
"state": "provisioning",
"endpoint": "",
"port": 5432,
"replica_states": []
},
"operation_id": "op-db-001"
}
DatabaseSpec Fields
| Field | Type | Required | Description |
|---|---|---|---|
engine | string | Yes | postgresql or mysql |
type | string | Yes | Instance type / size |
version | string | No | Engine version |
vpc_id | string | No | VPC for network placement |
storage_gb | int | No | Storage allocation (default: 20) |
replicas | int | No | Number of read replicas (default: 0) |
backup_enabled | bool | No | Enable automated backups (default: true) |
backup_schedule | string | No | Cron expression for backups |
GET /v1/databases
{
"items": [
{
"id": "db-a1b2c3",
"metadata": {"name": "production-db"},
"spec": {"engine": "postgresql", "version": "15"},
"status": {"state": "running", "endpoint": "10.0.2.50", "port": 5432}
}
]
}
Delete Database
DELETE /v1/databases/db-a1b2c3
Returns 202 with an operation ID. Deletion removes the primary instance and all replicas.