SWIRLS_
ReferenceSDKClient

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:

ParameterTypeRequiredDescription
idstringNo
projectIdstringYes
folderIdstring | nullNo
namestringYes
labelstringYes
descriptionstringNo

Output:

FieldTypeDescription
idstring

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:

ParameterTypeRequiredDescription
idstringYes

Output:

FieldTypeDescription
idstring
projectIdstring
folderIdstring | null
namestring
labelstring
descriptionstring | null
createdAtunknown
orgIdstring | null
userIdstring
nodesobject[]
edgesobject[]

updateGraph

Update an existing graph

PUT

Usage:

const result = await swirls.client.graphs.updateGraph({
  id: '...',
})

Input:

ParameterTypeRequiredDescription
idstringYes
namestringNo
descriptionstringNo
folderIdstring | nullNo

Output:

FieldTypeDescription
idstring
projectIdstring
folderIdstring | null
namestring
labelstring
descriptionstring | null
createdAtunknown
orgIdstring | null
userIdstring

deleteGraph

Delete a graph

DELETE

Usage:

const result = await swirls.client.graphs.deleteGraph({
  id: '...',
})

Input:

ParameterTypeRequiredDescription
idstringYes

listGraphs

List all graphs in a project

GET

Usage:

const result = await swirls.client.graphs.listGraphs({
  projectId: '...',
})

Input:

ParameterTypeRequiredDescription
projectIdstringYes
folderIdstring | nullNo
paginationobjectNo

Output:

FieldTypeDescription
paginationobject
resultsobject[]
totalCountnumber

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:

ParameterTypeRequiredDescription
idstringNo
graphIdstringYes
namestringYes
labelstringYes
descriptionstringNo
type"bucket" | "code" | "document" | "email" | "graph" | "http" | "ai" | "scrape" | "stream" | "switch" | "wait"Yes
configobjectYes
reviewConfigobject | nullNo
positionobjectNo
outputSchemaobject | nullNo
inputSchemaobject | nullNo

Output:

FieldTypeDescription
idstring
graphIdstring
namestring
labelstring
descriptionstring | null
type"bucket" | "code" | "document" | "email" | "graph" | "http" | "ai" | "scrape" | "stream" | "switch" | "wait"
configobject
reviewConfigunknown | null
positionobject | null
outputSchemaobject | null
inputSchemaobject | null
createdAtunknown
orgIdstring | null
userIdstring

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:

ParameterTypeRequiredDescription
idstringYes
type"bucket" | "code" | "document" | "email" | "graph" | "http" | "ai" | "scrape" | "stream" | "switch" | "wait"No
namestringNo
labelstringNo
descriptionstringNo
configobjectNo
reviewConfigobject | nullNo
positionobjectNo
outputSchemaobject | nullNo
inputSchemaobject | nullNo

Output:

FieldTypeDescription
idstring
graphIdstring
namestring
labelstring
descriptionstring | null
type"bucket" | "code" | "document" | "email" | "graph" | "http" | "ai" | "scrape" | "stream" | "switch" | "wait"
configobject
reviewConfigunknown | null
positionobject | null
outputSchemaobject | null
inputSchemaobject | null
createdAtunknown
orgIdstring | null
userIdstring

deleteNode

Delete a node from a graph

DELETE

Usage:

const result = await swirls.client.graphs.deleteNode({
  id: '...',
})

Input:

ParameterTypeRequiredDescription
idstringYes

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:

ParameterTypeRequiredDescription
idstringNo
graphIdstringYes
sourceNodeIdstringYes
targetNodeIdstringYes
labelstringNo

Output:

FieldTypeDescription
idstring
graphIdstring
sourceNodeIdstring
targetNodeIdstring
labelstring | null
createdAtunknown
orgIdstring | null
userIdstring

deleteEdge

Delete an edge from a graph

DELETE

Usage:

const result = await swirls.client.graphs.deleteEdge({
  id: '...',
})

Input:

ParameterTypeRequiredDescription
idstringYes

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:

ParameterTypeRequiredDescription
graphIdstringYes
nodesobject[]Yes
edgesobject[]Yes

Output:

FieldTypeDescription
idstring
projectIdstring
folderIdstring | null
namestring
labelstring
descriptionstring | null
createdAtunknown
orgIdstring | null
userIdstring
nodesobject[]
edgesobject[]

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:

ParameterTypeRequiredDescription
graphIdstringYes
inputobjectNo

Output:

FieldTypeDescription
executionIdstring

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:

ParameterTypeRequiredDescription
idstringYes

Output:

FieldTypeDescription
idstring
graphIdstring
executorTypestring
executorIdstring
triggerIdstring | null
triggerTypestring | null
statusstring
inputunknown
outputunknown
errorstring | null
startedAtunknown
completedAtunknown | null
createdAtunknown
orgIdstring | null
userIdstring
nodeExecutionsobject[]

listExecutions

List executions for a graph

GET

Usage:

const result = await swirls.client.graphs.listExecutions({
  graphId: '...',
})

Input:

ParameterTypeRequiredDescription
graphIdstringYes
paginationobjectNo

Output:

FieldTypeDescription
paginationobject
resultsobject[]
totalCountnumber

listTriggers

GET

Usage:

const result = await swirls.client.graphs.listTriggers({
  graphId: '...',
})

Input:

ParameterTypeRequiredDescription
graphIdstringYes
paginationobjectNo

Output:

FieldTypeDescription
paginationobject
resultsobject[]
totalCountnumber

getStream

GET

Usage:

const result = await swirls.client.graphs.getStream({
  graphId: '...',
})

Input:

ParameterTypeRequiredDescription
graphIdstringYes

On this page