Upload Workflow JSON API

Upload workflow JSON definition programatically

You can Download Workflow JSON in the workflow builder.

Download workflow JSON in the workflow builder

You can edit the JSON programmatically and re-upload it with to following API route. Note: it is best practice to edit an existing workflow structure to preserve node layout and positioning.

You can optional upload to a new workflow, or update an existing workflow by including workflow_id in the post data.

import json
import requests
import json
import os
from pathlib import Path

with open("YourJson.json", "r") as f:
    workflow_json = json.load(f)

workflow_json_str = json.dumps(workflow_json)

url = f"{API_BASE_URL}/workflows/upload"
headers = {"Authorization": f"Bearer {API_KEY}"}

# Create files dictionary with the JSON content
files = {
    'workflow_file': ('YourJson.json', workflow_json_str.encode('utf-8'), 'application/json')
}

# Make the request
response = requests.post(
    url,
    headers=headers,
    files=files,
)

# # optionally include workflow_id to update an existing workflow
# # data = {
# #     "workflow_id" : "THE_WORKFLOW_ID"
# # }

# # # Make the request
# # response = requests.post(
# #     url,
# #     data,
# #     headers=headers,
# #     files=files,
# # )

# Print the results
print(f"Status code: {response.status_code}")
print(f"Response: {response.json() if response.status_code == 200 else response.text}")

Last updated