Api for subflows


I'm trying to manage nodered with admin api endpoints.

If I want to import an existing flow (not all flows but only some selected ones) from another nodered instance :

  • I do a http get from the source nodered server to get the selected flow with /flow/:id endpoint,
  • then I http post the result to the destination nodered server using the /flow endpoint

This works fine while no subflow is used in the exported/imported flow, since the get /flow/:id doesn't return the definition of subflow. So what should we do if we need to import a flow with a subflow in it ?

I saw the possibility to use the /flow/global endpoint to get all subflows, but seems no further detail endpoinds are provided which allow us to manager subflow (crud).

Thanks a lot for advice

You are right there are no endpoints for subflows. This is something I'd like to rectify eventually.

For now, you have to first add the definition to the global flow.

Hi @knolleary, thanks a lot for your reply.
I would just like to ask some further details on how to add or update subflows with /flow/global.

When we do a get with /flow/global, all configurations and subflows are returned.
Since there is no endpoint for managing each individual config or subflow, does that mean, each time, when we need to add or update only one subflow, we always need to put all existing config/subflow in the body ?


HI @jacyuan

Correct - there is no api for modifying individual subflows or nodes. The model has always been to manage things at the flow level.

So to update a subflow you have to get the /global flow config, modify the subflow and then post it back. I fully acknowledge that is not ideal - and as I said, something I want to fix. But as with everything, short of someone else stepping in to help improve it (even proposing a design for a better API would be a starting point), it sits on the backlog waiting for me to have the time to look at it.


Thanks again! :+1: