Back to docs
Backend API

API Overview

The Dagy REST API provides programmatic access to all platform features: flow management, run execution, scheduling, team management, billing, secrets, notifications, and monitoring.

Base URL

The API is served from a single AWS Lambda function via API Gateway. The base URL depends on your deployment:

https://api.dagy.io/app

For local development, the default is http://localhost:8000.

Authentication

All endpoints (except /health, /billing/plans, /billing/webhook, and /webhooks/{token}) require authentication. Dagy supports three authentication methods:

Access Tokens: Obtained via POST /auth/login. Include in requests as:

Authorization: Bearer <access_token>

API Keys: Created via POST /api-keys with scoped permissions. Include as:

Authorization: Bearer dagy_<key>

JWT Tokens: When DAGY_JWT_REQUIRED=true, the API validates JWTs against the configured JWKS URL. Include as:

Authorization: Bearer <jwt>

See the Authentication Guide for full details.

RBAC (Role-Based Access Control)

Every authenticated request resolves to an identity with a role. Dagy enforces permissions on all endpoints:

RoleDescription
ownerFull access — the only role with any billing.* or admin.org permission
adminEverything except billing and org-level settings (billing.*, admin.org)
developerRead/write/trigger on flows, runs, schedules, nodes, dep-packages, connectors; read-only on secrets/environments
viewerRead-only across flows, runs, schedules, nodes, environments, dep-packages, connectors

The full 4-role × 30-permission matrix (generated from src/dagy_api/auth.py) is in Auth. When a request lacks the required permission, the API returns 403 Forbidden.

Rate Limiting

All authenticated endpoints are rate-limited using a token-bucket algorithm:

  • 120 requests per minute per API key or IP address
  • 200 burst capacity
  • Excluded endpoints: /health, /docs, /openapi.json

Rate limit headers are included in every response:

HeaderDescription
X-RateLimit-LimitMaximum requests per minute
X-RateLimit-RemainingRequests remaining in current window
Retry-AfterSeconds to wait (only on 429 responses)

Request Format

All request bodies must be JSON with Content-Type: application/json. Query parameters are used for filtering and pagination.

Response Format

All responses are JSON. Successful responses return the resource directly. Error responses follow the standard format:

{
  "detail": "Human-readable error message"
}

Pagination

List endpoints support cursor-based pagination:

  • limit: Maximum items to return (default: 100)
  • next_token: Opaque cursor from a previous response
{
  "items": [...],
  "next_token": "opaque-cursor-string"
}

When next_token is null or absent, there are no more pages.

Triggering Model

Flow runs can be triggered in four ways:

  1. API run trigger: POST /runs with deployment or flow name
  2. Schedule-managed trigger: Automatic via scheduler tick (cron, interval)
  3. Manual schedule trigger: POST /schedules/{schedule_id}/trigger
  4. Webhook trigger: POST /webhooks/{token} from external systems via sensors

Event Processing

The API uses SQS for asynchronous event processing. Run triggers are enqueued and processed by the Lambda SQS consumer. Supported event types:

  • flow_trigger: Execute a flow run
  • scheduler_tick: Process due schedules
  • run_status_poll: Poll async backend status (Step Functions, ECS)
  • run_status_update: Update run status and trigger notifications

Endpoint Categories

The API is organized into these categories (see Endpoints Reference for full details):

CategoryEndpointsDescription
Authentication2Login, logout
User2Current user identity and profile
Flows8Register, list, versions, latest, get, delete, deploy, backends
Deployments5Create, list, rollback, change version, delete
Runs5Trigger, list, get, cancel, logs
Scheduling5CRUD + manual trigger + partial update
API Keys3Create, list, delete
Organizations6Org CRUD, members, roles
DAG Drafts6Visual builder drafts + node types
Usage & Billing10Metering, quotas, Stripe
Audit Logs2Query audit trail
Secrets6Encrypted secret management
Notifications9Channels + alert rules
Environments12CRUD, variables, reorder, diff, promote
Sensors6Event triggers + webhooks
Artifacts3Multipart upload (initiate, complete, abort)
UI Config4Marketing, navigation, dashboard, settings
AI Studio17Session-based agentic workflow building and attachments
Super Admin16Customer management, exceptions, impersonation
Health2Health checks

The table above is an approximate grouping; the authoritative, always-current count comes from the generated OpenAPI spec.

Total (from docs/api/openapi.json): 126 unique paths / 168 operations.

Regenerate the spec and these counts with:

uv run python scripts/generate_openapi.py

OpenAPI Specification

The canonical OpenAPI schema is auto-generated by FastAPI. Generate it with:

uv run python scripts/generate_openapi.py

This writes the schema to docs/api/openapi.json (and --check fails if it is stale — wire it into CI). You can also access it at /openapi.json on a running API instance.