SDK
Reference documentation for the Swirls TypeScript SDK (@swirls/sdk).
The @swirls/sdk package provides a type-safe TypeScript client for the Swirls API and a Graph Builder for constructing workflows in code.
Installation
npm install @swirls/sdkClient
The Client exposes the full Swirls API as type-safe procedures (graphs, forms, triggers, streams, and more). Use it when you need to call individual API endpoints.
import { Swirls } from '@swirls/sdk/client'
const swirls = new Swirls({ apiKey: 'your-api-key' })
const projects = await swirls.client.projects.listProjects()See Client for all 16 namespaces.
Graph Builder
The Graph Builder (@swirls/sdk/graph) lets you build and manipulate workflow graphs in code with a fluent API. Define nodes and edges locally, validate structure, then persist via the API or serialize for storage.
import { Swirls } from '@swirls/sdk/client'
import { GraphBuilder } from '@swirls/sdk/graph'
const swirls = new Swirls({ apiKey: 'your-api-key' })
const graph = new GraphBuilder({ client: swirls.client })
.setName('my_workflow')
.addNode('fetch', { type: 'http', label: 'Fetch', config: { type: 'http', url: 'https://api.example.com' } })
.addNode('process', { type: 'ai', label: 'Process', config: { type: 'ai', kind: 'text', prompt: 'Summarize' } })
.addEdge({ source: 'fetch', target: 'process' })
await graph.save({ projectId: '...' })Workflow Builder
The Workflow Builder (@swirls/sdk/workflow) composes a graph with trigger associations (forms, webhooks, schedules, agents). Validate trigger–graph schema compatibility, serialize for storage, and export Mermaid diagrams.