- 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
Open the Middleware library
Click Add Middleware
- Visually
- XanoScript
Provide some basic information

Providing basic information for Middleware
Build the middleware logic
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.
Accessing the Middleware menu on your workspace

Select the workflow type you want to apply the middleware to.

Select the appropriate option to apply either pre or post middleware.
Applying middleware to a workflow group

Accessing the Middleware menu on an API group

Check the Customize box next to the type of middleware you want to apply to that API group. You'll see the Add buttons appear once you do.
Applying middleware to an individual workflow
From the workflow, click and select Middleware.
Accessing the Middleware menu on a workflow

Check the Customize box next to the type of middleware you want to apply to that workflow. You'll see the Add buttons appear once you do.