Run flows via API
Last updated
Last updated
You can execute every flow using API, and the structure of requests stays the same regardless of a particular flow internals.
There are basically two requests: one to initiate the flow execution and another one to get results. And to perform any requests you need to obtain a secret key
Go to API keys section and click the New Server Key button
Pick some comprehensive name for your key, and after the key is generated, make sure you save it somewhere in a safe place, because the key is shown only once and can be retrieved later
Pick the workflow that you want to run. Go to flow builder and proceed to the Publish button
If you have one Start Node and one End Node form in your workflow, and have already obtained the key, you are all set. You'll get code snippets which you can use right away — just don't forget to replace placeholders with your data.
Here's a breakdown of out example
https://api.scade.pro/api/v1/scade/flow/<flow_id>/execute
— URL to send your request to. You can get flow_id
from the address bar of your browser
"start_node_id": "SYnn-start"
— the node that should be run first
"end_node_id": "y5iI-end"
— the node that should be run last
"result_node_id": "y5iI-end"
— the node from which results will be extracted; in most cases its id
is the same as the end_node_id
— it's a place to put your data into. Replace placeholders like {STRING}
with your actual data (say, URLs of a video and an image in this case)
--header 'Authorization: Basic {ACCESS_TOKEN}'
— replace {ACCESS_TOKEN}
with your key. See Get the key section if needed
It’s strongly recommended to have one Start Node and one End Node. But sometimes flows have more than one of each. In this case you'll have to go to the Overview on the left sidebar menu and from the dropdowns choose which node should be run first and which one should be run last upon your flow execution.
Aside from that, the drill of request formation is the same.
Once you get your request formed, send it using the POST
method. If everything is correct, the response would be like this:
We need to take "id"
from the response to get the result
It's pretty straightforward. Here's the url:
https://api.scade.pro/api/v1/task/<task_id>
Replace <task_id>
with the id
that you get upon the flow execution and send a GET
request. Once the flow ends execution, you'll get the result.
It may take some time, so send requests with intervals between them, and look for the result
object in the response