Workflow APIs and HTTP integrations
Workflow APIs and HTTP integrations are the transport layer for defining, starting, observing, and controlling workflows from outside the workflow engine. REST endpoints serve designer and operator clients, the optional real-time channel streams instance changes, and HTTP activities let a workflow receive requests or call external services.
Transport boundaries
The system exposes separate boundaries for workflow management, workflow execution, live updates, inbound HTTP triggers, webhook events, and dashboard data. The host chooses which boundaries to enable and places them in its ASP.NET request pipeline. The usual REST prefix is /elsa/api, while workflow-trigger routes use the configured HTTP base path. See the related server composition and server applications pages for the host layers around these boundaries.
| Boundary | Main purpose | Typical caller |
|---|---|---|
| Workflow REST API | Save, publish, inspect, execute, dispatch, cancel, and export workflow resources | Designer, admin tool, service client |
| Workflow instance hub | Receive live execution and instance changes for an observed instance | Designer or monitoring client |
| HTTP workflow routes | Start a workflow or resume a waiting workflow from an HTTP request | Browser, service, or integration partner |
| Webhook endpoint | Accept a webhook event and route it to matching workflow activities | External webhook provider |
| Dashboard API | Read aggregate status, trends, recent activity, and attention items | Dashboard UI |
REST API surface
The workflow API is a permission-aware REST surface over workflow definitions, instances, runtime state, and workflow support data. Definition routes cover draft save, publish, retract, import, export, version work, graph views, consumer lookup, bulk actions, and execution. Instance routes cover list and detail views, state, journal, variables, activity execution records, import, export, cancel, and delete.
The API also exposes controlled entry points for event triggers, external task completion, activity tests, bookmark queue dead letters, and runtime administration. Descriptor routes let a dashboard or designer discover activity types, property options, expression types, variable types, storage and commit strategies, incident and log strategies, output converters, activation strategies, and installed features. These routes let clients adapt to the installed workflow capabilities instead of assuming that every host has the same catalog.
Workflow definitions use version-aware handles. A caller can work with a definition identity, a stored version, or a published version depending on the operation. The API returns linked models for many definition views so clients can follow references between workflows.
The API uses a shared serializer so workflow graphs, activity arguments, variables, and response models keep one JSON contract. Mutable definition operations honor the system's read-only mode. The default route prefix is elsa/api, and a host can change it through ApiEndpointOptions.
The main REST flow moves from authoring to runtime observation:
flowchart LR
Client[Designer or service client] --> Definitions[Create or update definition]
Definitions --> Publish[Publish a version]
Publish --> Start[Execute or dispatch]
Start --> Instance[Workflow instance]
Instance --> Inspect[Read state, journal, variables, and activity data]
Instance --> Control[Cancel, export, or delete]
References: src/…/WorkflowPermissions.cs• L11-50 src/…/Endpoint.cs• L15-45 src/…/Endpoint.cs• L31-37 src/…/Endpoint.cs• L24-28 src/…/Endpoint.cs• L14-42 src/…/Endpoint.cs• L13-34 src/…/Endpoint.cs• L16-67 src/…/Endpoint.cs• L15-57 src/…/Endpoint.cs• L17-61 src/…/Endpoint.cs• L12-35 src/…/Endpoint.cs• L17-45 src/…/Endpoint.cs• L14-24 src/…/ApiEndpointOptions.cs• L3-14 src/…/WebApplicationExtensions.cs• L29-62
Workflow API client
The API client gives applications typed access to the REST boundary without requiring them to build URLs or JSON bodies by hand. Its definition client covers resource lifecycle and graph operations. Its execution client separates direct execution from dispatch. Its instance client covers queries, state inspection, journal and variable reads, cancellation, deletion, and archive transfer.
The client is built from HttpClient instances and Refit contracts. It accepts a server base address and can add API-key authentication or a custom authentication handler. The standard setup adds retry behavior to ordinary resource clients, while execution calls use a client without the default retry policy so a caller does not accidentally repeat a workflow start.
External authentication descriptor models represent permissions as a resource plus the verbs that resource accepts. This gives a client enough information to offer valid permission choices without treating a full permission string as one opaque name. Unverified descriptors can still appear when a module declares a resource that has no matching catalog entry, so clients must not assume that every descriptor has been checked by the server.
References: src/…/IWorkflowDefinitionsApi.cs• L11-24 src/…/IWorkflowDefinitionsApi.cs• L93-135 src/…/IExecuteWorkflowApi.cs• L7-31 src/…/IWorkflowInstancesApi.cs• L10-27 src/…/IWorkflowInstancesApi.cs• L29-117 src/…/DependencyInjectionExtensions.cs• L41-101 src/…/ElsaClientOptions.cs• L6-21 src/…/ElsaClientBuilderOptions.cs• L11-47 src/…/ExternalAuthenticationDescriptors.cs• L36-58
API security and limits
REST operations declare a permission at the endpoint boundary. The permission catalog groups access by resource and verb. Definition authoring and lifecycle work use definition permissions. Instance inspection and control use instance permissions. Activity execution data, runtime control, event triggers, task completion, descriptor discovery, tests, and dead-letter repair have separate permissions.
Definition writes also pass through the read-only guard. The same guard applies to delete, publish, retract, version, import, and reference-update operations. This keeps a deployment-wide authoring lock separate from the caller's permission to use the API.
Workflow definitions are checked for host-disabled script languages before the API saves, publishes, imports, or starts them. The check is a deployment rule, not a per-caller trust rule. If a definition uses a disabled host language, the API reports a 400 Bad Request that explains the disabled capability rather than reporting a caller permission failure.
HTTP-trigger routes can use a separate rate limit and can reject new work while the runtime pauses or drains. This keeps external callers from adding new work during maintenance or shutdown. The transport returns 503 Service Unavailable with a retry hint based on the reason for the pause.
References: src/…/WorkflowPermissions.cs• L53-80 src/…/WorkflowDefinitionScriptAuthorizationService.cs• L12-24 src/…/WorkflowDefinitionScriptAuthorizationService.cs• L51-81 src/…/WorkflowDefinitionScriptAuthorizationFailure.cs• L3-15 src/…/WorkflowExecutionHelper.cs• L24-39 src/…/Endpoint.cs• L62-75 src/…/Endpoint.cs• L47-65 src/…/Endpoint.cs• L30-39 src/…/Endpoint.cs• L21-32 src/…/Endpoint.cs• L14-25 src/…/Endpoint.cs• L16-40 src/…/Endpoint.cs• L17-45 src/…/WebApplicationExtensions.cs• L40-53 src/…/ApplicationBuilderExtensions.cs• L18-44 src/…/HttpWorkflowsMiddleware.cs• L54-64
Descriptor and diagnostic APIs
Descriptor APIs describe the capabilities that a host makes available to a designer. They cover both the activity catalog and the supporting choices that shape a workflow, such as variable types, expression languages, output conversion, storage, commit, incident, log, and activation strategies. Activity descriptors can be refreshed and can return context-specific property options.
Diagnostic APIs expose the records needed to explain workflow progress. Clients can count or list activity executions, read one execution's call stack, request execution statistics, and page through a workflow journal or a filtered journal. Operators can inspect bookmark queue dead letters and either replay or delete a failed queue item.
The descriptor and diagnostic boundaries are read-focused. Actions that can alter runtime work, such as dead-letter replay, task completion, event triggering, and runtime control, use explicit action permissions instead of the read permission.
References: src/…/Endpoint.cs• L9-27 src/…/Endpoint.cs• L8-46 src/…/Endpoint.cs• L15-47 src/…/Endpoint.cs• L17-41 src/…/Endpoint.cs• L18-55 src/…/Endpoint.cs• L15-28 src/…/Endpoint.cs• L15-28 src/…/Endpoint.cs• L16-28 src/…/Endpoint.cs• L16-29 src/…/Endpoint.cs• L15-27 src/…/Endpoint.cs• L14-29 src/…/Endpoint.cs• L14-41 src/…/Endpoint.cs• L15-64 src/…/Endpoint.cs• L12-39 src/…/Endpoint.cs• L17-69 src/…/Endpoint.cs• L11-36
Real-time workflow updates
Real-time updates provide a live view of one workflow instance beside the REST snapshot. The client connects to the SignalR hub, authenticates, and asks to observe an instance. The hub checks the workflow-instance read permission and tenant access before placing the connection in that instance's group. Notifications from workflow execution and management then become messages for that group.
The update stream covers the instance record, workflow execution log, and activity execution progress. It is an update signal rather than a complete replacement for REST reads. A client can use the instance identifier in each message to fetch current detail when it needs a full state.
This diagram shows the path from a workflow change to an authorized client.
sequenceDiagram
participant Runtime as Workflow runtime
participant Events as Workflow notifications
participant Broadcaster as Progress broadcaster
participant Hub as Workflow instance hub
participant Client as Authorized client
Client->>Hub: Connect and observe instance
Hub-->>Client: Join instance group after permission and tenant checks
Runtime->>Events: Commit instance or log change
Events->>Broadcaster: Deliver change notification
Broadcaster->>Hub: Publish instance or progress message
Hub-->>Client: Send update to instance group
Client->>Hub: Read current detail through REST when needed
The hub is available at /elsa/hubs/workflow-instance when the host maps it. Authentication is required for the connection. Observation needs the workflow-instance view permission or an equivalent broader permission. The instance must belong to the current tenant or be tenant-agnostic.
References: src/…/RealTimeWorkflowUpdatesFeature.cs• L8-23 src/…/WorkflowInstanceHub.cs• L14-73 src/…/BroadcastWorkflowProgress.cs• L12-91 src/…/IWorkflowInstanceClient.cs• L5-44 src/…/ModuleExtensions.cs• L21-28
HTTP workflow integration
The HTTP integration turns workflow triggers into normal HTTP routes and turns outbound calls into workflow activities. An HttpEndpoint waits for a request on a path and method. A SendHttpRequest activity calls another service and exposes its status, headers, and parsed response content to later activities. The HTTP feature also defines the content and route types that cross the workflow boundary.
Inbound HTTP requests
The HTTP workflow middleware is the gateway for inbound trigger requests. It normalizes the request path and first checks the configured base path. It then maps the path through the HTTP route table and uses the resulting route and method to find indexed workflow triggers or waiting bookmarks. A trigger starts a new instance. A matching bookmark resumes an existing instance. If no workflow matches, the request continues to later host middleware unless the configured base path marks it as an HTTP workflow route.
Before it accepts new workflow work, the gateway checks whether the runtime is accepting work. A paused or draining runtime returns 503 Service Unavailable with a reason-based retry hint. For an accepted request, the gateway can use a selected workflow instance ID or correlation ID to narrow bookmark matching. This lets an external caller resume the intended waiting workflow without coupling the caller to the workflow's internal activity layout.
When a request reaches an endpoint activity, the workflow can use the request, route values, query values, headers, parsed body, and uploaded files. The endpoint can require authentication or a policy. It can also limit request and file size and restrict file extensions or MIME types. The activity either exposes a workflow outcome for these checks or writes the matching HTTP error response.
This diagram shows how one inbound request crosses from ASP.NET into workflow execution.
flowchart LR
Request[Inbound HTTP request] --> Gateway[HTTP workflow gateway]
Gateway --> Route[Match path and method]
Route --> Trigger[Indexed workflow trigger]
Route --> Bookmark[Waiting workflow bookmark]
Trigger --> Start[Start workflow instance]
Bookmark --> Resume[Resume workflow instance]
Start --> Endpoint[HTTP endpoint activity]
Resume --> Endpoint
Endpoint --> Data[Request data and parsed content]
Endpoint --> Response[Workflow-written HTTP response]
Route --> Next[Next host middleware when no route matches]
The gateway hashes the normalized method and route after it removes the configured base path from the matched route. Route matching supports route parameters. Correlation and instance identifiers can come from the configured header or query selectors, with higher-priority selectors taking precedence. When the base path is configured and no trigger or bookmark matches, the gateway returns 404 Not Found instead of passing the request to later middleware.
References: src/…/HttpWorkflowsMiddleware.cs• L26-133 src/…/HttpWorkflowsMiddleware.cs• L135-233 src/…/HttpWorkflowsMiddleware.cs• L259-358 src/…/HttpWorkflowsMiddleware.cs• L397-429 src/…/HttpEndpoint.cs• L18-23 src/…/HttpEndpoint.cs• L46-171 src/…/HttpEndpoint.cs• L181-299 src/…/DefaultHttpEndpointRoutesProvider.cs• L9-35 src/…/RouteMatcher.cs• L8-29 src/…/HttpFeature.cs• L130-183 src/…/HttpFeature.cs• L244-249
Outbound HTTP activities
Outbound HTTP activities let a workflow use another HTTP service as one step in its process. The activity builds a request from a URL, method, content, content type, authorization value, and headers. It parses supported response content and exposes the status code, response headers, and parsed content to the workflow.
SendHttpRequest maps response status codes and transport errors to workflow paths. A workflow can provide a path for expected status codes, an unmatched status, a connection failure, or a timeout. The common resilience boundary can retry transient failures, and the activity records transport errors in workflow execution data when a request cannot complete.
References: src/…/SendHttpRequestBase.cs• L17-22 src/…/SendHttpRequestBase.cs• L24-120 src/…/SendHttpRequestBase.cs• L158-220 src/…/SendHttpRequestBase.cs• L224-307 src/…/SendHttpRequest.cs• L7-71 src/…/HttpFeature.cs• L79-87 src/…/HttpFeature.cs• L149-167
Webhook handling
The webhook boundary accepts events from a registered source and turns a recognized event type into a workflow stimulus. The public endpoint is POST /webhooks. It reads the event, finds a configured source that declares its type, and sends a notification. Unknown event types receive a successful response without starting a workflow.
Webhook sources also shape the workflow-facing activity catalog. For each event type with a binding, the system exposes an activity with the source category, display name, event type, and payload type. When the event arrives, the matching activity receives the full webhook event as workflow input and makes its payload available to the workflow. A declared payload type converts the payload before the activity completes.
This diagram shows the event path from an external provider to a waiting workflow.
flowchart LR
Provider[Webhook provider] --> Endpoint[POST /webhooks]
Endpoint --> Source[Find registered source and event type]
Source -->|No match| Accepted[Return success without dispatch]
Source -->|Match| Notification[Webhook event notification]
Notification --> Stimulus[Send event stimulus and event input]
Stimulus --> Activity[Resume matching webhook activity]
Activity --> Payload[Expose converted payload to workflow]
The endpoint is anonymous because the webhook source is the external caller. Source registration and source-specific verification belong at the webhook integration boundary. The workflow activity match uses the event type, while the event input carries the provider payload and event data.
References: src/…/Endpoint.cs• L11-40 src/…/WebhooksFeature.cs• L11-78 src/…/WebhookEventActivityProvider.cs• L8-60 src/…/InvokeWebhookActivities.cs• L9-29 src/…/WebhookEventReceived.cs• L13-73 src/…/ModuleExtensions.cs• L7-19
Dashboard-facing APIs
The dashboard API is a read boundary for operational views. It does not replace workflow instance or journal endpoints. Instead, it returns shaped summaries that help a dashboard show runtime health, workflow counts, diagnostics, recent activity, items that need attention, trends, and workflow hotspots.
All dashboard routes use the read:dashboard permission. Queries can select a time range and whether system workflows are included. The provider combines contributions from registered dashboard contributors and returns one response for the dashboard client. Contributor failures do not normally remove the whole dashboard response. Unavailable contributions are skipped while cancellation still stops the request.
| Route | View |
|---|---|
GET /dashboard/overview | Runtime state, workflow metrics, diagnostics, metrics, and panels |
GET /dashboard/recent-activity | Recent workflow activity with a bounded result count |
GET /dashboard/needs-attention | Prioritized findings that need operator review |
POST /dashboard/workflow-trends | Time buckets for created, finished, faulted, suspended, and incident-bearing workflows |
POST /dashboard/workflow-hotspots | Definitions ranked by executions, faults, incidents, or duration |
References: src/…/DashboardApiFeature.cs• L8-19 src/…/DashboardPermissions.cs• L1-6 src/…/Endpoint.cs• L9-23 src/…/Endpoint.cs• L9-24 src/…/Endpoint.cs• L9-24 src/…/Endpoint.cs• L9-21 src/…/Endpoint.cs• L9-21 src/…/DefaultDashboardProvider.cs• L7-139 src/…/DefaultDashboardProvider.cs• L151-199
Change checklist
When these files or sections are changed, remember to consider these:
- Keep REST route contracts aligned with the matching interfaces and request or response models in
Elsa.Api.Client. - Treat direct workflow execution and dispatch as different retry contracts. Do not add an automatic retry to a call that can start a second instance.
- When changing HTTP endpoint route or bookmark data, review base-path filtering, route-table matching, bookmark hashing, and pass-through behavior as one contract.
- When changing instance or activity notifications, update both the SignalR client contract and the message consumers that use the instance group.
- When changing webhook source event types, keep source registration, dynamic activity descriptors, stimulus names, and payload conversion aligned.
- When changing dashboard contribution models, preserve the aggregation rules for time range, count bounds, and contributor failure isolation.
- When changing a transport path, check its permission, tenant boundary, rate limit, and host pipeline mapping together.
- When changing permission resources or verbs, update permission descriptors and external-authentication permission mappings together.
- When changing script-capable workflow handling, keep authoring, import, publish, and execution checks aligned with the host language switches and the
400failure contract. - When changing runtime pause or drain behavior, keep status reads, control actions, conflict responses, and HTTP-trigger rejection behavior aligned.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Two indexed triggers or waiting bookmarks match one HTTP request | The request is rejected as ambiguous instead of selecting one workflow | Use a unique path and method combination, or provide selectors that identify the instance or correlation |
| HTTP workflow base path is enabled but no trigger or bookmark matches | The gateway returns 404 Not Found | Publish the workflow and use the route built from the configured base path |
| Runtime is paused or draining when an HTTP trigger arrives | New work is rejected with 503 Service Unavailable | Honor Retry-After and retry after the runtime accepts work |
| An observed workflow instance is outside the caller's tenant or the caller lacks read permission | The SignalR observation is denied | Authenticate the client and use the correct tenant and permission |
| A webhook event type has no registered source match | The endpoint returns success but no workflow starts | Register the source and event type before sending provider events |
| An outbound HTTP call times out or cannot connect | The workflow follows the configured timeout or connection-failure path | Connect the relevant error port or configure the workflow's resilience behavior |
| A client retries a direct execute request after an uncertain network result | The workflow may start more than once | Use an idempotency design at the caller or use dispatch semantics suited to the caller's delivery model |
| A definition uses a host-disabled C# or Python expression | Save, import, publish, or start returns 400 Bad Request and no workflow action completes | Enable the language only for trusted authors, or remove the disabled expression |
| Resume or force-drain is called while a drain is active | The request returns 409 Conflict and the runtime remains in drain state | Read the returned runtime state and wait for the next runtime generation |
| A bookmark queue dead letter cannot be replayed in its current state | Replay returns 409 Conflict and the queue item remains unresolved | Inspect the dead-letter record before replay and repair the underlying queue or workflow condition |
Key files
| File | Why to read it |
|---|---|
| src/…/WorkflowPermissions.cs | Defines the resource and verb model that protects the workflow transport surface. |
| src/…/Endpoint.cs | Shows the authoring boundary for saving or publishing a workflow definition. |
| src/…/PostEndpoint.cs | Shows the external execution entry point into the workflow runtime. |
| src/…/Endpoint.cs | Shows the separate dispatch contract used for runtime delivery. |
| src/…/Endpoint.cs | Shows the query boundary used by operator and designer views. |
| src/…/Endpoint.cs | Shows the paged and filtered workflow history boundary. |
| src/…/Endpoint.cs | Shows the diagnostic boundary for tracing nested activity execution. |
| src/…/Endpoint.cs | Shows the operator repair boundary for failed bookmark delivery. |
| src/…/IWorkflowDefinitionsApi.cs | Shows the typed definition-management contract used by external .NET callers. |
| src/…/IExecuteWorkflowApi.cs | Shows the separate execute and dispatch transport contract. |
| src/…/DependencyInjectionExtensions.cs | Shows client registration, authentication hooks, and retry separation. |
| src/…/ExternalAuthenticationDescriptors.cs | Shows how clients receive permission resources and supported verbs for external-authentication setup. |
| src/…/WorkflowDefinitionScriptAuthorizationService.cs | Shows the host-level gate for script-capable workflow definitions. |
| src/…/WorkflowInstanceHub.cs | Shows authorization, tenant checks, and instance-group subscription. |
| src/…/BroadcastWorkflowProgress.cs | Shows how workflow notifications become live client updates. |
| src/…/HttpWorkflowsMiddleware.cs | Shows the inbound HTTP route, trigger, bookmark, runtime-acceptance, and response boundary. |
| src/…/HttpEndpoint.cs | Shows the request data and policy exposed to an HTTP-triggered workflow. |
| src/…/SendHttpRequestBase.cs | Shows the common outbound request and response boundary. |
| src/…/Endpoint.cs | Shows how external webhook events enter the system. |
| src/…/InvokeWebhookActivities.cs | Shows how a recognized event becomes a workflow stimulus. |
| src/…/DefaultDashboardProvider.cs | Shows how dashboard views combine data from contributors. |
| src/…/Endpoint.cs | Shows the runtime status boundary used during pause and drain operations. |