API Introduction
Get started with the Portabase REST API for database and agent management.
The Portabase dashboard exposes a REST API for programmatic management of databases and agents. Swagger UI and the OpenAPI specification are also available.
Enable the API
Set the following environment variables in your dashboard configuration:
API_ENABLED=true
OPENAPI_ENABLED=trueAPI_ENABLED=true: enables all API routes under/api/v1.OPENAPI_ENABLED=true: enables the OpenAPI specification and Swagger UI. The API must also be enabled for this to work.
API Documentation
Once enabled:
| Resource | URL |
|---|---|
| Swagger UI | /api/v1/docs |
| OpenAPI specification | /api/v1/openapi |
Authentication
To create an API token:
- Go to your Profile in the dashboard.
- Open the Account tab.
- In the API Token section, generate a new token.
Tokens are user-level, all API actions inherit the permissions of the associated user.
Use the x-api-key header to authenticate your requests:
GET /api/v1/databases
x-api-key: <your-token>Access
An API token acts as the user who created it.
| Resource | Required role |
|---|---|
| Databases, backups, restorations, database policies | Owner or Admin of the organization that owns the database's project |
| Project backup schedule and retention policy | Right to manage the organization's settings (Owner or Admin) |
| Linking a database to a project | Owner or Admin of the project's organization |
Declaring a database on an agent (POST /databases) | Owner or Admin of the agent's organization; an instance admin for a global agent |
| Organization storage and notification channels | Owner or Admin of the organization |
| Project storage and alert policies | Right to manage the organization's settings (Owner or Admin) |
Organization members have no database access through the API.
Instance admins (system role admin or superadmin) can reach the databases of every agent, whatever their organization. Creating, attaching, detaching or deleting a global agent requires an instance admin, and so does managing global storage and notification channels and choosing which organizations may use them.
Channel credentials and database connection settings (the config objects) are write-only: the API stores them, encrypting the secrets, and never returns them.
A database not linked to any project appears in GET /databases for the organizations its agent is attached to, and any of them can link it to one of its projects. Its details, backups and restorations are available once it is linked.
Rate limits
Each API token allows 1000 requests per hour by default. A window lasts one hour. The first one starts when the token is created, and each next one starts with the first request after the previous window has ended, so a client that stays under the limit is never refused. Instance admins can change the limit with API_RATE_LIMIT (see Environment variables).
Every response reports the token's quota:
| Header | Meaning |
|---|---|
X-RateLimit-Limit | Requests allowed per hour |
X-RateLimit-Remaining | Requests left in the current window |
X-RateLimit-Reset | Unix time, in seconds, when the window resets |
Beyond the limit, the API answers 429 with a Retry-After header, in seconds, until the window resets:
{ "error": "Rate limit exceeded.", "details": { "tryAgainIn": 3599816 } }tryAgainIn is the wait in milliseconds. Each MCP tool call counts as two requests (see MCP Server).
Errors
Errors return a JSON body { "error": "<message>" }.
| Status | Meaning |
|---|---|
401 | Missing, invalid or expired token, or the token's user no longer exists |
403 | Account suspended or pending approval, missing role, or a database of another organization |
404 | The resource does not exist, is not visible to the token, or the id is not a valid UUID |
409 | Conflict with the current state: a job already queued, suspended backups, a missing backup file, a replica, a duplicate slug |
422 | Invalid request body or query parameter |
429 | Rate limit reached |
API coverage is being extended. Check the roadmap for upcoming endpoints.
Last updated on