SWIRLS_
Reference

API

Reference for the Swirls API -- authentication, RPC endpoints, public endpoints, pagination, and error handling.

The Swirls API provides programmatic access to every capability available in the Portal. Use it to manage projects, build and execute graphs, configure triggers, work with forms and webhooks, and more.

Base URL

All API requests are made against your Swirls deployment's base URL. If you are using Swirls Cloud, the base URL is provided in your account dashboard. For self-hosted deployments, this is the URL where your API server is running.

Authentication

Most API endpoints require authentication. Include a valid JWT in the Authorization header of each request:

Authorization: Bearer <token>

Requests with a missing, expired, or invalid token receive a 401 Unauthorized response.

Protocol

The Swirls API uses oRPC (type-safe RPC) for its authenticated endpoints. All RPC requests are routed through the /rpc path prefix. In addition, Swirls exposes several public REST-style endpoints for form submissions, webhooks, and agent chat that do not require authentication.

RPC endpoints

The following domains are available through the RPC layer. Each domain groups related operations.

Projects

OperationDescription
createProjectCreate a new project with a given name.
getProjectRetrieve a project by ID.
listProjectsList all projects accessible to the authenticated user.
createStorageProvision a storage instance for a project.
getStorageRetrieve storage instance status and health for a project.

Graphs

OperationDescription
createGraphCreate a new graph within a project.
getGraphRetrieve a graph by ID, including its nodes and edges.
updateGraphUpdate a graph's name, description, or folder.
deleteGraphDelete a graph.
listGraphsList graphs in a project, optionally filtered by folder. Paginated.
syncGraphSynchronize a graph's nodes and edges in a single operation. Creates, updates, and deletes nodes and edges to match the provided state.
createNodeAdd a node to a graph. Node names must be unique within a graph.
updateNodeUpdate a node's type, configuration, schema, position, or other properties.
deleteNodeRemove a node from a graph. Edges must be deleted first.
createEdgeAdd a directed edge between two nodes. Cycles are not allowed.
deleteEdgeRemove an edge.
executeGraphExecute a graph from its root node with a given input payload. Returns an execution ID.
getExecutionRetrieve a graph execution by ID, including all node executions.
listExecutionsList executions for a graph. Paginated.
listTriggersList triggers attached to a graph. Paginated.
getStreamRetrieve the stream associated with a graph, if one exists.

Forms

OperationDescription
createFormCreate a new form in a project. Names must be unique within a project.
getFormRetrieve a form by ID.
updateFormUpdate a form's name, description, schema, enabled status, or folder.
deleteFormDelete a form.
listFormsList forms in a project, optionally filtered by folder. Paginated.
listTriggersForFormList all triggers that reference a given form. Paginated.

Webhooks

OperationDescription
createWebhookCreate a new webhook in a project. Names must be unique within a project.
getWebhookRetrieve a webhook by ID.
updateWebhookUpdate a webhook's name, description, schema, enabled status, or folder.
deleteWebhookDelete a webhook.
listWebhooksList webhooks in a project, optionally filtered by folder. Paginated.
listTriggersForWebhookList all triggers that reference a given webhook. Paginated.

Schedules

OperationDescription
createScheduleCreate a new schedule with a cron expression and optional timezone.
getScheduleRetrieve a schedule by ID.
updateScheduleUpdate a schedule's name, cron expression, timezone, or enabled status.
deleteScheduleDelete a schedule.
listSchedulesList schedules in a project, optionally filtered by folder. Paginated.
listTriggersForScheduleList all triggers that reference a given schedule. Paginated.

Agents

OperationDescription
createAgentCreate a new agent with a prompt and optional tool trigger bindings.
getAgentRetrieve an agent by ID, including its tool configuration.
updateAgentUpdate an agent's name, description, prompt, or tools.
deleteAgentDelete an agent.
listAgentsList agents in a project, optionally filtered by folder. Paginated.

Triggers

Triggers connect a resource (form, webhook, schedule, or agent) to a graph. When the resource fires, the trigger executes the connected graph.

OperationDescription
createTriggerCreate a trigger linking a resource to a graph. The graph must have a valid root node.
getTriggerRetrieve a trigger by ID.
updateTriggerUpdate a trigger's enabled status, graph, or resource binding.
deleteTriggerDelete a trigger.
listTriggersList triggers in a project, optionally filtered by graph or resource. Paginated.
listSchemaIncompatibilitiesList triggers with schema incompatibilities in a project. Paginated.
executeTriggersExecute all valid triggers for a given resource with a payload. Returns execution IDs.

Schemas

OperationDescription
createSchemaCreate a reusable JSON Schema in a project. Names must be unique within a project.
getSchemaRetrieve a schema by ID.
updateSchemaUpdate a schema's name, description, definition, or folder.
deleteSchemaDelete a schema.
listSchemasList schemas in a project, optionally filtered by folder. Paginated.

Streams

Streams persist graph execution output to a structured data table.

OperationDescription
createStreamCreate a stream linked to a graph. Streams have a 1:1 relationship with graphs.
getStreamRetrieve a stream by ID, including its associated graph.
updateStreamUpdate a stream's name, description, persistence condition, or enabled status.
deleteStreamDelete a stream.
listStreamsList streams in a project. Paginated.
listStreamSchemasList schema versions for a stream. Paginated.
promoteStreamSchemaPromote a draft schema version to production and create the backing table.
getStreamTableSchemaRetrieve the table schema for a stream's current production version.
listStreamTableColumnsList the columns in a stream's backing table.
executeStreamQueryQuery a stream's persisted data with optional filters, limit, and offset.

Secrets

OperationDescription
createSecretCreate an encrypted secret (key-value pair) in a project's storage.
getSecretValueRetrieve the decrypted value of a non-sensitive secret. Sensitive secrets cannot be revealed.
updateSecretUpdate a secret's key, value, or sensitivity flag.
deleteSecretDelete a secret.
listSecretsList all secrets in a project (values are masked).

Folders

OperationDescription
createFolderCreate a folder within a project for organizing resources.
getFolderRetrieve a folder by ID.
updateFolderUpdate a folder's name.
deleteFolderDelete a folder.
listFoldersList folders in a project. Paginated.

Reviews

Reviews enable human-in-the-loop approval during graph execution. When a node is configured for review, execution pauses until the review is approved or rejected.

OperationDescription
listReviewsList reviews for a project, optionally filtered by status. Defaults to pending reviews. Paginated.
getReviewRetrieve a review by ID, including the associated node and execution details.
approveReviewApprove a pending review, optionally providing form data that is validated against the node's review schema. Resumes execution.
rejectReviewReject a pending review with an optional reason. Resumes execution with a failure state.

Public endpoints

The following REST endpoints do not require authentication and are designed for external integrations.

Form submission

POST /forms/:formId

Submit data to a form. The request body must be valid JSON. If the form has triggers attached, all enabled triggers execute and the response includes the resulting execution IDs.

Response:

{
  "message": "Form submitted successfully",
  "executionIds": ["exec_abc123", "exec_def456"]
}

Webhook

POST /webhooks/:webhookId

Send a payload to a webhook endpoint. If the webhook is enabled and has triggers attached, all matching triggers execute.

Response:

{
  "message": "Webhook received",
  "executionIds": ["exec_abc123"]
}

Agent chat

POST /agents/:agentId/chat

Send a message to an agent and receive a streaming response. The request body includes an array of messages and an optional conversationId to continue an existing conversation. This endpoint requires authentication and returns a streaming text/event-stream response.

Request body:

{
  "messages": [
    { "id": "msg_1", "role": "user", "parts": [{ "type": "text", "text": "Hello" }] }
  ],
  "conversationId": "conv_abc123"
}

Pagination

All list operations use cursor-based pagination and return results in the following structure:

{
  "pagination": {
    "hasNextPage": true,
    "hasPreviousPage": false,
    "startCursor": "...",
    "endCursor": "..."
  },
  "results": [],
  "totalCount": 42
}

Pass before, after, first, or last parameters to control which page of results is returned.

Error handling

The API returns errors in a consistent format:

{
  "error": {
    "code": "NOT_FOUND",
    "message": "Graph not found"
  }
}

Error codes:

CodeHTTP StatusDescription
UNAUTHORIZED401Authentication is missing or invalid.
FORBIDDEN403The authenticated user does not have access to the requested resource.
BAD_REQUEST400The request is malformed or contains invalid parameters.
NOT_FOUND404The requested resource does not exist.
INTERNAL_SERVER_ERROR500An unexpected error occurred on the server.

Next steps

  • CLI reference -- Authenticate and generate code from the command line.
  • Portal guide -- Build graphs, forms, and triggers through the visual interface.
  • Schemas guide -- Define and manage JSON Schemas for your resources.

On this page