Skip to main content

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

Python
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())
Shell
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:

NameTypeRequiredDescription
projectintegerYesProject ID to which the workflow belongs.
titlestringYesName/title of the workflow.
dataobjectYesWorkflow structure (nodes, edges, viewport)

Responses:

  • 201: Workflow successfully created.
  • 400: Invalid input or missing required parameters.

Retrieve Workflows

Python
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())
Shell
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:

NameInTypeRequiredDescription
projectqueryintegerNoFilter workflows by project ID.
titlequerystringNoFilter by workflow title (case-insensitive).
pagequeryintegerNoPage number for pagination.

Responses:

  • 200: Returns a paginated list of workflows.

Retrieve a Specific Workflow

Python
url = "https://scriptrun.ai/api/v1/workflows/6/"
headers = \{"X-Api-Key": "<Your API Key>"\}

response = requests.get(url, headers=headers)
print(response.json())
Shell
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:

NameInTypeRequiredDescription
idpathintegerYesID of the workflow to fetch.

Responses:

  • 200: Returns the workflow details.
  • 404: Workflow not found.

Update a Workflow

Python
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())
Shell
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:

NameInTypeRequiredDescription
idpathintegerYesID of the workflow to update.

Request Body:

NameTypeRequiredDescription
titlestringNoUpdated workflow title.
dataobjectNoUpdated workflow structure.

Responses:

  • 200: Workflow successfully updated.
  • 404: Workflow not found.

Delete a Workflow

Python
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)
Shell
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:

NameInTypeRequiredDescription
idpathintegerYesID 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.

Python
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())
Shell
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.

Python
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())
Shell
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.

Python
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())
Shell
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.

Python
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())
Shell
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.

Python
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())
Shell
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.я

Working with Input Data

Overview

When running a workflow, you can pass input_data that will be available in all nodes through variables. This is useful for parameterizing workflows and making them reusable with different inputs.

Key Features:

  • ✅ Supports valid JSON (objects, arrays, primitives)
  • ✅ Supports plain text (will be wrapped automatically)
  • ✅ Access data in nodes using {{ input.field_name }} syntax
  • ✅ Supports nested objects and arrays

POST /api/v1/workflows/{id}/run/

Summary: Runs a workflow with optional input data.

Parameters:

NameInTypeRequiredDescription
idpathintegerYesID of the workflow to run.

Request Body:

NameTypeRequiredDescription
input_dataobject / array / stringNoInput data accessible in nodes via {{ input.* }} variables.

Example 1: Object Input Data

Pass structured data as a JSON object:

Python
import requests

url = "https://scriptrun.ai/api/v1/workflows/6/run/"
headers = {"X-Api-Key": "<Your API Key>"}
data = {
"input_data": {
"user_name": "John Doe",
"email": "[email protected]",
"age": 30,
"preferences": {
"theme": "dark",
"notifications": True
},
"tags": ["admin", "developer"]
}
}

response = requests.post(url, headers=headers, json=data)
print(response.json())
Shell
curl -X POST "https://scriptrun.ai/api/v1/workflows/6/run/" \
-H "X-Api-Key: <Your API Key>" \
-H "Content-Type: application/json" \
-d '{
"input_data": {
"user_name": "John Doe",
"email": "[email protected]",
"age": 30,
"preferences": {
"theme": "dark",
"notifications": true
},
"tags": ["admin", "developer"]
}
}'

Accessing in nodes:

{{ input.user_name }}              → "John Doe"
{{ input.email }} → "[email protected]"
{{ input.age }} → 30
{{ input.preferences.theme }} → "dark"
{{ input.tags[0] }} → "admin"
{{ input.tags[1] }} → "developer"

Example 2: Array Input Data

Pass an array of items:

Python
data = {
"input_data": [
{"id": 1, "name": "Alice", "role": "admin"},
{"id": 2, "name": "Bob", "role": "user"}
]
}

response = requests.post(url, headers=headers, json=data)
Shell
curl -X POST "https://scriptrun.ai/api/v1/workflows/6/run/" \
-H "X-Api-Key: <Your API Key>" \
-H "Content-Type: application/json" \
-d '{
"input_data": [
{"id": 1, "name": "Alice", "role": "admin"},
{"id": 2, "name": "Bob", "role": "user"}
]
}'

Accessing in nodes:

{{ input[0].name }}     → "Alice"
{{ input[1].role }} → "user"
{{ input[0].id }} → 1

Example 3: Plain Text Input

Pass plain text (will be wrapped automatically):

Python
data = {
"input_data": "Hello, this is a simple text input"
}

response = requests.post(url, headers=headers, json=data)

Accessing in nodes:

{{ input.__raw_input__ }}    → "Hello, this is a simple text input"

Using Input Data in Nodes

In HTTP Node

{
"url": "https://api.example.com/users",
"method": "POST",
"headers": {
"Authorization": "Bearer {{ input.api_token }}",
"Content-Type": "application/json"
},
"body": {
"name": "{{ input.user_name }}",
"email": "{{ input.email }}",
"age": "{{ input.age }}"
}
}

In LLM Node

{
"messages": [
{
"role": "system",
"message": "You are a helpful assistant"
},
{
"role": "user",
"message": "Create a welcome message for {{ input.user_name }} with email {{ input.email }}"
}
]
}

Complex Example: Nested Structures

Python
data = {
"input_data": {
"company": {
"name": "Acme Inc",
"departments": [
{
"name": "IT",
"employees": [
{"name": "Alice", "role": "Developer"},
{"name": "Bob", "role": "DevOps"}
]
},
{
"name": "HR",
"employees": [
{"name": "Charlie", "role": "Manager"}
]
}
]
}
}
}

Accessing nested data:

{{ input.company.name }}                          → "Acme Inc"
{{ input.company.departments[0].name }} → "IT"
{{ input.company.departments[0].employees[0].name }} → "Alice"
{{ input.company.departments[0].employees[1].role }} → "DevOps"
{{ input.company.departments[1].employees[0].name }} → "Charlie"

Variable Syntax

ScriptRun supports flexible variable syntax for accessing input data:

SyntaxDescriptionExample
{{ input.field }}Access object field{{ input.user_name }}
{{ input.nested.field }}Access nested field{{ input.preferences.theme }}
{{ input[0] }}Access array element by index{{ input[0] }}
{{ input.users[0].name }}Access field in array element{{ input.users[0].name }}
{{ input.tags[1] }}Access nested array element{{ input.tags[1] }}

Both syntaxes work:

  • Dot notation: {{ input.tags.0 }}
  • Bracket notation: {{ input.tags[0] }}

Error Handling

Invalid JSON:

  • Plain text or invalid JSON is automatically wrapped in {"__raw_input__": "text"}
  • Access it via {{ input.__raw_input__ }}

Missing Fields:

  • If a field doesn't exist, it returns an empty value
  • Example: {{ input.nonexistent_field }}{}

Empty Input:

  • If no input_data is provided, it defaults to {}

Best Practices

  1. Use descriptive field names: user_name instead of n
  2. Validate required fields: Use Trigger node with required input fields
  3. Keep structure consistent: Use the same data structure for similar workflows
  4. Test with sample data: Verify your variables work before running in production
  5. Document your inputs: Add comments in your workflow about expected input structure

Responses

  • 200: Workflow execution started successfully
  • 400: Invalid input data or workflow structure
  • 404: Workflow not found