Skip to main content

Create dynamic API Gateway with HTTP Router and workflow orchestration

Workflow preview

Workflow preview
100%
Create dynamic API Gateway with HTTP Router and workflow orchestration preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow 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, w...

Best for

  • Engineering automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.set, n8n-nodes-base.executeworkflow, n8n-nodes-base.respondtowebhook, n8n-nodes-base.if, n8n-nodes-base.webhook, n8n-nodes-base.stickynote, n8n-nodes-base.code

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Sven Rösser.

Original n8n.io source

1.1 Workflow description

Title
Create dynamic API Gateway with HTTP Router and workflow orchestration
Workflow name
Create dynamic API Gateway with HTTP Router and workflow orchestration

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 your Routes Config, every route is defined with an action name, a list of allowed HTTP methods, and the target subflow ID.
  • When a request comes in, the workflow looks up the provided action in 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

  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:

  • 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.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - HEAD

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 2 - Execute Workflow

Type / Role
n8n-nodes-base.executeWorkflow - executeWorkflow
Config choices
Version 1.3

Block 3 - Success

Type / Role
n8n-nodes-base.respondToWebhook - respondToWebhook
Config choices
Version 1.4

Block 4 - Aggregate Method Branches

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 5 - PUT

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 6 - PATCH

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 7 - DELETE

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 8 - POST

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 9 - GET

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 10 - Routes Config

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 11 - Query param exists?

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 12 - Universal Receiver

Type / Role
n8n-nodes-base.webhook - webhook
Config choices
Version 2.1

Block 13 - Sticky: Method detection

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 14 - Sticky: Routes config

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 15 - Sticky: Resolver

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 16 - Sticky: Execute & respond

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 17 - [Error] Required query param missing

Type / Role
n8n-nodes-base.respondToWebhook - respondToWebhook
Config choices
Version 1.4

Block 18 - Resolve

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 19 - Route is OK?

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 20 - Status = 405?

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 21 - [Error] Method Not Allowed

Type / Role
n8n-nodes-base.respondToWebhook - respondToWebhook
Config choices
Version 1

Block 22 - Error - Not OK

Type / Role
n8n-nodes-base.respondToWebhook - respondToWebhook
Config choices
Version 1

Block 23 - Error - Subflow

Type / Role
n8n-nodes-base.respondToWebhook - respondToWebhook
Config choices
Version 1

Block 24 - Sticky: Method detection1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

3. Summary Table

Workflow Create dynamic API Gateway with HTTP Router and workflow orchestration
Complexity advanced
Nodes 24
Categories Engineering
Author Sven Rösser
Published 01 Oct 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/9165/9165.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Create dynamic API Gateway with HTTP Router and workflow orchestration do?

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, w...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Engineering use case.