Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

API Reference

Brokkr provides a comprehensive REST API for managing deployments, agents, stacks, templates, and work orders across your Kubernetes clusters.

Interactive API Documentation

The Brokkr broker includes an interactive Swagger UI that provides complete API documentation with:

  • All available endpoints with request/response schemas
  • Authentication requirements for each endpoint
  • Try-it-out functionality for testing endpoints
  • Example requests and responses

Access Swagger UI at: http://<broker-url>/swagger-ui

OpenAPI spec available at: http://<broker-url>/docs/openapi.json

API Overview

All API endpoints are prefixed with /api/v1/ and require authentication via PAK (Pre-Authenticated Key) in the Authorization header.

Authentication

# All requests require a PAK in the Authorization header
curl -H "Authorization: Bearer <your-pak>" http://localhost:3000/api/v1/...

There are three types of PAKs:

  • Admin PAK: Full access to all endpoints
  • Agent PAK: Access to agent-specific endpoints (target state, events, heartbeat)
  • Generator PAK: Access to create deployment objects for assigned stacks

Core Resources

Stacks

Stacks are collections of Kubernetes resources managed as a unit.

MethodEndpointDescription
GET/stacksList all stacks
POST/stacksCreate a new stack
GET/stacks/:idGet stack by ID
PUT/stacks/:idUpdate a stack
DELETE/stacks/:idDelete a stack
GET/stacks/:id/labelsList stack labels
POST/stacks/:id/labelsAdd label to stack
DELETE/stacks/:id/labels/:labelRemove label from stack
GET/stacks/:id/annotationsList stack annotations
POST/stacks/:id/annotationsAdd annotation to stack
DELETE/stacks/:id/annotations/:keyRemove annotation
GET/stacks/:id/deployment-objectsList deployment objects
POST/stacks/:id/deployment-objectsCreate deployment object
POST/stacks/:id/deployment-objects/from-templateInstantiate template

Agents

Agents run in Kubernetes clusters and apply deployment objects.

MethodEndpointDescription
GET/agentsList all agents
POST/agentsRegister a new agent
GET/agents/:idGet agent by ID
PUT/agents/:idUpdate an agent
DELETE/agents/:idDelete an agent
GET/agents/:id/target-stateGet agent’s target state
POST/agents/:id/heartbeatRecord agent heartbeat
GET/agents/:id/labelsList agent labels
POST/agents/:id/labelsAdd label to agent
GET/agents/:id/annotationsList agent annotations
POST/agents/:id/annotationsAdd annotation to agent
GET/agents/:id/stacksList agent’s associated stacks
GET/agents/:id/targetsList agent’s stack targets
POST/agents/:id/targetsAdd stack target
DELETE/agents/:id/targets/:stack_idRemove stack target
POST/agents/:id/rotate-pakRotate agent PAK

Templates

Reusable stack templates with Tera templating and JSON Schema validation.

MethodEndpointDescription
GET/templatesList all templates
POST/templatesCreate a new template
GET/templates/:idGet template by ID
PUT/templates/:idUpdate a template
DELETE/templates/:idDelete a template
GET/templates/:id/labelsList template labels
POST/templates/:id/labelsAdd label to template
GET/templates/:id/annotationsList template annotations
POST/templates/:id/annotationsAdd annotation to template

Work Orders

Transient operations like container builds routed to agents.

MethodEndpointDescription
GET/work-ordersList all work orders
POST/work-ordersCreate a new work order
GET/work-orders/:idGet work order by ID
DELETE/work-orders/:idCancel a work order
POST/work-orders/:id/claimClaim a work order (agent)
POST/work-orders/:id/completeComplete a work order (agent)
GET/agents/:id/work-orders/pendingGet pending work orders for agent
GET/work-order-logList completed work orders
GET/work-order-log/:idGet completed work order details

Generators

External systems that create deployment objects.

MethodEndpointDescription
GET/generatorsList all generators
POST/generatorsCreate a new generator
GET/generators/:idGet generator by ID
PUT/generators/:idUpdate a generator
DELETE/generators/:idDelete a generator
POST/generators/:id/rotate-pakRotate generator PAK

Other Endpoints

MethodEndpointDescription
GET/agent-eventsList agent events
GET/agent-events/:idGet agent event by ID
GET/deployment-objects/:idGet deployment object by ID
POST/auth/pakVerify a PAK

Webhooks

MethodEndpointDescription
GET/webhooksList webhook subscriptions
POST/webhooksCreate webhook subscription
GET/webhooks/event-typesList available event types
GET/webhooks/:idGet webhook subscription
PUT/webhooks/:idUpdate webhook subscription
DELETE/webhooks/:idDelete webhook subscription
POST/webhooks/:id/testTest webhook delivery
GET/webhooks/:id/deliveriesList webhook deliveries

Admin

MethodEndpointDescription
GET/admin/audit-logsQuery audit logs
POST/admin/config/reloadReload broker configuration

Health Monitoring

MethodEndpointDescription
GET/deployment-objects/:id/healthGet deployment health
GET/deployment-objects/:id/diagnosticsGet diagnostics
POST/deployment-objects/:id/diagnosticsRequest diagnostic

Health Endpoints

The broker exposes health endpoints (not under /api/v1/):

EndpointDescription
/healthzBasic health check
/readyzReadiness probe
/metricsPrometheus metrics

See Health Endpoints for details.

Error Handling

All API errors return JSON with an error field:

{
  "error": "Description of what went wrong"
}

Common HTTP status codes:

  • 400 - Bad request (invalid input)
  • 401 - Unauthorized (missing or invalid PAK)
  • 403 - Forbidden (valid PAK but insufficient permissions)
  • 404 - Not found
  • 422 - Unprocessable entity (validation failed)
  • 500 - Internal server error

Rate Limiting

The API does not currently implement rate limiting. For production deployments, consider placing a reverse proxy in front of the broker.