Middleware enables additional control of your logic at pivotal points of execution. They are separate pieces of logic that can run before the logic executes (before input validation) or after the logic executes (after the response is generated, but before it is delivered). Middleware can be applied to:Documentation Index
Fetch the complete documentation index at: https://docs.xano.com/llms.txt
Use this file to discover all available pages before exploring further.
- APIs
- Custom Functions
- Background Tasks
- AI Tools
- Pre-middleware that runs before input validation
- Post-middleware that runs after the logic executes and a response is generated, but before it is delivered
| Response Type | Description |
|---|---|
merge | Merges the response of the middleware with the existing response. If the middleware response contains a key that already exists in the generated response, it will be overwritten. |
replace | Replaces the existing response entirely with the new response |
| Exception Method | Description |
|---|---|
critical | Stops execution completely and returns an error |
silent | Silently ignores errors |
rethrow | When paired with post-middleware, it allows the post-middleware to run even when an error occurs in the pre-middleware. Good for error logging or monitoring. |
vars- The variables from the parent object. This could be either the inputs sent to the workflow for a pre-middleware, or the response generated by the parent object for a post-middleware.type- The type of middleware (pre or post).
Building Middleware in Xano
- Visually
- XanoScript
Applying Middleware to Workflows
Middleware can be applied at the workspace level, workflow group level (like API groups), or onto individual workflows. If no customizations are set on a workflow, it will inherit middleware settings from their parent object, such as the group they reside in or the workspace. You can quickly disable middleware by clicking the toggle and remove it completely from the object by clicking the .Workspace level
From your Dashboard, click⚙️ and choose Middleware from the menu.


Applying middleware to a workflow group
From an API group, click and select Middleware.

Applying middleware to an individual workflow
From the workflow, click and select Middleware.

