> Source: https://wexa.ai/docs/agents/delete-peer-agent

# delete-peer-agent

[Can be held for approval](/docs/sdks-and-apis/how-every-tool-call-works#lifecycle-and-governance)

Remove a peer agent connection. Get its `connection_id` from [list-peer-agents](/docs/agents/list-peer-agents) or [register-peer-agent](/docs/agents/register-peer-agent). Needs the `fabric:orchestrate.write` grant.

The shape of `result` for `delete-peer-agent` is not recorded here: it was not captured against a live deployment. Call it once and read what comes back rather than assuming a shape.

**Delete a peer agent**

**Wexa MCP server**

```bash
curl -sS -X POST https://fabric.wexa.ai/mcp/$FABRIC_PROJECT_ID \
  -H "authorization: Bearer $FABRIC_API_KEY" \
  -H "Mcp-Session-Id: $MCP_SESSION_ID" \
  -H "content-type: application/json" -H "accept: application/json" \
  -d '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"delete-peer-agent","arguments":{"connection_id":"6ab3e1c07f2d9a4b1c5e8d20"}}}'
```

**REST API**

```bash
curl -sS https://fabric.wexa.ai/v1/delete-peer-agent \
  -H "authorization: Bearer $FABRIC_API_KEY" \
  -H "content-type: application/json" \
  -d '{"connection_id":"6ab3e1c07f2d9a4b1c5e8d20"}'
```

**TypeScript SDK**

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

const fabric = new Fabric()
const result = await fabric.deletePeerAgent({
  connection_id: '6ab3e1c07f2d9a4b1c5e8d20'
})
```

**Python SDK**

```python
from wexa import Fabric

fabric = Fabric()
out = fabric.delete_peer_agent(connection_id="6ab3e1c07f2d9a4b1c5e8d20")
```

## Parameters

| Parameter | Type | Required | Notes |
| --- | --- | --- | --- |
| `connection_id` | string | Required | From `list-peer-agents` or `register-peer-agent`. A connection an `interop_agent` node still delegates to is not removed. |

**Errors**

- `UpstreamError` (502): an `interop_agent` node still delegates to the connection. The message names each agent and its process flow, and says nothing was removed. Retrying will not help until those nodes are repointed or removed.
- `UpstreamError` (502): the platform could not check which agents still reference the connection, so it was left in place.

**More details**

A connection that an `interop_agent` node still delegates to is not removed, so a running process flow is not broken by accident. The call fails with an error that names each such agent and its process flow, and nothing is removed. Repoint each of those nodes at another connection, or remove the node, then delete the connection. A refusal reads like this:

```
connection 6ab3e1c07f2d9a4b1c5e8d20 is still delegated to by "Match invoices" in process flow "Accounts payable" — repoint each one at another connection, or remove the node, then delete this connection. Nothing was removed.
```

There is no rotate operation. To change a connection's credential, register a new connection, repoint the nodes, then delete the old one; the steps are under [register-peer-agent](/docs/agents/register-peer-agent).

### Result fields

| Field | What it is |
| --- | --- |
| `connection_id` | The connection that was removed. |
| `deleted` | `true`. A connection that was not removed is an error, never a result. |
| `still_referenced_by` | Always empty on a result: a connection something still references is refused instead. |

Every tool call works the same way: [How every tool call works](/docs/sdks-and-apis/how-every-tool-call-works).
