Scade knowledge base
  • What is Scade?
  • Quick start
    • How to create a flow
  • Build a flow
    • What is Flow?
    • How to create a flow
    • What is a Node
    • What are the Start and End Nodes?
    • How to add nodes (AIs and tools) to your flow
    • Top Nodes settings
      • Large language models
      • Image generation
      • Transcribe audio to text (Whisper)
      • Image background removal options
    • How to Connect Nodes
    • How to Use Expression Editor
    • How to Copy Generated Images or Text
    • What is the 'View Source' of a Node
    • How to add python code
  • Flow examples
    • Building a flow: create promo cards of a product
    • Building a flow: a virtual AI editorial office
    • Building a flow: video transcription and summarization
    • 5 minute challenge: compare different LLMs
    • 5 minute challenge: upscale and colorize photos
    • 5 minute challenge: summarize audio
  • Publish
    • Run flows via API
  • Pricing and credits
Powered by GitBook
On this page
  • Get the key
  • Execute the flow
  • Form the request
  • Retrieve task_id
  • Get the result
  1. Publish

Run flows via API

PreviousPublishNextPricing and credits

Last updated 3 months ago

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

Get the key

Go to the section, click the Add new button and pick the Server Key option

Choose 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

Execute the flow

Pick the workflow that you want to run. Go to Workflow builder and proceed to the Publish button

Form the request

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

curl --location 'https://api.scade.pro/api/v1/scade/flow/1607/execute' \
  --header 'Authorization: Basic {ACCESS_TOKEN}' \
  --header 'Content-Type: application/json' \
  --data '{
      "start_node_id": "SYnn-start",
      "end_node_id": "y5iI-end",
      "result_node_id": "y5iI-end",
      "node_settings": {
        "SYnn-start": {
          "data": {
            "source": {STRING},
            "target": {STRING}
          }
        }
      }
  }'

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

      "node_settings": {
        "SYnn-start": {
          "data": {
            "source": {STRING},
            "target": {STRING}
          }
        }
      }

— 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

Picking other nodes

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.

Retrieve task_id

Once you get your request formed, send it using the POST method. If everything is correct, the response would be like this:

{
  "id": 22311,
  "data": {
    "node_id": null,
    "start_node_id": "SYnn-start",
    "end_node_id": "y5iI-end",
    "result_node_id": "y5iI-end",
    "init_context": {},
    "node_settings": {
      "SYnn-start": {
        "data": {
          "source": "https://example.com/video.mp4",
          "target": "https://example.com/image.jpg",
        }
      }
    }
  },
  "status": 2,
  "created": "2024-04-18T21:14:34.800001",
  "finished": null,
  "result": null,
  "execution_time": null,
  "execution_cost": null,
  "parent_id": null,
  "ref_id": "flow:1607;",
  "task_type": 4,
  "is_hide": false,
  "public_access_token": null,
  "file_result_link": null
}

We need to take "id" from the response to get the result

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

API & credentials