Flows api to create flow programmatically

Hi, i am trying to create flows using 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

{
    "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.

Check the api documentation - there are a number of possibilities. In particular you might want to use /flow instead.

1 Like

thanks.
/flow works