> Source: https://wexa.ai/docs/tools/update-process-flow

# update-process-flow

Add ONE new agent (skilled_agent, decider_agent or interop_agent — the external agent node — defaulting to skilled_agent) to an EXISTING process flow -- the tool equivalent of the UI's '+' button -- OR, if agent_id is given, EDIT an agent already in the process flow in place (a PARTIAL update: only the fields you include in `agent` change, everything else on that agent is left untouched). Positioning (add mode only): after_agent_id (existing agent id to insert after -- omit for a skilled agent to prepend it as the new initial agent; omit for a decider agent only on an empty flow) and add_on_side_if_decider (required when after_agent_id points at an existing DECIDER agent -- must be one of that decider's own condition names, and that branch must not already be wired). Unlike create-process-flow's manifest mode (which resolves next_agents against refs in the same call), this tool's agent.next_agents/agent.next values must be REAL EXISTING ids already in the project/flow -- fetch them via get-process-flow first if needed (edit mode doesn't support rewiring next/next_agents at all -- the backend has no such field on an in-place update; to rewire, remove and re-add). agent.skills is always real existing skill ids (there is no ref-resolution case, no manifest, and no way to create a skill through any Wexa tool) -- call list-skills first to find them. The one exception is agent.context_target_agent_ids: give agent TITLES as they appear in the flow, not ids -- this tool resolves them for you and returns a clear error listing which name(s) didn't match.

## What it is called on each surface

The wire name is `update-process-flow` everywhere: it is what the Wexa MCP server advertises, the REST path is
`POST /v1/update-process-flow`, and each SDK exposes it under its own language's naming convention.

| Surface | Name |
| --- | --- |
| Wexa MCP server | `update-process-flow` |
| REST API | `POST /v1/update-process-flow` |
| TypeScript SDK | `fabric.updateProcessFlow()` |
| Python SDK | `fabric.update_process_flow()` |

## Arguments

1 of the 6 arguments is required. Omitting a required one is refused before the tool runs, at the validation stage, so it costs nothing and changes nothing.

| Argument | Type | Required | Notes |
| --- | --- | --- | --- |
| `add_on_side_if_decider` | string | Optional | Required when after_agent_id points at an existing DECIDER agent -- must be one of that decider's own condition names, and that decision slot must not already be wired. |
| `after_agent_id` | string | Optional | Existing agent id to insert after. Omit for a skilled agent to prepend it as the new initial agent. Omit for a decider agent only when the flow is currently empty. Ignored when agent_id is set. |
| `agent` | object | Required | ADD mode (no agent_id): same shape as one manifest.agents[] entry, minus `ref` (there's only one agent) -- title is required, skills/next_agents/next must be real existing ids, not manifest refs. EDIT mode (agent_id set): title is NOT required -- include ONLY the fields you're changing, every omitted field is left untouched on the existing agent. Editable in this mode: title, role, role_description, prompt, llm, skills, context, has_knowledge_base, is_preview_mode_enabled, triggers, context_required, context_target_agent_ids, conditions (decider_agent only), context_access, agent_base_prompt, is_terminal_agent (skilled_agent only), is_user_specific_task (skilled_agent only), and registration_id (interop_agent only -- repointing an external agent node at a different peer agent connection). NOT editable in this mode -- omit these when agent_id is set, they have no effect: type (an agent's node type can't change after creation), next, next_agents (wiring an existing agent's position/branches isn't supported by an in-place edit; remove and re-add instead). |
| `agent_id` | string | Optional | Existing agent id to EDIT IN PLACE instead of adding a new agent. When given, `agent` is a PARTIAL update -- only the fields you include are changed; everything else on the existing agent stays as-is. after_agent_id/add_on_side_if_decider are ignored in this mode. Rewiring (next/next_agents) is NOT supported for an in-place edit -- only content/config fields (title, role, prompt, llm, skills, context_required, etc.) can be changed this way. Omit agent_id to add a new agent instead (the default). |
| `flow_name` | string | Optional | Lookup by exact flow name when id is unknown. Names are not unique; if several flows share it the call fails and lists their ids — pass process_flow_id instead. |
| `process_flow_id` | string | Optional | Process flow id. |

`project_id`, `projectID`, `organization_id` and `executed_by` are not arguments you pass: the
platform binds all four from the credential you authenticated with, and both SDKs refuse them
before the request leaves your process — see
[server-bound arguments](/docs/get-started/scope-and-server-bound-arguments).

## What it returns

The three surfaces wrap this differently, and code written against one will not read another
correctly — see [return shape](/docs/tools/overview#return-shape).

A real response, captured from a live call to `update-process-flow`:

`flow` came back populated and is shown as `…` here, because the real value runs to
thousands of characters. Read it from your own call rather than from this page.

**Result of update-process-flow**

**REST API**

```json
{
  "lifecycle_id": "qlc_000183",
  "result": {
    "agent_id": "6ab1968189fbbb1251ca6754",
    "flow": "\u2026",
    "process_flow_id": "6ab1945e7566f41b5c28e308"
  }
}
```

**Wexa MCP server**

```json
{
  "content": [
    {
      "type": "text",
      "text": "{\"lifecycle_id\":\"qlc_000183\",\"result\":{\"agent_id\":\"6ab1968189fbbb1251ca6754\",\"flow\":\"\\u2026\",\"process_flow_id\":\"6ab1945e7566f41b5c28e308\"}}"
    }
  ],
  "isError": false
}
```

**TypeScript SDK**

```ts
// the object you get back IS the result — there is no `.result` to read
{
  agent_id: '6ab1968189fbbb1251ca6754',
  flow: '…',
  process_flow_id: '6ab1945e7566f41b5c28e308'
}

// The TS SDK names these camelCase — lifecycleId, traceId — where Python uses
// lifecycle_id and trace_id. Both are non-enumerable: readable, but omitted by
// Object.keys() and JSON.stringify(). `result.lifecycleId` here is undefined.
result.lifecycleId // 'qlc_000183'
```

**Python SDK**

```python
# a dict subclass; `result` is already unwrapped
{
 "agent_id": "6ab1968189fbbb1251ca6754",
 "flow": "\u2026",
 "process_flow_id": "6ab1945e7566f41b5c28e308"
}

out.lifecycle_id  # 'qlc_000183' — an attribute, not a key
```

Keeping the `lifecycle_id` is what lets you ask later why a call was allowed, refused or held.

## Calling it

The same call on all four surfaces. Pick a tab once and every code block in the documentation follows it.

The ids in this example are real: they resolve against the project the documentation is written
against, so the call runs as written once you point it at your own deployment. Swap them for the
ids of your own objects.

**Call update-process-flow**

**Wexa MCP server**

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "update-process-flow",
    "arguments": {
      "agent": {"title": "Fixture Step Two", "role": "conversational", "role_description": "A second step the documentation cites.", "prompt": {"template": "Reply OK.", "display_template": "Reply OK."}, "has_knowledge_base": true, "context": ["docs-fixture"]}
    }
  }
}
```

**REST API**

```bash
curl -sS https://fabric.wexa.ai/v1/update-process-flow \
  -H "authorization: Bearer $FABRIC_API_KEY" \
  -H "content-type: application/json" \
  -d '{"agent":{"title": "Fixture Step Two", "role": "conversational", "role_description": "A second step the documentation cites.", "prompt": {"template": "Reply OK.", "display_template": "Reply OK."}, "has_knowledge_base": true, "context": ["docs-fixture"]}}'
```

**TypeScript SDK**

```ts
import { Fabric } from '@wexa-fabric/sdk'

const fabric = new Fabric()
const { result } = await fabric.updateProcessFlow({
  agent: {"title": "Fixture Step Two", "role": "conversational", "role_description": "A second step the documentation cites.", "prompt": {"template": "Reply OK.", "display_template": "Reply OK."}, "has_knowledge_base": true, "context": ["docs-fixture"]}
})
```

**Python SDK**

```python
from wexa import Fabric

fabric = Fabric()
out = fabric.update_process_flow(agent={"title": "Fixture Step Two", "role": "conversational", "role_description": "A second step the documentation cites.", "prompt": {"template": "Reply OK.", "display_template": "Reply OK."}, "has_knowledge_base": true, "context": ["docs-fixture"]})
```

## Errors

Both SDKs raise the same typed errors, chosen from the gateway's own error string first and its
HTTP status second. `update-process-flow` checks the `fabric:orchestrate.write` grant, and reaches the seven classes every
tool reaches — listed under [the common set](/docs/tools/errors#the-common-set). These are the ones specific to it:

| Error | Status | Raised when |
| --- | --- | --- |
| `NotFound` | 404 | `process_flow_id` matches no process flow in this project, or `agent_id` / `after_agent_id` no agent inside it. |
| `ApprovalRequired` | 202 | A policy held this call for a person to approve. The error carries the approval id; see below. |
| `ConfigurationError` | 5xx | `update-process-flow` is not available to you. Retrying will not help. |

## Governance

Every call to `update-process-flow` runs through the same ten-stage lifecycle as every other Wexa tool: the
credential is resolved to a scope, the `fabric:orchestrate.write` grant is checked, quota is drawn down, the arguments are
validated, policy rules are evaluated, the call is executed, the result is shaped and redacted, and an audit
record is written. The `lifecycle_id` in the response is the handle to that record.

`update-process-flow` is marked consequential, which means it changes something rather than only reading. Two things
follow. It is audited in full rather than lightly, and a policy rule may hold it for human approval — in which
case the call returns `202` and an `ApprovalRequired` error carrying the approval id, and the SDKs can wait for
the decision and resume rather than making you call again.

## See also

[The tool index](/docs/tools/overview), [errors](/docs/tools/errors),
and [which identifier goes where](/docs/tools/identifiers).
