Workflow API Documentation
A Workflow in Slate is a flexible, visual representation of a process or automation. It consists of interconnected nodes (steps, triggers, actions, outputs) and edges (connections between nodes), allowing you to design and execute complex logic flows.
Key Concepts
- Workflow: A schema consisting of nodes and edges that defines the sequence of actions.
- Node: A step in the process (e.g., trigger, LLM request, data processing, output).
- Edge: Connects two nodes, defining the direction of the flow.
- Data: The structure describing all nodes, edges, the start node, and viewport parameters.
Workflow Data Structure Example
{
"id": 6,
"project": 307,
"title": "New workflow",
"data": {
"edges": [
{
"id": "xy-edge__3d63f846-0f6a-478c-b91c-5921259429c1-a67fef47-c844-4489-9024-ff894b5d7465",
"type": "custom-edge",
"source": "3d63f846-0f6a-478c-b91c-5921259429c1",
"target": "a67fef47-c844-4489-9024-ff894b5d7465",
"style": \{"stroke": "#76A9FA", "strokeWidth": 2\},
"animated": false,
"markerEnd": "edge-target",
"markerStart": "edge-source"
}
],
"nodes": [
{
"id": "3d63f846-0f6a-478c-b91c-5921259429c1",
"type": "trigger-node",
"data": \{ ... \},
...
},
{
"id": "a67fef47-c844-4489-9024-ff894b5d7465",
"type": "basic-node",
"data": \{ ... \},
...
},
{
"id": "2dfa426d-4233-49f2-8532-4b82f57640b6",
"type": "output-node",
"data": \{ ... \},
...
}
],
"viewport": \{"x": 0.25, "y": 152.25, "zoom": 0.5\},
"start_node": "a67fef47-c844-4489-9024-ff894b5d7465"
}
}
API Endpoints
Create a Workflow
import requests
url = "https://scriptrun.ai/api/v1/workflows/"
headers = \{"X-Api-Key": "<Your API Key>"\}
data = {
"project": 307,
"title": "New workflow",
"data": \{ ... \} # see structure above
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
curl -X POST "https://scriptrun.ai/api/v1/workflows/" \
-H "X-Api-Key: <Your API Key>" \
-H "Content-Type: application/json" \
-d '{
"project": 307,
"title": "New workflow",
"data": \{ ... \}
}'
POST /api/v1/workflows/
Summary: Creates a new workflow.
Request Body:
| Name | Type | Required | Description |
|---|---|---|---|
project | integer | Yes | Project ID to which the workflow belongs. |
title | string | Yes | Name/title of the workflow. |
data | object | Yes | Workflow structure (nodes, edges, viewport) |
Responses:
- 201: Workflow successfully created.
- 400: Invalid input or missing required parameters.
Retrieve Workflows
url = "https://scriptrun.ai/api/v1/workflows/"
headers = \{"X-Api-Key": "<Your API Key>"\}
params = \{"project": 307\}
response = requests.get(url, headers=headers, params=params)
print(response.json())
curl -X GET "https://scriptrun.ai/api/v1/workflows/?project=307" \
-H "X-Api-Key: <Your API Key>"
GET /api/v1/workflows/
Summary: Retrieves a list of workflows, optionally filtered by project.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
project | query | integer | No | Filter workflows by project ID. |
title | query | string | No | Filter by workflow title (case-insensitive). |
page | query | integer | No | Page number for pagination. |
Responses:
- 200: Returns a paginated list of workflows.
Retrieve a Specific Workflow
url = "https://scriptrun.ai/api/v1/workflows/6/"
headers = \{"X-Api-Key": "<Your API Key>"\}
response = requests.get(url, headers=headers)
print(response.json())
curl -X GET "https://scriptrun.ai/api/v1/workflows/6/" \
-H "X-Api-Key: <Your API Key>"
GET /api/v1/workflows/\{id\}/
Summary: Retrieves the details of a specific workflow by its ID.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
id | path | integer | Yes | ID of the workflow to fetch. |
Responses:
- 200: Returns the workflow details.
- 404: Workflow not found.
Update a Workflow
url = "https://scriptrun.ai/api/v1/workflows/6/"
headers = \{"X-Api-Key": "<Your API Key>"\}
data = {
"title": "Updated Workflow Title",
"data": \{ ... \}
}
response = requests.patch(url, headers=headers, json=data)
print(response.json())
curl -X PATCH "https://scriptrun.ai/api/v1/workflows/6/" \
-H "X-Api-Key: <Your API Key>" \
-H "Content-Type: application/json" \
-d '{
"title": "Updated Workflow Title",
"data": \{ ... \}
}'
PATCH /api/v1/workflows/\{id\}/
Summary: Updates an existing workflow.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
id | path | integer | Yes | ID of the workflow to update. |
Request Body:
| Name | Type | Required | Description |
|---|---|---|---|
title | string | No | Updated workflow title. |
data | object | No | Updated workflow structure. |
Responses:
- 200: Workflow successfully updated.
- 404: Workflow not found.
Delete a Workflow
url = "https://scriptrun.ai/api/v1/workflows/6/"
headers = \{"X-Api-Key": "<Your API Key>"\}
response = requests.delete(url, headers=headers)
print(response.status_code)
curl -X DELETE "https://scriptrun.ai/api/v1/workflows/6/" \
-H "X-Api-Key: <Your API Key>"
DELETE /api/v1/workflows/\{id\}/
Summary: Deletes a specific workflow by its ID.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
id | path | integer | Yes | ID of the workflow to delete. |
Responses:
- 204: Workflow successfully deleted.
- 404: Workflow not found.
Additional Workflow Endpoints
Check Workflow Structure
POST /api/v1/workflows/check_workflow/
Summary: Validates the structure of a workflow before saving or running it.
import requests
url = "https://scriptrun.ai/api/v1/workflows/check_workflow/"
headers = \{"X-Api-Key": "<Your API Key>"\}
data = {
"data": {
"nodes": [...],
"edges": [...],
"viewport": \{"x": 0, "y": 0, "zoom": 1\},
"start_node": "node-id-1"
}
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
curl -X POST "https://scriptrun.ai/api/v1/workflows/check_workflow/" \
-H "X-Api-Key: <Your API Key>" \
-H "Content-Type: application/json" \
-d '{
"data": {
"nodes": [...],
"edges": [...],
"viewport": \{"x": 0, "y": 0, "zoom": 1\},
"start_node": "node-id-1"
}
}'
Get Node Schemas for Frontend
GET /api/v1/workflows/get_nodes/
Summary: Retrieves the available node schemas for rendering and configuration in the frontend.
import requests
url = "https://scriptrun.ai/api/v1/workflows/get_nodes/"
headers = \{"X-Api-Key": "<Your API Key>"\}
response = requests.get(url, headers=headers)
print(response.json())
curl -X GET "https://scriptrun.ai/api/v1/workflows/get_nodes/" \
-H "X-Api-Key: <Your API Key>"
Run a Workflow
POST /api/v1/workflows/run/
Summary: Starts the execution of a workflow. Requires a task_id as a query parameter.
import requests
url = "https://scriptrun.ai/api/v1/workflows/run/?task_id=123e4567-e89b-12d3-a456-426614174000"
headers = \{"X-Api-Key": "<Your API Key>"\}
data = {
"data": {
"nodes": [...],
"edges": [...],
"viewport": \{"x": 0, "y": 0, "zoom": 1\},
"start_node": "node-id-1"
}
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
curl -X POST "https://scriptrun.ai/api/v1/workflows/run/?task_id=123e4567-e89b-12d3-a456-426614174000" \
-H "X-Api-Key: <Your API Key>" \
-H "Content-Type: application/json" \
-d '{
"data": {
"nodes": [...],
"edges": [...],
"viewport": \{"x": 0, "y": 0, "zoom": 1\},
"start_node": "node-id-1"
}
}'
Get Workflow Node Result
GET /api/v1/workflows/workflow_result/
Summary: Retrieves the result for a specific node in a workflow run.
import requests
url = "https://scriptrun.ai/api/v1/workflows/workflow_result/?task_id=123e4567-e89b-12d3-a456-426614174000&node_id=a67fef47-c844-4489-9024-ff894b5d7465"
headers = \{"X-Api-Key": "<Your API Key>"\}
response = requests.get(url, headers=headers)
print(response.json())
curl -X GET "https://scriptrun.ai/api/v1/workflows/workflow_result/?task_id=123e4567-e89b-12d3-a456-426614174000&node_id=a67fef47-c844-4489-9024-ff894b5d7465" \
-H "X-Api-Key: <Your API Key>"
Workflow Run History
GET /api/v1/workflows/history/
Summary: Retrieves the history of workflow runs.
import requests
url = "https://scriptrun.ai/api/v1/workflows/history/?workflow_id=6&limit=10"
headers = \{"X-Api-Key": "<Your API Key>"\}
response = requests.get(url, headers=headers)
print(response.json())
curl -X GET "https://scriptrun.ai/api/v1/workflows/history/?workflow_id=6&limit=10" \
-H "X-Api-Key: <Your API Key>"
Workflow Data Structure
- nodes: List of nodes, each containing:
id: Unique node identifier.type: Node type (e.g., "trigger-node", "basic-node", "output-node").data: Node parameters (name, settings, schema, messages, etc.).position,measured,selected, etc. — visualization parameters.
- edges: List of connections between nodes, each containing:
id: Unique edge identifier.source: Source node id.target: Target node id.type,style,markerEnd,markerStart, etc. — visualization parameters.
- viewport: Viewport parameters (x, y, zoom).
- start_node: id of the start node (usually the first action or trigger).
Summary
- A Workflow is a visual process schema consisting of nodes and edges.
- The API allows you to create, retrieve, update, and delete workflows.
- The data structure supports complex scenarios, branching, parameters, and visualization.
- For workflow execution , use the dedicated endpoints.