# How to Intercept HTTP Requests for Dynamic Sub-Flow Loading in Node-RED for Multi-Tenancy?

**URL:** <https://discourse.nodered.org/t/how-to-intercept-http-requests-for-dynamic-sub-flow-loading-in-node-red-for-multi-tenancy/93281>\
**Category:** General\
**Created:** [20 November 2024 06:25 UTC](https://discourse.nodered.org/t/how-to-intercept-http-requests-for-dynamic-sub-flow-loading-in-node-red-for-multi-tenancy/93281 "2024-11-20T06:25:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vidit.khemka](https://avatars.discourse-cdn.com/v4/letter/v/e5b9ba/32.png) [@vidit.khemka](https://discourse.nodered.org/u/vidit.khemka)\
**Post date:** [20 November 2024 06:25 UTC](https://discourse.nodered.org/t/how-to-intercept-http-requests-for-dynamic-sub-flow-loading-in-node-red-for-multi-tenancy/93281/1 "2024-11-20T06:25:09Z")

</div>

Hello Node-RED community,

I have a question regarding implementing multi-tenancy in Node-RED. In my current setup, I have different sub-flows dedicated to separate tenants. These sub-flows handle specific processes, such as placing orders to platforms like Amazon, with each tenant having unique requirements.

For example:

- **Tenant 1** : "Bob Tenant"
- **Tenant 2** : "Sam Tenant"

Currently, I route the main flow to the appropriate sub-flow using a switch node, based on the `tenantId` received from a request. While this approach works well for a few tenants, I’m concerned about scalability as the number of tenants potentially grows to 1,000 or more. Loading all sub-flows at once is not efficient or practical.

To address this, I’m looking for a way to intercept Node-RED HTTP-based requests that trigger the deployed flows, allowing me to dynamically load and execute only the desired sub-flow at runtime based on the `tenantId`. This would help optimize performance and manage resources more effectively as the number of tenants scales up.

Is there a recommended approach or any advice on how to intercept these HTTP requests and dynamically load sub-flows at runtime in Node-RED? Your suggestions or insights would be greatly appreciated!

Thank you in advance for your help!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [18 February 2025 06:25 UTC](https://discourse.nodered.org/t/how-to-intercept-http-requests-for-dynamic-sub-flow-loading-in-node-red-for-multi-tenancy/93281/2 "2025-02-18T06:25:31Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
