Upload Workflow JSON API
Upload workflow JSON definition programatically

Last updated
Upload workflow JSON definition programatically

Last updated
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}")