The FlatRun Agent exposes a comprehensive REST API for programmatic control of your deployments and infrastructure. This enables automation, integration with CI/CD pipelines, and building custom tooling.
Base URL
All API endpoints are relative to your agent's address:
http://localhost:8090/api In production, use HTTPS and your configured domain.
Live API Description
Each agent publishes the API it actually runs at /api/openapi.json. The description
includes request fields, field types, accepted values, required permissions, response shapes,
and whether an operation supports a plan. Use this document as the authoritative reference for
the installed agent version.
curl https://panel.example.com/api/openapi.json \
-H "Authorization: Bearer $TOKEN" | jq
The CLI reads the same description. Run flatrun RESOURCE OPERATION --help for one
operation, or --generate-cli-skeleton to print a request body you can fill in.
Authentication
All API endpoints (except health and auth status) require authentication. See Authentication for details.
Quick Start
# Login and get token
TOKEN=$(curl -s -X POST http://localhost:8090/api/auth/login \
-H "Content-Type: application/json" \
-d '{"api_key": "your-api-key"}' | jq -r '.token')
# Use token in requests
curl http://localhost:8090/api/deployments \
-H "Authorization: Bearer $TOKEN" Response Format
API data and errors use JSON. Download and stream endpoints return the media type described by OpenAPI. Successful JSON responses commonly include:
{
"data": { ... }, // or array for list endpoints
"message": "Success"
} Error responses include:
{
"error": "Error message",
"code": "ERROR_CODE"
} HTTP Status Codes
| Code | Meaning |
|---|---|
200 | Success |
201 | Created (for POST requests) |
400 | Bad Request (invalid parameters) |
401 | Unauthorized (missing/invalid token) |
404 | Not Found |
500 | Internal Server Error |
API Categories
The API is organized into the following categories:
Authentication
GET /auth/status: Check if auth is enabledPOST /auth/login: Login with API keyGET /auth/validate: Validate JWT token
Deployments
GET /deployments: List all deploymentsGET /deployments/:name: Get deployment detailsPOST /deployments: Create deploymentPUT /deployments/:name: Update deploymentDELETE /deployments/:name: Delete deploymentPOST /deployments/:name/start: Start deploymentPOST /deployments/:name/stop: Stop deploymentPOST /deployments/:name/restart: Restart deploymentGET /deployments/:name/logs: Get deployment logsGET /deployments/:name/stats: Get resource stats
Containers
GET /containers: List all containersPOST /containers/:id/start: Start containerPOST /containers/:id/stop: Stop containerPOST /containers/:id/restart: Restart containerDELETE /containers/:id: Remove containerGET /containers/:id/logs: Get container logs
Docker Resources
GET /images: List imagesPOST /images/pull: Pull imageDELETE /images/:id: Delete imageGET /volumes: List volumesPOST /volumes: Create volumeDELETE /volumes/:name: Delete volumeGET /networks: List networksPOST /networks: Create networkDELETE /networks/:name: Delete network
Templates
GET /templates: List templatesGET /templates/categories: Get categoriesPOST /templates/refresh: Refresh templatesGET /templates/:id/compose: Get template compose
Certificates
GET /certificates: List certificatesPOST /certificates: Request certificatePOST /certificates/renew: Renew certificatesDELETE /certificates/:domain: Delete certificate
Proxy
GET /proxy/status/:name: Get proxy statusPOST /proxy/setup/:name: Setup proxyDELETE /proxy/:name: Remove proxyGET /proxy/vhosts: List virtual hosts
Databases
POST /databases/test: Test connectionPOST /databases/list: List databasesPOST /databases/tables: List tablesPOST /databases/query: Execute queryPOST /databases/create: Create databasePOST /databases/users/create: Create user
Infrastructure
GET /infrastructure: List infrastructurePOST /infrastructure/:name/start: Start servicePOST /infrastructure/:name/stop: Stop serviceGET /infrastructure/:name/logs: Get logs
Object Stores
GET /backup-destinations: List storesPOST /object-stores/provision-managed: Deploy a store on this hostGET /object-stores/:name/objects: Browse a storePOST /object-stores/:name/replicate: Copy one store to another
Plans
GET /plans: List plansGET /plans/:id: Read a previewPOST /plans/:id/apply: Run the reviewed change
Metrics & Alerts
GET /plugin/observability/metrics/latest: Current readingsGET /plugin/observability/metrics/timeseries: History for a deploymentGET /plugin/observability/alerts/rules: Alert rulesGET /dashboards: Saved dashboards
System
GET /health: Health checkGET /stats: System statisticsGET /settings: Get settingsPUT /settings: Update settingsGET /system/logs: Proxy and infrastructure logsGET /notifications/targets: Delivery targets
Rate Limiting
The API does not currently implement rate limiting. However, for production use, it's recommended to place the agent behind a reverse proxy with rate limiting configured.
CORS
CORS can be enabled in the agent configuration to allow browser-based access from allowed origins:
api:
enable_cors: true
allowed_origins:
- https://dashboard.example.com