# Interface IOperationBuilder OptimaJet.Workflow.Api.Configuration.IOperationBuilder Registers callbacks for one operation in one application. Namespace: [OptimaJet.Workflow.Api.Configuration](https://api.workflowengine.io/web-api/OptimaJet.Workflow.Api.Configuration/) ```csharp public interface IOperationBuilder ``` ## Methods ### `IOperationBuilder OnBefore(Func, ValueTask> callback)` Adds input preparation. Null continues; a result skips the remaining before/authorization callbacks and handler, then runs OnAfter. ### Parameters | Name | Type | Description | | --- | --- | --- | | `callback` | `Func, IResult>` | The preparation callback. | ### Returns | Type | Description | | --- | --- | | `IOperationBuilder` | This builder. | ### Remarks Only this stage permits ReplaceInput. ASP.NET policies and HTTP binding run before the callback. ### `IOperationBuilder OnAuthorize(Func, ValueTask> callback)` Adds authorization over the final input. The first false returns 403 and skips the remaining authorization callbacks and handler. ### Parameters | Name | Type | Description | | --- | --- | --- | | `callback` | `Func, Boolean>` | The authorization callback. | ### Returns | Type | Description | | --- | --- | | `IOperationBuilder` | This builder. | ### Remarks Runs even when built-in security is disabled. Do not mutate the input or its nested values in this stage. ### `IOperationBuilder OnAfterSuccess(Func, TSuccess, ValueTask> callback)` Adds a transformation of the original handler's successful (2xx) payload, preserving HTTP result semantics. ### Parameters | Name | Type | Description | | --- | --- | --- | | `callback` | `Func, TSuccess, ValueTask>` | The payload transformation. | ### Returns | Type | Description | | --- | --- | | `IOperationBuilder` | This builder. | ### Remarks Skipped for results without payload (including null values), errors, authorization denials, short circuits and exception fallbacks. An empty response record is a payload. ### `IOperationBuilder OnAfter(Func, IResult, ValueTask> callback)` Adds a transformation of the final result, including handler errors, short circuits, callback denials and exception fallbacks. ### Parameters | Name | Type | Description | | --- | --- | --- | | `callback` | `Func, IResult, IResult>` | The result transformation, which must return a non-null result. | ### Returns | Type | Description | | --- | --- | | `IOperationBuilder` | This builder. | ### Remarks Runs before result execution and serialization. Responses from external middleware are outside this pipeline. ### `IOperationBuilder OnException(Func, Exception, ValueTask> callback)` Adds exception recovery. Null passes the original exception to the next callback; the first result handles it. ### Parameters | Name | Type | Description | | --- | --- | --- | | `callback` | `Func, Exception, IResult>` | The exception recovery callback. | ### Returns | Type | Description | | --- | --- | | `IOperationBuilder` | This builder. | ### Remarks Covers callbacks and the handler, but not binding, result execution, serialization or an already-started response. Unhandled exceptions preserve their stack trace. Request cancellation bypasses recovery, and process/tenant guards convert protected failures to 404 first, including failures inside recovery callbacks. Other recovery failures propagate without recursively invoking the callback chain. A fallback before OnAfter passes through that stage once; a fallback for an OnAfter failure is sent directly. ## Remarks Stages run in fixed order: OnBefore, OnAuthorize, handler, OnAfterSuccess, OnAfter. Within each stage callbacks run in registration order. Resolve scoped dependencies from the callback context. Builders cannot be changed after configuration is fixed; request state is not stored in this builder. [Previous IHubOperationContext](https://api.workflowengine.io/web-api/OptimaJet.Workflow.Api.Configuration/IHubOperationContext/) [Next IOperationContext](https://api.workflowengine.io/web-api/OptimaJet.Workflow.Api.Configuration/IOperationContext/)