Swyftstack REST API
A predictable, org-scoped REST API for managed PostgreSQL, object storage and backups. Authenticate with an API key or connect an AI client with device login. Everything the console does, you can automate.
On this page: Authentication · Scopes · Rate limits · Errors · Pagination · Endpoints · Examples · Workflows
Overview
The base URL is below. Every response is JSON in a { data } envelope; errors use { error: { code, message } }. All timestamps are ISO-8601 UTC. IDs are prefixed public ids (db_…, proj_…, bucket_…).
https://swyftstack.com/v1Authentication
Send your API key as a bearer token on every request.
Authorization: Bearer sk_live_your_key_hereDevice authentication (recommended for AI/CLI)
AI clients connect without a key using the OAuth 2.0 Device Authorization Grant (RFC 8628). The client calls POST /v1/device/authorize, shows you a short code, and polls POST /v1/device/token; you approve in the browser at /device and a scoped key is minted automatically. The official MCP server does this for you - see the MCP guide.
API keys (scripts & CI)
Create long-lived keys under Settings → API keys, with a scope preset and optional expiry. The secret is shown once. Keys are org-scoped and can be revoked anytime.
OAuth 2.0 (roadmap)
A full three-legged OAuth flow for third-party apps is on the roadmap. Today, use device login (for AI/CLI) or API keys (for your own automation).
Scopes
Each key is limited to the scopes you grant. Scopes marked destructive additionally require the key's dangerous-operations toggle.
| Database | database:createdatabase:readdatabase:updatedatabase:delete ⚠ |
| Storage | storage:createstorage:readstorage:updatestorage:delete ⚠ |
| Backups | backup:createbackup:restorebackup:delete ⚠backup:downloadbackup:list |
| Account | account:read |
| Billing | billing:read |
| Teams | team:read |
⚠ = destructive. Presets: Read Only (view resources, usage, and backups. cannot create, change, or delete anything.) · Developer (create and manage databases, buckets, and backups. no destructive deletes.) · Full Access (every scope, including deletes (deletes still require the dangerous-operations toggle).)
Rate limits, errors & pagination
Rate limits
Reads are unlimited in normal use. Expensive/irreversible operations (create database, create/restore backup, create bucket, import) are rate-limited per key; exceeding a limit returns 429 with a Retry-After header.
Error responses
{
"error": {
"code": "insufficient_scope",
"message": "This API key is missing the required scope: database:create."
}
}Codes: unauthorized (401), forbidden / insufficient_scope / dangerous_not_allowed (403), not_found (404), conflict (409), validation_error (422), rate_limited (429), internal_error (500).
Pagination
List endpoints accept ?limit= (max 100). Log endpoints also accept ?page= and return meta.has_next. Results are newest-first.
Endpoints
A key can only see and act on resources in its own organization.
Databases
| GET | /v1/databases | database:read | List databases |
| POST | /v1/databases | database:create | Create a database |
| GET | /v1/databases/:id | database:read | Get a database |
| DELETE | /v1/databases/:id | database:delete | Delete a database (destructive) |
| POST | /v1/databases/:id/restart | database:update | Restart |
| POST | /v1/databases/:id/rotate-password | database:update | Rotate password |
| GET | /v1/databases/:id/connection | database:read | Connection details |
| GET | /v1/databases/:id/ssl | database:read | SSL/TLS status |
Network & security
| GET | /v1/databases/:id/allowlist | database:read | Get IP allow-list |
| PUT | /v1/databases/:id/allowlist | database:update | Replace IP allow-list |
| GET | /v1/databases/:id/rls | database:read | Row-Level Security overview |
| POST | /v1/databases/:id/rls | database:update | Enable/disable RLS on a table |
Backups & recovery
| GET | /v1/databases/:id/backups | backup:list | List backups |
| POST | /v1/databases/:id/backups | backup:create | Trigger a manual backup |
| POST | /v1/databases/:id/backups/:backupId/restore | backup:restore | Restore from a backup |
| POST | /v1/databases/:id/backups/:backupId/pin | backup:create | Pin/unpin a backup |
| DELETE | /v1/databases/:id/backups/:backupId | backup:delete | Delete a backup (destructive) |
| GET | /v1/databases/:id/recovery | backup:list | PITR / WAL / recovery timeline |
| POST | /v1/databases/:id/recovery/restore-request | backup:restore | Request a PITR restore |
| GET | /v1/databases/:id/export | backup:download | Latest downloadable export |
Imports
| GET | /v1/imports | database:read | List imports |
| POST | /v1/imports | database:create | Import an external database |
| GET | /v1/imports/:importId | database:read | Import status + log |
Storage
| GET | /v1/buckets | storage:read | List buckets |
| POST | /v1/buckets | storage:create | Create a bucket |
| DELETE | /v1/buckets/:id | storage:delete | Delete a bucket (destructive) |
| GET | /v1/buckets/:id/objects | storage:read | List objects |
| POST | /v1/buckets/:id/objects?key=… | storage:create | Upload an object |
| DELETE | /v1/buckets/:id/objects/:key | storage:delete | Delete an object |
Account & agent
| GET | /v1/account/usage | account:read | Usage vs plan limits |
| GET | /v1/account/limits | account:read | Plan limits + features |
| GET | /v1/account/billing | billing:read | Billing + trial state |
| GET | /v1/account/api-keys | account:read | List API keys |
| GET | /v1/account/audit-logs | account:read | API + agent activity log |
| GET | /v1/agent/status | account:read | AI-optimized account snapshot |
| GET | /v1/agent/recommendations | account:read | Actionable recommendations |
Examples
Create a database, in four languages.
curl -X POST https://swyftstack.com/v1/databases \ -H "Authorization: Bearer $SWYFTSTACK_API_KEY" \ -H "Content-Type: application/json" \ -d '{"project":"proj_xxx","name":"production"}'
Common workflows
- Create a database:
POST /v1/databases, thenGET /v1/databases/:id/connectionfor the URL. - Import a database:
POST /v1/imports, then pollGET /v1/imports/:importId. - Restore a backup:
GET /v1/databases/:id/backups→POST /v1/databases/:id/backups/:backupId/restore. - Manage storage:
POST /v1/buckets, thenPOST /v1/buckets/:id/objects?key=…to upload. - Rotate a password:
POST /v1/databases/:id/rotate-password(returns fresh credentials once). - View usage:
GET /v1/account/usageor the aggregatedGET /v1/agent/status. - Manage API keys: list with
GET /v1/account/api-keys; create/revoke in the dashboard.