Homey Community Forum

Create flow over API

Hi!
I’m a new Homey user but started looking into using the API right away since I want to create a large number of flows programmatically. I am however not a developer so I have some trouble understanding the API documentation and how to map them to endpoints.
I’m trying to create a flow over the API and have successfully done in the sandbox. The problem is that the sandbox does not give me the raw HTTP request and hence I am not entirely sure of to what endpoint I should send my request.
My code is written in python and I’ve been able to GET all devices and flows but bump into 404’s as soon as I try to use the createFlow function.
Have anyone been able to create a flow over the API? If so, could you share the raw HTTP request?

It is absolutely possible to create flows but all flows must be valid with fe devices and a trigger. (In Homey fw 1.x it was not verified)
But I guess your authorization is the issue.
What did you use for authentication?
Have you tried the web playground on the developers page?
Maybe look into the community backup and restore i created.

Hi and thanks for your reply!
The authentication is not the problem. I’ve autenticated successfully using the bearer token in the v2 format as described in this post.
I am simply not sure where to send my (I suppose) PUT request, to what endpoint. So i can for example perform a GET request to get a list of all the devices here:

http://<HOMEY_IP>/api/manager/devices/device/
and get a list of all flows here:
http://<HOMEY_IP>/api/manager/flow/flow/.
This is straightforward. But I am not sure how to craft a createFlow action over pure HTTP since http://<HOMEY_IP>/api/manager/flow/createFlow/ for example gives me a 404. When I found out how to do so, I’ll just make a copy of my current flows to ensure I have all the triggers etc in place before starting to substitute parts and make it more dynamic.

Yes, I have successfully created flows using the playground.

Oh, and happy birthday @Dijker! :slight_smile:

Thanks!
I don’t know the http request as I use the js webapi, but look at restoring a flow from the backup fe after removing the original flow. It should be possible to see it in the chrome console.

Congrats Dijker!

@homeyuser have a look at the flow viewer @Erik made: https://github.com/irritanterik/homey-realtime-logpage/blob/master/flowview.html
Think you can find a lot of API endpoints in it (Not sure if adding is one of it though)

You can find some more information about it here:
[HOW TO] View your Homey v2 flows in a browser
(This was posted after Homey V2 was released and Athom still believed in the Mobile only strategy, it’s superseded now by flow.homey.app)

btw, I think you’d want to use POST to create.