> ## Documentation Index
> Fetch the complete documentation index at: https://developers.clay.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Build a Workflow (Alpha)

> Use the Clay plugin and CLI to create, edit, run, and inspect a Workflow.

Use Workflows when you want to build and edit Clay logic from an agent or terminal instead of the Clay UI.

<Note>
  **Workflows are in Alpha.** They are earlier and more experimental than Clay-managed functions and custom functions.
</Note>

## When to use this

* Agent-first creation and editing in Claude Code, Codex, or Cursor.
* CLI-based run, inspect, and debug loops.
* Code inside the flow.
* A flow created from a prompt, CSV, webhook, Audience, or existing Clay table.
* Runs that avoid the 50,000 row limit.

## 1. Install the plugin

<Card title="Clay plugin quickstart" href="/cli/quickstart">
  Install the plugin and configure `CLAY_API_KEY`.
</Card>

## 2. Create or open a Workflow

List existing Workflows:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
clay workflows list
```

Create a new Workflow:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
clay workflows create --name "Enrich target accounts"
```

## 3. Build and edit with an agent

Ask your agent to build the Workflow. The Clay plugin lets the agent read the Workflow, edit nodes, validate the graph, and test Clay actions before wiring them in.

Example prompts:

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
Build a Workflow that takes a company domain, enriches company data, finds relevant sales leaders, and returns structured output for my CRM.
```

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
Turn this Clay table into a Workflow I can run in batches. Keep the same enrichment steps, but add a code step that filters out companies with fewer than 100 employees.
```

## 4. Run and inspect

Start a test run:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
echo '{"domain":"clay.com"}' | clay workflows runs test wf_abc123 --input -
```

Fetch run status:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
clay workflows runs get wf_abc123 wfr_abc123 --nodes
```

Inspect failed steps:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
clay workflows runs steps wf_abc123 wfr_abc123 --status failed
```

## 5. Use snapshots

Use snapshots to inspect changes or restore an earlier Workflow state.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
clay workflows snapshots list wf_abc123
```

<Card title="Workflows (Alpha)" href="/routines/workflows-alpha">
  Learn the Workflow model and how it compares to functions.
</Card>
