# update()

Canonical URL: https://developers.iagenify.com/sdk/ref/workflow/update/
Language: en

`workflow.update(patch) → Promise<Workflow>`

Changes the workflow. What you send is validated as a whole definition — there is no patching of a single step.

Status: PUT · revalidated · object updates itself

```javascript
await workflow.update({ name: "Weekly digest (Monday)" });

await workflow.update({
  steps: workflow.data.steps.map((s) =>
    s.id === "write" ? { ...s, config: { ...s.config, model: "gemini-3.1-pro" } } : s),
});
```

## Send the whole thing you are changing {#whole}

> **steps replaces steps**
>
> Sending one step leaves the workflow with one step. Read data.steps, map it, send it back — which is also what keeps the edges valid, since they name step ids.

## Everything is checked again {#revalidated}

Templates, the graph, the required approvals, the tool names. A change that breaks a reference elsewhere is refused with `invalid_workflow`, and nothing is saved.

## Agent tools are serialised here too {#tools}

An `agent.run` step whose `tools` is an object is converted before it is sent, exactly as on create.

## Runs in flight keep the old definition {#running}

A run executes the definition it started with. Changing a workflow does not change what an in-flight run is doing — which is what makes an update safe on a busy workflow.

## It returns the workflow {#returns}

And replaces `data` on the object, so the instance you hold is current.

- [Workflow definition](/sdk/workflows): What a definition holds, and what is refused.
- [runStep()](/sdk/ref/workflow/run-step): Checking a change before saving it.

```python
workflow.update(name="Weekly digest (Monday)")

workflow.update(steps=[
    {**s, "config": {**s["config"], "model": "gemini-3.1-pro"}} if s["id"] == "write" else s
    for s in workflow.data["steps"]
])
```
