Graphs
SDK reference for graphs — Create, update, execute, and manage workflow graphs, nodes, and edges.
Create, update, execute, and manage workflow graphs, nodes, and edges.
createGraph
Create a new workflow graph
POST
Usage:
const result = await swirls.client.graphs.createGraph({
projectId: '...',
name: '...',
label: '...',
})Input:
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | No | |
projectId | string | Yes | |
folderId | string | null | No | |
name | string | Yes | |
label | string | Yes | |
description | string | No |
Output:
| Field | Type | Description |
|---|---|---|
id | string |
getGraph
Get a graph with all its nodes and edges. Each node has position: { x, y } (canvas coordinates). Use this to understand workflow structure and existing layout. Before creating or updating nodes, call this to see existing positions so you can place new nodes and adjust positions for a visually compelling flow (e.g. left-to-right, consistent spacing, no overlap). Each node also includes inputSchema and outputSchema — inspect these before calling execute_graph.
GET
Usage:
const result = await swirls.client.graphs.getGraph({
id: '...',
})Input:
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes |
Output:
| Field | Type | Description |
|---|---|---|
id | string | |
projectId | string | |
folderId | string | null | |
name | string | |
label | string | |
description | string | null | |
createdAt | unknown | |
orgId | string | null | |
userId | string | |
nodes | object[] | |
edges | object[] |
updateGraph
Update an existing graph
PUT
Usage:
const result = await swirls.client.graphs.updateGraph({
id: '...',
})Input:
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | |
name | string | No | |
description | string | No | |
folderId | string | null | No |
Output:
| Field | Type | Description |
|---|---|---|
id | string | |
projectId | string | |
folderId | string | null | |
name | string | |
label | string | |
description | string | null | |
createdAt | unknown | |
orgId | string | null | |
userId | string |
deleteGraph
Delete a graph
DELETE
Usage:
const result = await swirls.client.graphs.deleteGraph({
id: '...',
})Input:
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes |
listGraphs
List all graphs in a project
GET
Usage:
const result = await swirls.client.graphs.listGraphs({
projectId: '...',
})Input:
| Parameter | Type | Required | Description |
|---|---|---|---|
projectId | string | Yes | |
folderId | string | null | No | |
pagination | object | No |
Output:
| Field | Type | Description |
|---|---|---|
pagination | object | |
results | object[] | |
totalCount | number |
createNode
Create a new node in a graph. For a visually compelling flow: call get_graph first to get existing nodes and their position { "x", "y" }; place the new node considering the layout—e.g. left-to-right (increase x for downstream), stack vertically (vary y), use ~150–200px spacing between nodes, avoid overlap. Position format: { "x": number, "y": number }. Node types and their configs:
POST
Usage:
const result = await swirls.client.graphs.createNode({
graphId: '...',
name: '...',
label: '...',
type: '...',
config: {},
})Input:
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | No | |
graphId | string | Yes | |
name | string | Yes | |
label | string | Yes | |
description | string | No | |
type | "bucket" | "code" | "document" | "email" | "graph" | "http" | "ai" | "scrape" | "stream" | "switch" | "wait" | Yes | |
config | object | Yes | |
reviewConfig | object | null | No | |
position | object | No | |
outputSchema | object | null | No | |
inputSchema | object | null | No |
Output:
| Field | Type | Description |
|---|---|---|
id | string | |
graphId | string | |
name | string | |
label | string | |
description | string | null | |
type | "bucket" | "code" | "document" | "email" | "graph" | "http" | "ai" | "scrape" | "stream" | "switch" | "wait" | |
config | object | |
reviewConfig | unknown | null | |
position | object | null | |
outputSchema | object | null | |
inputSchema | object | null | |
createdAt | unknown | |
orgId | string | null | |
userId | string |
updateNode
Update an existing node. For layout: call get_graph to see all nodes and edges; set position { "x", "y" } to improve flow—align with connected nodes, leave ~150–200px spacing, keep left-to-right or top-to-bottom order for a visually compelling layout.
PUT
Usage:
const result = await swirls.client.graphs.updateNode({
id: '...',
})Input:
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | |
type | "bucket" | "code" | "document" | "email" | "graph" | "http" | "ai" | "scrape" | "stream" | "switch" | "wait" | No | |
name | string | No | |
label | string | No | |
description | string | No | |
config | object | No | |
reviewConfig | object | null | No | |
position | object | No | |
outputSchema | object | null | No | |
inputSchema | object | null | No |
Output:
| Field | Type | Description |
|---|---|---|
id | string | |
graphId | string | |
name | string | |
label | string | |
description | string | null | |
type | "bucket" | "code" | "document" | "email" | "graph" | "http" | "ai" | "scrape" | "stream" | "switch" | "wait" | |
config | object | |
reviewConfig | unknown | null | |
position | object | null | |
outputSchema | object | null | |
inputSchema | object | null | |
createdAt | unknown | |
orgId | string | null | |
userId | string |
deleteNode
Delete a node from a graph
DELETE
Usage:
const result = await swirls.client.graphs.deleteNode({
id: '...',
})Input:
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes |
createEdge
Create an edge connecting two nodes. Edges define the flow of data between nodes. Cycles are not allowed.
POST
Usage:
const result = await swirls.client.graphs.createEdge({
graphId: '...',
sourceNodeId: '...',
targetNodeId: '...',
})Input:
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | No | |
graphId | string | Yes | |
sourceNodeId | string | Yes | |
targetNodeId | string | Yes | |
label | string | No |
Output:
| Field | Type | Description |
|---|---|---|
id | string | |
graphId | string | |
sourceNodeId | string | |
targetNodeId | string | |
label | string | null | |
createdAt | unknown | |
orgId | string | null | |
userId | string |
deleteEdge
Delete an edge from a graph
DELETE
Usage:
const result = await swirls.client.graphs.deleteEdge({
id: '...',
})Input:
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes |
syncGraph
Sync a complete graph structure with nodes and edges. This is the most efficient way to create or update a complete workflow in one operation. Each node can include position: { "x": number, "y": number }. For a visually compelling flow, assign positions so nodes run left-to-right (or top-to-bottom), with ~150–200px spacing and no overlap; consider edge connections when placing nodes.
POST
Usage:
const result = await swirls.client.graphs.syncGraph({
graphId: '...',
nodes: [],
edges: [],
})Input:
| Parameter | Type | Required | Description |
|---|---|---|---|
graphId | string | Yes | |
nodes | object[] | Yes | |
edges | object[] | Yes |
Output:
| Field | Type | Description |
|---|---|---|
id | string | |
projectId | string | |
folderId | string | null | |
name | string | |
label | string | |
description | string | null | |
createdAt | unknown | |
orgId | string | null | |
userId | string | |
nodes | object[] | |
edges | object[] |
executeGraph
Execute a graph with input data. Returns an execution ID that can be used to track progress via get_execution.
POST
Usage:
const result = await swirls.client.graphs.executeGraph({
graphId: '...',
})Input:
| Parameter | Type | Required | Description |
|---|---|---|---|
graphId | string | Yes | |
input | object | No |
Output:
| Field | Type | Description |
|---|---|---|
executionId | string |
getExecution
Get the status and results of a graph execution, including all node executions. Use the executionId returned by execute_graph. The response includes the overall status and each node's individual execution status and output.
GET
Usage:
const result = await swirls.client.graphs.getExecution({
id: '...',
})Input:
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes |
Output:
| Field | Type | Description |
|---|---|---|
id | string | |
graphId | string | |
executorType | string | |
executorId | string | |
triggerId | string | null | |
triggerType | string | null | |
status | string | |
input | unknown | |
output | unknown | |
error | string | null | |
startedAt | unknown | |
completedAt | unknown | null | |
createdAt | unknown | |
orgId | string | null | |
userId | string | |
nodeExecutions | object[] |
listExecutions
List executions for a graph
GET
Usage:
const result = await swirls.client.graphs.listExecutions({
graphId: '...',
})Input:
| Parameter | Type | Required | Description |
|---|---|---|---|
graphId | string | Yes | |
pagination | object | No |
Output:
| Field | Type | Description |
|---|---|---|
pagination | object | |
results | object[] | |
totalCount | number |
listTriggers
GET
Usage:
const result = await swirls.client.graphs.listTriggers({
graphId: '...',
})Input:
| Parameter | Type | Required | Description |
|---|---|---|---|
graphId | string | Yes | |
pagination | object | No |
Output:
| Field | Type | Description |
|---|---|---|
pagination | object | |
results | object[] | |
totalCount | number |
getStream
GET
Usage:
const result = await swirls.client.graphs.getStream({
graphId: '...',
})Input:
| Parameter | Type | Required | Description |
|---|---|---|---|
graphId | string | Yes |