Skip to content

Agent API Reference

The Traefik Manager Agent (TMA) exposes an HTTP API on port 8090. Every endpoint except /health requires authentication.

Authentication

Send your API key in the X-Api-Key header:

http
X-Api-Key: your-api-key-here

Authorization: Bearer <key> works too.

TM handles authentication automatically when proxying calls through /api/agents/proxy/<id>/....

Rate limiting

/api/ requests are rate-limited per IP using TMA_RATE_LIMIT (default: 300 requests/minute), and return 429 Too Many Requests when exceeded. Set TMA_RATE_LIMIT=0 to disable. The default is generous because TM makes many API calls per tab switch; lower it only if you need stricter access control.

Endpoints

MethodPathDescription
GET/healthHealth check - no auth required
GET/api/traefik/overviewTraefik API overview
GET/api/traefik/routersRouters across all protocols - returns {"http":[...],"tcp":[...],"udp":[...]}
GET/api/traefik/servicesServices across all protocols - returns {"http":[...],"tcp":[...],"udp":[...]}
GET/api/traefik/middlewaresMiddlewares across all protocols - returns {"http":[...],"tcp":[...]}
GET/api/traefik/entrypointsEntrypoints
GET/api/traefik/versionTraefik version
GET/api/traefik/logsLast N access log lines (requires ACCESS_LOG_PATH) - ?lines=100, capped at 1000
GET/api/traefik/certsCertificates from acme.json (requires ACME_JSON_PATH)
GET/api/traefik/pluginsPlugins declared in the agent's static config (requires STATIC_CONFIG_PATH)
GET/api/configsRead dynamic config file(s)
POST/api/configsWrite a dynamic config file (creates a .bak before writing) - body: {"name": "...", "content": "<yaml>"}
GET/api/staticRead static config (requires STATIC_CONFIG_PATH)
POST/api/staticWrite static config - body: {"content": "<yaml>"}
GET/api/static/statusRestart method info
POST/api/static/restartRestart Traefik (requires RESTART_METHOD)
GET/api/crowdsec/decisionsCrowdSec active decisions (requires CrowdSec config)
POST/api/crowdsec/decisionsAdd a decision - body: {"value": "<ip>", "type": "ban", "duration": "24h", "reason": "..."}; type is ban, captcha or bypass
GET/api/crowdsec/alertsCrowdSec recent alerts
DELETE/api/crowdsec/decisions/<id>Unban an IP
GET/api/backupsList local .bak backup files
POST/api/backup/createCreate .bak backups for all config files (one per file)
POST/api/restore/<filename>Restore a config file from a .bak backup
POST/api/backup/delete/<filename>Delete a .bak backup file
GET/api/backup/git/statusGit backup status
POST/api/backup/git/pushManual git push
POST/api/backup/git/testTest git connectivity
GET/api/backup/git/commitsLast 50 commits
GET/api/backup/git/commit/<sha>/diffPer-file diff for a commit
POST/api/backup/git/restore/<sha>Restore configs from a git commit
DELETE/api/backup/git/repoReset (delete) local git repo clone
GET/api/routes/<id>/rawRaw YAML for a single route (router + service block) - id is the route name or configFile::routeName
POST/api/routes/<id>/rawSave raw YAML for a route - body: {"content": "<yaml>"}
GET/api/keysList API keys
POST/api/keysCreate an API key - body: {"name": "..."}
DELETE/api/keys/<id>Delete an API key

Health check

http
GET /health

Response (no auth required):

json
{"ok": true, "version": "1.11.0"}

Error responses

StatusMeaning
400Bad request (invalid body or filename, RESTART_METHOD not configured)
401Missing or invalid API key
404Endpoint not available (e.g. STATIC_CONFIG_PATH not set)
429Rate limit exceeded
500Internal error
502Cannot reach Traefik or the CrowdSec LAPI

All errors return {"error": "message", "ok": false}.

Backup format

Local backups are per-file .bak files, not zip archives, named filename.YYYYMMDD_HHMMSS.bak (e.g. dynamic.yml.20250601_143022.bak) with a UTC timestamp. When restoring, the agent strips the timestamp suffix to recover the original filename and writes it back to CONFIG_PATH - or to STATIC_CONFIG_PATH when the recovered name is that of the static config file. A .bak of the destination is taken before the restore overwrites it.

POST /api/backup/create creates one .bak per config file found in CONFIG_PATH (and STATIC_CONFIG_PATH if configured) in a single request. POST /api/configs also creates a .bak for the affected file before writing.

Traefik data envelope

/api/traefik/routers, /api/traefik/services and /api/traefik/middlewares do NOT proxy the Traefik API directly. They fetch every protocol, following the API's pagination, and return a structured envelope:

  • /api/traefik/routers - {"http": [...], "tcp": [...], "udp": [...]}
  • /api/traefik/services - {"http": [...], "tcp": [...], "udp": [...]}
  • /api/traefik/middlewares - {"http": [...], "tcp": [...]}

This matches the format TM expects for its own Traefik API calls, so agent data renders identically to local data.

If the agent cannot reach its Traefik API, or Traefik answers with a non-200 status, these endpoints return 502 with {"error": "traefik unavailable...", "ok": false}. Earlier versions turned a non-200 response into an empty list with status 200, so a broken Traefik looked the same as one with nothing configured.

API keys

The agent supports multiple named API keys, stored in <BACKUP_DIR>/api_keys.json. Only a SHA-256 hash of each key is stored - the raw key is shown once at creation and cannot be recovered. The primary TMA_API_KEY from the environment always works regardless of the key store. Create, list and delete additional keys via /api/keys, which is useful when several TM instances connect to the same agent.

Proxying through TM

TM proxies agent calls server-side via /api/agents/proxy/<agent-id>/<path>. For example:

GET /api/agents/proxy/abc123/traefik/routers

Routes to:

GET https://agent-host:8090/api/traefik/routers

TM injects the X-Api-Key header automatically using the stored (encrypted) key.