---
title: "Workflows hooks"
description: "Hand-written shim. Generated CRUD via ./workflows.gen. The hooks below
cover the workflow-run sub-resource and graph-replace mutation that the
manifest pipeline doesn't model."
section: "Libraries"
group: "React hooks"
order: 474
---

## Hooks

### `useCreateWorkflow` `mutation`

Create a workflow.

```ts
useCreateWorkflow(options?: MutationOpts<Workflow, CreateWorkflowParams>)
```

**Types:** [Workflow](/types/workflow) · [CreateWorkflowParams](/types/create-workflow-params)

### `useDeleteWorkflow` `mutation`

Soft-delete a workflow.

```ts
useDeleteWorkflow(options?: MutationOpts<SuccessResponse, string>)
```

**Types:** [SuccessResponse](/types/success-response)

### `useGetWorkflowRun` `query`

Fetch a single workflow run by workflow and run ID.

```ts
useGetWorkflowRun(workflowId: string, runId: string, options?: QueryOpts<WorkflowRun>)
```

**Types:** [WorkflowRun](/types/workflow-run)

```ts
const { data: run } = useGetWorkflowRun("wfl_abc123", "run_abc123");
```

### `useListWorkflows` `query`

List workflows.

```ts
useListWorkflows(params?: Omit<ListWorkflowsParams, | > & { filter?: WorkflowFilter; orderBy?: WorkflowOrderBy[]; } & WorkflowShorthands, options?: QueryOpts<Page<Workflow>>)
```

**Types:** [ListWorkflowsParams](/types/list-workflows-params) · [WorkflowFilter](/types/workflow-filter) · [WorkflowOrderBy](/types/workflow-order-by) · [WorkflowShorthands](/types/workflow-shorthands) · [Page](/types/page) · [Workflow](/types/workflow)

### `usePurgeWorkflow` `composite`

Permanently delete a soft-deleted workflow.

```ts
usePurgeWorkflow(options?: MutationOpts<SuccessResponse, PurgeWorkflowParams>)
```

**Types:** [SuccessResponse](/types/success-response) · [PurgeWorkflowParams](/types/purge-workflow-params)

### `usePutWorkflowGraph` `composite`

Replace the entire graph (nodes + edges) of a workflow.
Auto-invalidates workflow queries.

```ts
usePutWorkflowGraph(options?: MutationOpts<Workflow, PutWorkflowGraphParams>)
```

**Types:** [Workflow](/types/workflow)

```ts
const put = usePutWorkflowGraph();
put.mutate({ id: "wfl_abc123", nodes: [...], edges: [...] });
```

### `useRestoreWorkflow` `composite`

Restore a soft-deleted workflow.

```ts
useRestoreWorkflow(options?: MutationOpts<Workflow, string>)
```

**Types:** [Workflow](/types/workflow)

### `useRetrieveWorkflow` `query`

Get a workflow by ID.

```ts
useRetrieveWorkflow(id: string, options?: QueryOpts<Workflow>)
```

**Types:** [Workflow](/types/workflow)

### `useStartWorkflowRun` `composite`

Start a new run for a workflow. Auto-invalidates workflow and run queries.

```ts
useStartWorkflowRun(options?: MutationOpts<Run, StartWorkflowRunParams>)
```

**Types:** [Run](/types/run)

```ts
const start = useStartWorkflowRun();
start.mutate({ workflowId: "wfl_abc123", input: {} });
```

### `useUpdateWorkflow` `mutation`

Update a workflow.

```ts
useUpdateWorkflow(options?: MutationOpts<Workflow, UpdateWorkflowParams>)
```

**Types:** [Workflow](/types/workflow) · [UpdateWorkflowParams](/types/update-workflow-params)

### `useWorkflowRunAction` `composite`

Perform an action on a workflow run (pause, resume, retry, cancel).
Auto-invalidates workflow and run queries.

```ts
useWorkflowRunAction(options?: MutationOpts<Run, WorkflowRunActionParams>)
```

**Types:** [Run](/types/run)

```ts
const act = useWorkflowRunAction();
act.mutate({ runId: "run_abc123", action: "cancel" });
```
