⚒️ Create dynamic API Gateway with HTTP Router and workflow orchestration

394 views · ⚒️ Engineering

Description

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

  1. Webhook Receiver – A single URL accepts requests.
  2. Method Detection – Branches capture the request method.
  3. Route Resolver – Matches the action parameter and method against your route configuration.
  4. Execute Subflow – If valid, the matching workflow is executed.
  5. 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 other words:

This makes action both the mapping key in the configuration and the control key for triggering the correct logic.

Setup steps

  1. Import the workflow into n8n.
  2. Define your routes in the Routes Config node. Each route contains:
    • action name
    • allowed HTTP methods
    • target subflow ID

This workflow is useful if you want to:


👉 A practical solution to turn n8n into a flexible and maintainable API gateway.

🔗 Nodes Used

Webhook, Execute Sub-workflow

📥 Import

Download workflow.json and import into n8n: Workflow menu → Import from File

📖 Importing guide · 🔑 Credential setup