Create dynamic API Gateway with HTTP Router and workflow orchestration
$20/month : Unlimited workflows
2500 executions/month
THE #1 IN WEB SCRAPING
Scrape any website without limits
HOSTINGER 🎉 Early Black Friday Deal
DISCOUNT 20% Try free
DISCOUNT 20%
Self-hosted n8n
Unlimited workflows - from $4.99/mo
#1 hub for scraping, AI & automation
6000+ actors - $5 credits/mo
Overview
This workflow provides a universal webhook endpoint that dynamically routes incoming requests to different subflows. It allows you to manage multiple API-like endpoints from a single entry point, while ensuring proper error handling and consistent responses.
How it works
- Webhook Receiver – A single URL accepts requests.
- Method Detection – Branches capture the request method.
- Route Resolver – Matches the
actionparameter and method against your route configuration. - Execute Subflow – If valid, the matching workflow is executed.
- Error Handling – If invalid, the workflow responds with a clear status code and JSON error.
About the action parameter
The action query parameter is the key that controls routing:
- In your Routes Config, every route is defined with an
actionname, a list of allowed HTTP methods, and the target subflow ID. - When a request comes in, the workflow looks up the provided
actionin this config. - If the action is valid and the method is allowed, the corresponding subflow is executed.
- If not, the workflow returns a structured error.
In other words:
- Config side → map
action→ subflow ID - Request side → send
?action=...→ determines which subflow runs
This makes action both the mapping key in the configuration and the control key for triggering the correct logic.
Setup steps
- Import the workflow into n8n.
- Define your routes in the Routes Config node. Each route contains:
actionname- allowed HTTP methods
- target subflow ID
This workflow is useful if you want to:
- Expose multiple clean API endpoints without creating many Webhook nodes
- Ensure consistent error handling across all endpoints
- Keep your n8n setup more structured and maintainable
👉 A practical solution to turn n8n into a flexible and maintainable API gateway.