Overview
The server component provides a FastAPI-based HTTP interface for managing workflows, handling authentication, processing events, and exposing application functionality through REST APIs.The SDK includes
APIServer, a complete FastAPI implementation that handles workflow triggers, authentication, metadata operations, and event processing.ServerInterface
The base interface that all server implementations must follow.APIServer
TheAPIServer class provides a complete FastAPI-based server implementation with built-in support for workflow management, authentication, and event handling.
Constructor Parameters
Optional lifespan manager for the FastAPI application. Used for startup/shutdown hooks.
Handler instance for processing application-specific operations like authentication, preflight checks, and metadata fetching.
Client for interacting with Temporal workflows. Required for workflow operations.
Path to frontend template files for the UI.
Whether to enable the UI frontend routes.
Whether the application has a configuration map for the UI.
List of Dapr pub/sub subscriptions for event-driven workflows.
Core API Endpoints
The server automatically registers several API endpoints:Workflow Endpoints (/workflows/v1)
POST /workflows/v1/auth
POST /workflows/v1/auth
Test authentication credentials.Request:Response:Calls
handler.test_auth()POST /workflows/v1/metadata
POST /workflows/v1/metadata
Fetch metadata from the source system.Request:Response:Calls
handler.fetch_metadata()POST /workflows/v1/check
POST /workflows/v1/check
Perform preflight validation checks.Request:Response:Calls
handler.preflight_check()POST /workflows/v1/start
POST /workflows/v1/start
Start a new workflow execution.Request:Response:
GET /workflows/v1/status/{workflow_id}/{run_id}
GET /workflows/v1/status/{workflow_id}/{run_id}
Get the status of a workflow run.Response:
POST /workflows/v1/stop/{workflow_id}/{run_id}
POST /workflows/v1/stop/{workflow_id}/{run_id}
Stop a running workflow.Response:
GET /workflows/v1/config/{config_id}
GET /workflows/v1/config/{config_id}
Retrieve workflow configuration.Response:
POST /workflows/v1/config/{config_id}
POST /workflows/v1/config/{config_id}
Update workflow configuration.Request:Response:
POST /workflows/v1/file
POST /workflows/v1/file
Upload a file to object storage.Form Data:
file: File to uploadfilename: Original filenameprefix: Storage prefix (default: “workflow_file_upload”)contentType: File content type
GET /workflows/v1/configmap/{config_map_id}
GET /workflows/v1/configmap/{config_map_id}
Get a configuration map.Response:Calls
handler.get_configmap()Event Endpoints (/events/v1)
POST /events/v1/event/{event_id}
POST /events/v1/event/{event_id}
Trigger a workflow from an event.Request:Response:
POST /events/v1/drop
POST /events/v1/drop
Drop events that don’t match filters.Response:
Dapr Endpoints (/dapr)
GET /dapr/subscribe
GET /dapr/subscribe
Get Dapr pub/sub subscription configuration.Response:
Other Endpoints
GET /observability
GET /observability
Launch DuckDB UI for log exploration.Redirects to
http://0.0.0.0:4213GET /
GET /
Serve the application UI (if
ui_enabled=True).Registering Workflows
Register workflows with the server using different trigger types.HTTP Trigger
Register a workflow that is triggered via HTTP POST:POST /workflows/v1/start endpoint.
Event Trigger
Register a workflow that is triggered by events:Multiple Triggers
A workflow can have multiple triggers:Starting the Server
Host address to bind to. Use
0.0.0.0 to accept connections from any network interface.Port to listen on. Configurable via
APP_PORT environment variable.ASGI root path passed to uvicorn. Used when the app is behind a proxy with a path prefix.Example: If your app is served at
https://example.com/api/my-app, set root_path="/api/my-app"Middleware
The server automatically includes middleware for:LogMiddleware
Logs all incoming requests and responses with timing information.MetricsMiddleware
Collects metrics for:- Request counts by endpoint and status code
- Request duration histograms
- Active request gauges
Documentation
The server can automatically generate and serve Atlan documentation:/atlandocs
Custom Subscriptions
Register custom Dapr pub/sub subscriptions:Complete Server Example
Instance Attributes
| Attribute | Type | Description |
|---|---|---|
app | FastAPI | The FastAPI application instance |
workflow_client | Optional[WorkflowClient] | Client for Temporal operations |
handler | Optional[HandlerInterface] | Handler for business logic |
workflow_router | APIRouter | Router for workflow endpoints |
dapr_router | APIRouter | Router for Dapr pub/sub |
events_router | APIRouter | Router for event handling |
ui_enabled | bool | Whether UI routes are enabled |
has_configmap | bool | Whether configmap is available |
workflows | List[WorkflowInterface] | Registered workflows |
event_triggers | List[EventWorkflowTrigger] | Event-based triggers |
Environment Variables
The server respects these environment variables:| Variable | Description | Default |
|---|---|---|
APP_HOST | Server host address | 0.0.0.0 |
APP_PORT | Server port | 8000 |
APP_TENANT_ID | Tenant identifier | - |
WORKFLOW_UI_HOST | Workflow UI host | - |
WORKFLOW_UI_PORT | Workflow UI port | - |
Best Practices
Use Environment-Based Configuration
Use Environment-Based Configuration
Configure the server using environment variables for different environments.
Implement Health Checks
Implement Health Checks
Add custom health check endpoints for monitoring.
Use Lifespan for Resource Management
Use Lifespan for Resource Management
Implement lifespan context managers for startup/shutdown tasks.
Related Components
- Application - Orchestrates server and worker
- Workflows - Register workflows with the server
- Handlers - Implement endpoint logic