> ## 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.

# workflows diagram

> Render a workflow's current graph as a Mermaid flowchart.

Render a workflow's current graph as a Mermaid `flowchart TD` diagram. Pipe the `diagram` string to any Mermaid renderer — GitHub, [mermaid.live](https://mermaid.live), or the mermaid CLI — to view the workflow.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
clay workflows diagram <workflowId>
```

## Arguments

| Argument     | Description                              |
| ------------ | ---------------------------------------- |
| `workflowId` | Workflow id, e.g. `wf_abc123`. Required. |

## Output

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "format": "mermaid",
  "diagram": "flowchart TD\n  ..."
}
```

| Field     | Type        | Description                                     |
| --------- | ----------- | ----------------------------------------------- |
| `format`  | `"mermaid"` | Always `"mermaid"`.                             |
| `diagram` | string      | Mermaid `flowchart TD` source for the workflow. |

Node shapes encode the node type: trigger uses a stadium, agent a rectangle, tool a rounded box, code a subroutine, conditional a diamond, map/fork/join a hexagon, reduce a cylinder, and collect a circle. Edges leaving a conditional node are labelled with their branch handle.

## Errors

| Code               | Exit | Notes                                                   |
| ------------------ | ---- | ------------------------------------------------------- |
| `validation_error` | 2    | `workflowId` argument is required.                      |
| `not_found`        | 6    | No workflow or snapshot with that id in this workspace. |
| `auth_forbidden`   | 3    | The API key lacks permission for this command.          |

## Examples

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
clay workflows diagram wf_abc123
clay workflows diagram wf_abc123 | jq -r '.diagram' > workflow.mmd
```
