---
title: "Workflows in the SDK"
canonical: https://trickest.com/docs/developer-tools/sdk/workflows
description: "client.workflows; CRUD, copy, move, and version management for workflow definitions."
---

# Workflows in the SDK

Examples use a server-side `client` from
[Client setup](/docs/developer-tools/sdk/client-setup), and resource IDs supplied
by your application.

<Info>
  **Platform concepts:** [Workflows](/docs/key-concepts/workflows). **CLI:**
  [Workflows](/docs/developer-tools/cli/workflows).
</Info>

## `client.workflows`

All list/create methods require a **`spaceId`** (workspace UUID).

| Method                                         | Description                             |
| ---------------------------------------------- | --------------------------------------- |
| `list(spaceId, options?)`                      | `AsyncGenerator<Workflow>`              |
| `listPage(spaceId, options?)`                  | `PaginatedResponse<Workflow>`           |
| `get(id, options?)`                            | Single workflow                         |
| `create(spaceId, data, options?)`              | `{ name, description?, project_info? }` |
| `update(id, data, options?)`                   | Metadata update                         |
| `delete(id, options?)`                         | Delete workflow                         |
| `copy(id, targetSpaceId, options?)`            | Copy to another space                   |
| `move(id, targetSpaceId, options?)`            | Move to another space                   |
| `getVersion(workflowId, versionId?, options?)` | Fetch a version snapshot                |
| `saveVersion(workflowId, data, options?)`      | Persist graph JSON as a new version     |

```ts
const workflow = await client.workflows.create(spaceId, {
  name: "Discovery Pipeline",
  description: "Subdomain → probe → scan",
});

const copied = await client.workflows.copy(workflow.id, otherSpaceId);
// workflowId refers to an existing workflow with a saved graph.
const version = await client.workflows.getVersion(workflowId);
```

`create()` creates workflow metadata. Save a graph version before executing
a new workflow. `getVersion(id)` reads the latest version; when you supply a
`versionId`, the client fetches that version by ID.

## Types

Exported from `@trickest/sdk`:

- `Workflow`, `CreateWorkflow`, `UpdateWorkflow`, `WorkflowVersion`

Use Zod validation on responses when shapes are critical:

```ts
import { z } from "zod";

const WorkflowSchema = z.object({
  id: z.string(),
  name: z.string(),
});

const wf = await client.workflows.get(workflowId, { schema: WorkflowSchema });
```

## Relationship to runs and database

- **Execute:** `client.runs.execute(workflow.id, …)`; see [Runs & schedules](/docs/developer-tools/sdk/runs-schedules).
- **Live Tables:** `client.database.listByWorkflow(workflowId)` and `resolveByName(name, workflowId)`. The latter prefers the workflow but can fall back to other vault tables; use `listByWorkflow` for strict scope.

## Related

<CardGroup cols={2}>
  <Card
    title="Runs & schedules"
    icon="play"
    href="/docs/developer-tools/sdk/runs-schedules"
  >
    Execute and schedule this workflow.
  </Card>
  <Card
    title="Library & tools"
    icon="cube"
    href="/docs/developer-tools/sdk/library-tools"
  >
    Resolve tool nodes when building graphs programmatically.
  </Card>
</CardGroup>

---
_Markdown source of https://trickest.com/docs/developer-tools/sdk/workflows._
