Skip to main content

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

Workflow Engine Web API

The Workflow Engine Web API is an ASP.NET library that enables seamless integration of the Workflow Engine into your web applications. It is quick to set up and lets you host a ready-to-use API service with minimal additional development. This makes it easy to plug the product into a microservice architecture or build a custom frontend client on top of the API.

Key Features

  1. RPC API: Remotely manage Workflow Engine Runtime instances in single-tenant or multi-tenant modes. Learn more.
  2. RESTful Data API: Interact safely with the Workflow Engine database without disrupting internal processes. Learn more.
  3. Granular authorization: Control access to each API endpoint and issue claims for your identities. Learn more.
  4. Multitenancy: Operate multiple Workflow Runtime instances and databases from a single web service. Learn more.
  5. OpenAPI (Swagger): Generate and host an OpenAPI specification for your API automatically. Learn more.
  6. ASP.NET-friendly: Built with standard ASP.NET patterns for straightforward integration. Learn more.

Quick Start

You can configure the Web API as a service in three steps.

1. Create a new ASP.NET project:

dotnet new webapi -n WorkflowApi --framework net8.0
cd WorkflowApi

Requires the .NET SDK 8.0.

2. Install the required Workflow API packages:

dotnet add package OptimaJet.Workflow.Api
dotnet add package OptimaJet.Workflow.Api.Sqlite

3. Configure Program.cs (copy and paste):

using System.Text.Json.Serialization;
using Microsoft.AspNetCore.Mvc;
using OptimaJet.Workflow.Api;
using OptimaJet.Workflow.Api.Options;
using OptimaJet.Workflow.Api.Sqlite;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.

// Configure JSON options for enum serialization.
builder.Services.AddControllers().AddJsonOptions(ConfigureJson);

// Configure Workflow API services.
builder.Services.AddWorkflowApiSqlite();
builder.Services.AddWorkflowApiCore(SetupWorkflowApiCore);
builder.Services.AddWorkflowRuntime(SetupWorkflowRuntime);

// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

var app = builder.Build();

// Configure the HTTP request pipeline.

// Enable middleware to serve generated OpenAPI as a JSON endpoint and the Swagger UI.
app.UseSwagger();
app.UseSwaggerUI();

// Configure routing and map the Workflow API endpoints.
app.UseRouting();
app.MapWorkflowApi();

app.Run();


void ConfigureJson(JsonOptions options)
{
options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
}

void SetupWorkflowApiCore(WorkflowApiCoreOptions options)
{
options.LicenseKey = "V2-TRIAL-VFJJQUw6MDguMjAuMjAyNTpleUpTWlhOMGNtbGpkR2x2Ym5NaU9uc2lVM1J5YVdOMFEyaGxZMnNpT" +
"21aaGJITmxMQ0pOWVhoT2RXMWlaWEpQWmtGamRHbDJhWFJwWlhNaU9qRXdMQ0pOWVhoT2RXMWlaWEpQWmxSeVl" +
"XNXphWFJwYjI1eklqb3hNQ3dpVFdGNFRuVnRZbVZ5VDJaRGIyMXRZVzVrY3lJNk5Td2lUV0Y0VG5WdFltVnlUM" +
"lpUWTJobGJXVnpJam94TENKTllYaE9kVzFpWlhKUFpsUm9jbVZoWkhNaU9qRXNJa0ZqZEdsMlpVUnBjbVZqZEc" +
"5eWVTSTZabUZzYzJVc0lrSnlZVzVrYVc1bklqb2lRbkpoYm1ScGJtY2lMQ0pYYjNKclpteHZkMFZ1WjJsdVpVR" +
"ndhU0k2SW5SeWRXVWlmU3dpUTNWemRHOXRVbVZ6ZEhKcFkzUnBiMjRpT25SeWRXVjk6bE1iTHBleFplMXk3ZEw" +
"5NHVLNm1EZWpkbzVOalZPd1JZZjIvbUZIZmlCb1RiMjdUWFBvQ1gyN1NFeWNiMm1SLzNSckhkWUlWMy9zaG1VW" +
"TgvRjZVQk5iQlhMK0lFYmFIYVJ0YVNiVDlldmI1ZWVYaEF4a1RmNmdCVVpiWHBwR3JuY09wNEJIV2dPR2RZZXJ" +
"STFNxc0Y3RlRxbGE3Z3RwbkpHTy9IdWJHZWlzPQ==";
}

void SetupWorkflowRuntime(WorkflowTenantCreationOptions options)
{
// Configure database connection string and Workflow Runtime.
options.ConnectionString = "Data Source=workflow_engine.db";
options.WorkflowRuntimeCreationOptions.ConfigureWorkflowRuntime = runtime =>
{
runtime.AsSingleServer();
};
}

All set. You can now run the application:

dotnet run

Open the Swagger UI at http://localhost:5000/swagger to explore and test the API endpoints.

For detailed instructions and additional configuration options, see the core services documentation.

GitHub Sample

For a more comprehensive project setup and code examples, explore the Sample project in the public GitHub repository. It demonstrates all Workflow API packages and shows an advanced ASP.NET application structure, including a JWT-based security example, API client generation and integration tests.

OpenAPI Specification

The Workflow Engine Web API supports OpenAPI generation using standard ASP.NET tooling. When you create a project from the Quick Start template, the OpenAPI documentation is generated automatically and is available by default at the /swagger page.

If you haven’t created your own API service yet, you can review the specification in our documentation, or download pre-generated files: JSON and YAML.

Packages

To work with the Workflow API, you need to add two packages: the main package OptimaJet.Workflow.Api and a database provider package that you prefer. Below is the list of available packages.

All packages are compatible with .NET 8.0.

Package IDDescription
OptimaJet.Workflow.ApiMain library containing API endpoints and security.
OptimaJet.Workflow.Api.SqlImplementation for SQL providers.
OptimaJet.Workflow.Api.MssqlProvider for MS SQL Server or Azure SQL.
OptimaJet.Workflow.Api.MysqlProvider for MySQL.
OptimaJet.Workflow.Api.OracleProvider for Oracle.
OptimaJet.Workflow.Api.PostgresProvider for PostgreSQL.
OptimaJet.Workflow.Api.SqliteProvider for SQLite.
OptimaJet.Workflow.Api.MongoProvider for MongoDB or Azure Cosmos DB.