# Flows api to create flow programmatically

**URL:** <https://discourse.nodered.org/t/flows-api-to-create-flow-programmatically/93531>\
**Category:** General\
**Tags:** api\
**Created:** [28 November 2024 04:18 UTC](https://discourse.nodered.org/t/flows-api-to-create-flow-programmatically/93531 "2024-11-28T04:18:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pratham](https://avatars.discourse-cdn.com/v4/letter/p/da6949/32.png) [@Pratham](https://discourse.nodered.org/u/Pratham)\
**Post date:** [28 November 2024 04:18 UTC](https://discourse.nodered.org/t/flows-api-to-create-flow-programmatically/93531/1 "2024-11-28T04:18:00Z")

</div>

Hi, i am trying to create flows using [http://localhost:1880/flows](http://localhost:1880/flows)  
It seems to create the flow but every time I hit the endpoint to create new flows it clears the previous and creates the only new one and again i have to go to UI and click on deploy to run the flow which i want to avoid if i want to do it programmatically.

dummy body for the end point

```auto
{
    "rev": "a7cb1300ba1f3bd025e33c912cefec34977f66e585be9976397f43477232f46f",
    "flows": [
    {
        "id": "111111111111111111111111",
        "type": "http in",
        "name": "HTTP In - Start Flow",
        "url": "/tesrtu",
        "method": "post",
        "x": 200,
        "y": 100,
        "wires": [["sum_node1"]]
    },
    {
        "id": "sum_node1",
        "type": "function",
        "name": "Sum Node 1",
        "func": "let sum1 = msg.payload.sensor1.reduce((total, value) => total + value, 0);\nmsg.payload.sum1 = sum1;\nreturn msg;",
        "x": 400,
        "y": 100,
        "wires": [["sum_node2"]]
    },
    {
        "id": "sum_node2",
        "type": "function",
        "name": "Sum Node 2",
        "func": "let sum2 = msg.payload.sensor2.reduce((total, value) => total + value, 0);\nmsg.payload.sum2 = sum2;\nreturn msg;",
        "x": 600,
        "y": 100,
        "wires": [["difference_node"]]
    },
    {
        "id": "difference_node",
        "type": "function",
        "name": "Difference Node",
        "func": "let difference = msg.payload.sum1 - msg.payload.sum2;\nmsg.payload = difference;\nreturn msg;",
        "x": 800,
        "y": 100,
        "wires": [["http_response_node"]]
    },
    {
        "id": "http_response_node",
        "type": "http response",
        "name": "HTTP Response",
        "x": 1000,
        "y": 100,
        "wires": []
    }
]
}

```

Can anyone help me with this ?

thanks in advance.

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [28 November 2024 08:48 UTC](https://discourse.nodered.org/t/flows-api-to-create-flow-programmatically/93531/2 "2024-11-28T08:48:17Z")

</div>

Check the [api documentation](https://nodered.org/docs/api/admin/methods/) - there are a number of possibilities. In particular you might want to use [/flow](https://nodered.org/docs/api/admin/methods/post/flow/) instead.

---

<div class="post-metadata">

**Author:** ![Pratham](https://avatars.discourse-cdn.com/v4/letter/p/da6949/32.png) [@Pratham](https://discourse.nodered.org/u/Pratham)\
**Post date:** [29 November 2024 07:15 UTC](https://discourse.nodered.org/t/flows-api-to-create-flow-programmatically/93531/3 "2024-11-29T07:15:54Z")

</div>

thanks.  
/flow works

---

<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:** [27 February 2025 07:16 UTC](https://discourse.nodered.org/t/flows-api-to-create-flow-programmatically/93531/4 "2025-02-27T07:16:51Z")

</div>

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