Skip to main content

Introducing Formengine - The New Formbuilder, try for FREE formengine.io.

Core Services

The Web API core services manage other services and build the API by using an internal builder based on ASP.NET Minimal API. The core services do not include database providers, so be sure to add one when configuring the Web API.

Core Options

You can configure core services options using the WorkflowApiCoreOptions record provided as ASP.NET IOptions in the service collection. Below is a table describing its properties:

NameTypeDefaultDescription
BasePathstring"workflow-api"The root path to the Workflow Engine Web API endpoints. If an empty string is specified, the endpoints will be accessible via the root path of your application.
LicenseKeystring""The Workflow Engine license key with the Workflow Engine API option enabled. If the key is not provided, the API will not start. Request a key from our sales team at sales@optimajet.com.
DefaultTenantIdstring?WorkflowApiConstants.SingleTenantIdThe default workflow tenant ID to use when no tenant is specified in the request. If the default tenant is null, requests without a tenant specified will be rejected.
ProtectedGlobalParameterTypesHashSet<string>WorkflowApiConstants.DefaultProtectedGlobalParameterTypesGlobal Parameter types that cannot be accessed through generic Global Parameters Data API endpoints. Host applications can add, remove, or replace values in this set.

Protected Global Parameter Types

ProtectedGlobalParameterTypes prevents clients from reading or changing Workflow Engine system storage through the generic Global Parameters Data API endpoints. The default set protects Global Parameter types used for global code actions, runtime and server settings, plugins, security, logging, LDAP, OpenID Connect, and CORS configuration.

The protection is applied to the generic Global Parameters endpoints under workflow-api/data/global-parameters and workflow-api/search/global-parameters. Collection reads and deletes automatically exclude protected types. Single-item create, read, update, and delete requests are rejected when the current type, or the target type in an update request, is protected.

Designer and runtime global code actions continue to use the shared Workflow Engine Core Global Parameters API. They are not exposed for direct management through the generic Web API Global Parameters endpoints while their type remains in ProtectedGlobalParameterTypes.

Host applications can customize the protected type list when registering the Web API core services:

builder.Services.AddWorkflowApiCore(options =>
{
// Add a host-specific system type to the default protected list.
options.ProtectedGlobalParameterTypes.Add("CustomSystemType");

// Remove a type if it must be managed through the generic Global Parameters Data API.
options.ProtectedGlobalParameterTypes.Remove("settings");
});

To replace the default list completely, assign a new set:

builder.Services.AddWorkflowApiCore(options =>
{
options.ProtectedGlobalParameterTypes = new HashSet<string>(StringComparer.Ordinal)
{
"CustomSystemType"
};
});

Workflow Tenant Creation Options

When configuring the Workflow Engine Runtime using AddWorkflowRuntime, AddWorkflowTenants, or IWorkflowTenantRegistry.RegisterTenantsAsync(...), you can specify options for creating WorkflowRuntime instances. These options are defined in the WorkflowTenantCreationOptions class. In single-tenant mode, you can provide these options as ASP.NET IOptions in the service collection. Below is a table describing its properties:

NameTypeDefaultDescription
TenantIdsstring[][]The unique workflow tenant identifiers handled by the tenant instance. AddWorkflowRuntime(...) sets this to WorkflowApiConstants.SingleTenantId automatically. AddWorkflowTenants(...) and dynamic registry registration require at least one explicit tenant id.
WorkflowRuntimeCreationOptionsWorkflowRuntimeCreationOptionsnew()Options for configuring the Workflow Engine WorkflowRuntime runtime of the tenant.
PersistenceProviderIdstring?nullThe identifier of the data & workflow provider to use for the tenant creation. This identifier is used to select provider factory from the list of registered factories. If not specified, the first found factory will be used. Default identifiers are stored in PersistenceProviderId class. And they are the same for both data and workflow providers.
ConnectionStringstring""Specifies the connection string used by both data and workflow providers for tenant creation.
DataProviderCreationOptionsDataProviderCreationOptionsnew()Configuration options for the tenant's data provider.
WorkflowProviderCreationOptionsWorkflowProviderCreationOptionsnew()Options for configuring the Workflow Engine Core.Persistence.IWorkflowProvider provider of the tenant.

The properties of DataProviderCreationOptions are described in the database providers documentation.

Tenant identifiers are case-sensitive, must be non-null, and can be at most 128 characters long. The empty string WorkflowApiConstants.SingleTenantId is reserved for single-tenant mode and cannot be mixed with named tenant ids.

Workflow Runtime Creation Options

The WorkflowRuntimeCreationOptions record lets you configure a tenant’s WorkflowRuntime instance. The table below describes its properties:`

NameTypeDefaultDescription
RuntimeIdGuidGuid.EmptyThe unique identifier for the Workflow Engine runtime instance.
PersistenceProviderFactoryFunc<IWorkflowProvider?, IPersistenceProvider>provider => provider ?? throw new ArgumentNullException(nameof(provider))A factory method for creating an instance of IPersistenceProvider, serving as an interface for storing process data in the Workflow Engine runtime. The parameter provided to the factory is the default IWorkflowProvider provider specified when creating the tenant or null if no provider is specified.
WorkflowBuilderFactoryFunc<IWorkflowProvider?, IWorkflowBuilder>provider => new WorkflowBuilder<XElement>(provider, new XmlWorkflowParser(), provider).WithDefaultCache()A factory method for creating an instance of IWorkflowBuilder, serving as a workflow scheme parser for the Workflow Engine runtime. The parameter provided to the factory is the IWorkflowProvider provider specified when creating the tenant or null if no provider is specified.
ConfigureWorkflowRuntimeAction<WorkflowRuntime> _ => { }A delegate used to configure the Workflow Engine runtime instance. Called after the IPersistenceProvider and IWorkflowBuilder have been registered.
DisableMigrationsExecutionboolfalseIf set to true, disables the execution of WorkflowRuntimeExtensions.RunMigrations(WorkflowRuntime) during the initialization of the WorkflowRuntime.
DisableRuntimeAutoStartboolfalseIf set to true, prevents the WorkflowRuntimeConfigurationExtension.StartAsync() from automatically starting after initialization.
IgnoreNotCompiledGlobalActionsOnStartboolfalseIf set to true, the Workflow Engine runtime will ignore any compilation errors that occur in global actions during its startup.

Workflow Provider Creation Options

The WorkflowProviderCreationOptions record lets you configure a tenant’s IWorkflowProvider instance. The table below describes its properties:`

NameTypeDefaultDescription
DisableWritingProcessTransitionHistoryboolfalseIf set to true, prevents the Workflow Engine from saving process transition history to the database.
WriteSubprocessTransitionHistoryToRootProcessboolfalseWhen enabled, writes the transition history of subprocesses directly into the root process transition history.

ASP.NET Extensions

The core services provide extension methods to configure the Workflow Engine Web API in an ASP.NET application.

AddWorkflowApiCore(this IServiceCollection services, Action<WorkflowApiCoreOptions>? setupAction = null)

Adds the core Workflow Engine Web Api services, enabling you to add endpoints using MapWorkflowApi.

Parameters

NameTypeDescription
servicesIServiceCollectionThe IServiceCollection.
setupActionAction<WorkflowApiCoreOptions>?A delegate to configure the core Workflow Engine Api options.

Returns

TypeDescription
IServiceCollectionA IServiceCollection that can be used to further configure services.

AddWorkflowRuntime(this IServiceCollection services, Action<WorkflowTenantCreationOptions>? setupAction = null)

Creates WorkflowRuntime and registers it with the service collection in single-tenant mode. For multi-tenant applications, use AddWorkflowTenants or IWorkflowTenantRegistry.RegisterTenantsAsync(...) instead.

Parameters

NameTypeDescription
servicesIServiceCollectionThe IServiceCollection.
setupActionAction<WorkflowTenantCreationOptions>?A delegate to configure the Workflow Runtime options. Using this method implies single-tenant mode, so the tenant ids will be set to a WorkflowApiConstants.SingleTenantId.

Returns

TypeDescription
IServiceCollectionA IServiceCollection that can be used to further configure services.

AddWorkflowTenants(this IServiceCollection services, params WorkflowTenantCreationOptions[] options)

Registers static tenant creation options in multi-tenant mode. The hosted tenant registry service creates and starts the tenants during application startup. For single-tenant applications, use AddWorkflowRuntime instead.

Parameters

NameTypeDescription
servicesIServiceCollectionThe IServiceCollection.
optionsWorkflowTenantCreationOptions[]An array of options for creating the tenants.

Returns

TypeDescription
IServiceCollectionA IServiceCollection that can be used to further configure services.

AddWorkflowTenants(this IServiceCollection services, IEnumerable<WorkflowTenantCreationOptions> options)

Registers static tenant creation options in multi-tenant mode. The hosted tenant registry service creates and starts the tenants during application startup. For single-tenant applications, use AddWorkflowRuntime instead.

Parameters

NameTypeDescription
servicesIServiceCollectionThe IServiceCollection.
optionsIEnumerable<WorkflowTenantCreationOptions>An enumerable of options for creating the tenants.

Returns

TypeDescription
IServiceCollectionA IServiceCollection that can be used to further configure services.

MapWorkflowApi(this IEndpointRouteBuilder endpoints)

Maps all Workflow Engine Web Api endpoints to the specified IEndpointRouteBuilder. When using this method, you must first add services using AddWorkflowApiCore.

Parameters

NameTypeDescription
endpointsIEndpointRouteBuilderThe IEndpointRouteBuilder.

Returns

TypeDescription
IEndpointRouteBuilderA IEndpointRouteBuilder that can be used to further configure endpoints.

IWorkflowTenantRegistry

Service for dynamically registering, unregistering, and snapshotting workflow tenants in a Workflow Engine Web API. The registry is mutable; request and read code should use IWorkflowTenantSnapshot or IWorkflowTenantLocator for a consistent view of tenants.

RegisterTenantsAsync(IEnumerable<WorkflowTenantCreationOptions> options) and RegisterTenantsAsync(params WorkflowTenantCreationOptions[] options)

Creates tenants from creation options, starts registry-owned tenants, registers them, and publishes a new immutable snapshot.

Parameters

NameTypeDescription
optionsIEnumerable<WorkflowTenantCreationOptions> or WorkflowTenantCreationOptions[]Tenant creation options.

Returns

TypeDescription
IReadOnlyCollection<IWorkflowTenant>The created tenant instances.

RegisterTenantsAsync(IEnumerable<IWorkflowTenant> tenants) and RegisterTenantsAsync(params IWorkflowTenant[] tenants)

Registers already created tenants and publishes a new immutable snapshot. Registry-owned tenants are started before the snapshot is published. Externally owned tenants are published without StartAsync() being called by the registry.

Parameters

NameTypeDescription
tenantsIEnumerable<IWorkflowTenant> or IWorkflowTenant[]Tenants to register.

UnregisterTenantsAsync(IEnumerable<IWorkflowTenant> tenants) and UnregisterTenantsAsync(params IWorkflowTenant[] tenants)

Removes tenant instances from newly created snapshots. If a tenant is unknown, the call is a no-op. Registry-owned tenants are shut down only after old snapshots that still reference them are disposed.

Parameters

NameTypeDescription
tenantsIEnumerable<IWorkflowTenant> or IWorkflowTenant[]Tenants to unregister.

GetSnapshot()

Gets an immutable point-in-time tenant snapshot. The caller must dispose it when it is no longer needed.

Returns

TypeDescription
IWorkflowTenantSnapshotA disposable immutable tenant view.

IWorkflowTenantRegistryLifecycle

Controls the host-owned lifecycle of the workflow tenant registry. The default core services register a hosted service that calls this lifecycle during ASP.NET application startup and shutdown.

StartAsync(IEnumerable<WorkflowTenantCreationOptions> options, CancellationToken cancellationToken = default)

Starts the tenant registry and registers static tenants from the provided creation options.

Parameters

NameTypeDescription
optionsIEnumerable<WorkflowTenantCreationOptions>Static tenant creation options.
cancellationTokenCancellationTokenThe cancellation token for startup.

StopAsync(CancellationToken cancellationToken)

Stops the tenant registry and gracefully shuts down registry-owned tenants.

Parameters

NameTypeDescription
cancellationTokenCancellationTokenThe cancellation token for shutdown.

IWorkflowTenantSnapshot

Immutable point-in-time view of registered workflow tenants. ASP.NET request scopes receive an IWorkflowTenantSnapshot automatically, so all Workflow API operations in the same request use the same tenant set.

Tenants

Returns

TypeDescription
IReadOnlyCollection<IWorkflowTenant>All tenant instances in the snapshot.

TenantIds

Returns

TypeDescription
IReadOnlyCollection<string>All tenant ids in the snapshot.

IsSingleTenant

Returns

TypeDescription
booltrue when the snapshot contains the reserved single-tenant setup.

GetTenant(string id)

Gets a workflow tenant by any registered tenant id.

Parameters

NameTypeDescription
idstringThe workflow tenant id.

Returns

TypeDescription
IWorkflowTenantThe workflow tenant instance.

IWorkflowTenantLocator

HTTP-specific service for resolving the current tenant from the request-scoped snapshot and WorkflowApiConstants.TenantIdHeader.

GetHttpContextWorkflowTenantSnapshot()

Gets the tenant snapshot from the current HTTP request scope.

Returns

TypeDescription
IWorkflowTenantSnapshotThe current request snapshot.

GetHttpContextWorkflowTenantId()

Gets the workflow tenant id from the current HTTP context based on the provided header or default tenant id.

Returns

TypeDescription
stringThe workflow tenant id.

GetHttpContextWorkflowTenant()

Gets the workflow tenant instance from the current HTTP context.

Returns

TypeDescription
IWorkflowTenantThe workflow tenant instance.

GetHttpContextWorkflowRuntime()

Get the workflow runtime instance for the workflow tenant identified in the current HTTP context.

Returns

TypeDescription
WorkflowRuntimeThe workflow runtime instance.

IWorkflowTenant

Defines a workflow tenant in a Workflow Engine Web API. In a single-tenant setup registered as a single instance with WorkflowApiConstants.SingleTenantId as its only id.

info

Has a default implementation WorkflowTenant.

Ids

Returns

TypeDescription
IReadOnlyCollection<string>All logical tenant ids that map to this tenant instance.

Runtime

Returns

TypeDescription
WorkflowRuntimeThe workflow runtime instance for this tenant.

DataProvider

Returns

TypeDescription
IDataProviderThe data provider for this tenant.

LifecycleOwnership

Controls whether the tenant lifecycle is managed by the registry or by external code.

Returns

TypeDescription
WorkflowTenantLifecycleOwnershipThe lifecycle ownership mode.

StartAsync()

Starts the tenant before it is published in the registry. The default WorkflowTenant starts its WorkflowRuntime unless DisableRuntimeAutoStart is enabled or the runtime is already running.

ShutdownAsync()

Gracefully shuts down the tenant after it is removed from the registry and is no longer used by any active snapshot.

WorkflowTenantLifecycleOwnership

ValueDescription
RegistryThe tenant registry calls StartAsync() and ShutdownAsync() for the tenant.
ExternalThe host application owns the tenant lifecycle. The registry only publishes and removes the tenant.

IWorkflowTenantFactory

Factory interface for creating IWorkflowTenant instances.

Create(WorkflowTenantCreationOptions options)

Creates a new IWorkflowTenant instance based on the provided creation options.

Parameters

NameTypeDescription
optionsWorkflowTenantCreationOptionsThe options for creating the tenant.

Returns

TypeDescription
IWorkflowTenantA new instance of IWorkflowTenant.

Create(IEnumerable<string> ids, WorkflowRuntime runtime, DataProviderCreationOptions dataProviderOptions, WorkflowTenantLifecycleOwnership lifecycleOwnership = WorkflowTenantLifecycleOwnership.Registry)

Creates a new IWorkflowTenant instance with the specified IDs, workflow runtime, data provider options, and lifecycle ownership.

Parameters

NameTypeDescription
idsIEnumerable<string>The logical tenant IDs that map to this tenant instance.
runtimeWorkflowRuntimeThe workflow runtime instance for this tenant.
dataProviderOptionsDataProviderCreationOptionsThe options for creating the data provider.
lifecycleOwnershipWorkflowTenantLifecycleOwnershipThe lifecycle owner for the tenant.

Returns

TypeDescription
IWorkflowTenantA new instance of IWorkflowTenant.
🔑 Get Trial Key

Alternatively, you can use an AI agent (Claude, Codex, GitHub Copilot, Cursor, or similar) to generate a trial key automatically. Provide the agent with the contents of trial.workflowengine.io/llms.txt and follow the instructions.

Stay in the know
Build Workflow Applications Faster
Star us on GitHub