---
title: "Workflows"
description: "REST endpoints for workflows. Bearer-auth required."
section: "API"
group: "REST"
order: 85
---

## GET /api/workflows

List workflows.

**Query parameters**

- `limit` (optional): Page size (1–100, default 100).
- `after` (optional): Keyset cursor — return the page after this row (next page).
- `before` (optional): Keyset cursor — return the page before this row (prev page).
- `ids` (optional): Comma-separated list of IDs. Narrows results to these IDs within the caller's accessible scope (does not bypass access checks).
- `filter` (optional): Nested filter expression (`<Entity>Filter`): AND/OR/NOT + per-field comparison operators + relation traversal. JSON-encoded on the query string.
- `orderBy` (optional): Multi-key sort (`<Entity>OrderBy[]`): array of `{ field: direction }` applied in order. Directions: asc/desc plus the four explicit nulls variants. JSON-encoded on the query string.
- `workspace_id` (optional): Filter to workflows in this workspace. When omitted, returns workflows across every workspace the caller is a member of (admins see all).
- `include_deleted` (optional): Soft-deleted workflow visibility. `false` (default) — active rows only. `true` — active plus soft-deleted. `only` — soft-deleted only (trash view).
- `name` (optional): Case-insensitive substring match on name.
- `source` (optional): Narrow by source. `workspace` = this workspace's rows plus those visible via installed integrations; `integration` = only rows made visible by installed integrations; omit = union.
- `entry_node_id` (optional): Shorthand: filter where `entryNodeId` equals this value.
- `output_node_id` (optional): Shorthand: filter where `outputNodeId` equals this value.
- `created_by` (optional): Shorthand: filter where `createdBy` equals this value.
- `runtime_user_id` (optional): Shorthand: filter where `runtimeUserId` equals this value.
- `retention_tier` (optional): Shorthand: filter where `retentionTier` equals this value.

**Response**

```json
{
  "data": [
    {
      "id": "<...>",
      "workspaceId": "<...>",
      "name": "<...>",
      "description": "<...>",
      "entryNodeId": "<...>",
      "outputNodeId": "<...>",
      "inputSchema?": "<...>",
      "outputSchema?": "<...>",
      "createdBy": "<...>",
      "runtimeUserId": "<...>",
      "deletedAt": "<...>",
      "retentionTier": "<...>",
      "createdAt": "<...>",
      "updatedAt": "<...>"
    }
  ],
  "pageInfo": {
    "total": "number",
    "hasNextPage": "boolean",
    "hasPreviousPage": "boolean",
    "startCursor": "string",
    "endCursor": "string"
  }
}
```

## POST /api/workflows

Create workflow

**Request body**

```json
{
  "workspaceId": "string",
  "name": "string",
  "description?": "string",
  "inputSchema?": {},
  "outputSchema?": {}
}
```

**Response**

```json
{
  "id": "string",
  "workspaceId": "string",
  "name": "string",
  "description": "string",
  "entryNodeId": "string",
  "outputNodeId": "string",
  "inputSchema?": "any",
  "outputSchema?": "any",
  "createdBy": "string",
  "runtimeUserId": "string",
  "deletedAt": "string",
  "retentionTier": "any",
  "createdAt": "string",
  "updatedAt": "string"
}
```

## GET /api/workflows/{id}

Get a workflow by ID.

**Path parameters**

- `id` (required): Workflow to retrieve.

**Response**

```json
{
  "id": "string",
  "workspaceId": "string",
  "name": "string",
  "description": "string",
  "entryNodeId": "string",
  "outputNodeId": "string",
  "inputSchema?": "any",
  "outputSchema?": "any",
  "createdBy": "string",
  "runtimeUserId": "string",
  "deletedAt": "string",
  "retentionTier": "any",
  "createdAt": "string",
  "updatedAt": "string"
}
```

## PATCH /api/workflows/{id}

Update workflow

**Path parameters**

- `id` (required): The workflow's prefixed ID.

**Request body**

```json
{
  "name?": "string",
  "description?": "string",
  "entryNodeId?": "string",
  "outputNodeId?": "string",
  "inputSchema?": {},
  "outputSchema?": {},
  "runtimeUserId?": "string"
}
```

**Response**

```json
{
  "id": "string",
  "workspaceId": "string",
  "name": "string",
  "description": "string",
  "entryNodeId": "string",
  "outputNodeId": "string",
  "inputSchema?": "any",
  "outputSchema?": "any",
  "createdBy": "string",
  "runtimeUserId": "string",
  "deletedAt": "string",
  "retentionTier": "any",
  "createdAt": "string",
  "updatedAt": "string"
}
```

## DELETE /api/workflows/{id}

Soft-delete a workflow.

**Path parameters**

- `id` (required): Workflow to soft-delete.

**Response**

```json
{
  "success": "boolean"
}
```

## PUT /api/workflows/{id}/graph

Sync workflow graph (bulk replace nodes and edges)

**Path parameters**

- `id` (required): The workflow's prefixed ID.

**Request body**

```json
{
  "nodes?": [
    {
      "type": "<...>",
      "name": "<...>",
      "config?": "<...>"
    }
  ],
  "edges?": [
    {
      "sourceNodeIndex": "<...>",
      "targetNodeIndex": "<...>",
      "handle?": "<...>",
      "priority?": "<...>",
      "label?": "<...>"
    }
  ],
  "entryNodeIndex?": "number"
}
```

**Response**

```json
{
  "nodes": [
    {
      "id": "string",
      "type": "agent | function | swarm | workflow",
      "name": "string"
    }
  ],
  "edges": [
    {
      "id": "string",
      "sourceNodeId": "string",
      "targetNodeId": "string"
    }
  ]
}
```

## DELETE /api/workflows/{id}/purge

Permanently delete a soft-deleted workflow.

**Path parameters**

- `id` (required): Soft-deleted workflow to permanently delete.

**Response**

```json
{
  "success": "boolean"
}
```

## POST /api/workflows/{id}/restore

Restore a soft-deleted workflow.

**Path parameters**

- `id` (required): Soft-deleted workflow to restore.

**Response**

```json
{
  "id": "string",
  "workspaceId": "string",
  "name": "string",
  "description": "string",
  "entryNodeId": "string",
  "outputNodeId": "string",
  "inputSchema?": "any",
  "outputSchema?": "any",
  "createdBy": "string",
  "runtimeUserId": "string",
  "deletedAt": "string",
  "retentionTier": "any",
  "createdAt": "string",
  "updatedAt": "string"
}
```
