> Source: https://wexa.ai/docs/tools/register-peer-agent

# register-peer-agent

Register an external agent on another platform as a peer agent connection, so that a process flow can hand a
whole goal to it. It returns the `connection_id` that an `interop_agent` node, the external agent node, points
at: it goes on the node as `registration_id`.

Test the endpoint first with [`handshake-peer-agent`](/docs/tools/handshake-peer-agent). Registration runs
its own handshake as well, and records what the external agent says about itself;
[`list-peer-agents`](/docs/tools/list-peer-agents) shows it afterwards.

The `name` must be unique within the project. It is the only thing telling two connections apart anywhere a
person looks, so a second connection with the same name is refused and nothing is created.

The `secret` is supplied once, here, and no tool returns it afterwards, in any form. There is no rotate
operation: to change the credential, delete the connection with
[`delete-peer-agent`](/docs/tools/delete-peer-agent) and register it again.

This registers the console's "single peer agent" connection type, which takes a whole goal. The console's
other type, a tool catalog, is a different concept and is not created here.

## What it is called on each surface

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

| Surface | Name |
| --- | --- |
| Wexa MCP server | `register-peer-agent` |
| REST API | `POST /v1/register-peer-agent` |
| TypeScript SDK | `fabric.registerPeerAgent()` |
| Python SDK | `fabric.register_peer_agent()` |

## Arguments

3 of the 7 arguments are 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 |
| --- | --- | --- | --- |
| `name` | string | Required | Unique within this project. |
| `endpoint` | string | Required | The external agent's full http:// or https:// URL. |
| `protocol` | string | Required | `mcp` or `a2a` — which protocol the external agent speaks. |
| `secret` | string | Optional | The bearer token or API key. Supplied once, here; no tool ever returns it. |
| `description` | string | Optional | A description of the connection. |
| `platform` | string | Optional | A label for which platform this agent runs on. |
| `auth` | string | Optional | `key`, `oauth` or `mtls`. Default `key`. |

A `protocol` other than `mcp` or `a2a` is refused, and the refusal names both.

`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

| Field | What it is |
| --- | --- |
| `connection_id` | The id an `interop_agent` node takes as `registration_id`. |
| `name`, `protocol`, `endpoint` | What you registered. |
| `state` | `Draft` when registered, `Active` once a call to the external agent has gone through. |

The secret is not in the result.

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

An example of what `register-peer-agent` returns. Every field shown is one the tool really sets: the
shape was checked against a live call to a running deployment. The ids, endpoints and
names are illustrative, so swap them for your own.

**Result of register-peer-agent**

**REST API**

```json
{
  "lifecycle_id": "qlc_000064",
  "result": {
    "connection_id": "6ab3e1c07f2d9a4b1c5e8d20",
    "name": "invoice-reconciler",
    "protocol": "a2a",
    "endpoint": "https://agents.example.com/a2a/invoice-reconciler",
    "state": "Draft"
  }
}
```

**Wexa MCP server**

```json
{
  "content": [
    {
      "type": "text",
      "text": "{\"lifecycle_id\":\"qlc_000064\",\"result\":{\"connection_id\":\"6ab3e1c07f2d9a4b1c5e8d20\",\"name\":\"invoice-reconciler\",\"protocol\":\"a2a\",\"endpoint\":\"https://agents.example.com/a2a/invoice-reconciler\",\"state\":\"Draft\"}}"
    }
  ],
  "isError": false
}
```

**TypeScript SDK**

```ts
// the object you get back IS the result — there is no `.result` to read
{
  "connection_id": "6ab3e1c07f2d9a4b1c5e8d20",
  "name": "invoice-reconciler",
  "protocol": "a2a",
  "endpoint": "https://agents.example.com/a2a/invoice-reconciler",
  "state": "Draft"
}

// 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_000064'
```

**Python SDK**

```python
# a dict subclass; `result` is already unwrapped
{
 "connection_id": "6ab3e1c07f2d9a4b1c5e8d20",
 "name": "invoice-reconciler",
 "protocol": "a2a",
 "endpoint": "https://agents.example.com/a2a/invoice-reconciler",
 "state": "Draft"
}

out.lifecycle_id  # 'qlc_000064' — 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.

A value in angle brackets is one only you can supply, and the platform refuses a literal `<...>`.

**Call register-peer-agent**

**Wexa MCP server**

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "register-peer-agent",
    "arguments": {
      "name": "invoice-reconciler",
      "endpoint": "https://agents.example.com/a2a/invoice-reconciler",
      "protocol": "a2a",
      "secret": "<the external agent's token>"
    }
  }
}
```

**REST API**

```bash
curl -sS https://fabric.wexa.ai/v1/register-peer-agent \
  -H "authorization: Bearer $FABRIC_API_KEY" \
  -H "content-type: application/json" \
  -d '{"name":"invoice-reconciler","endpoint":"https://agents.example.com/a2a/invoice-reconciler","protocol":"a2a","secret":"<the external agent's token>"}'
```

**TypeScript SDK**

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

const fabric = new Fabric()
const result = await fabric.registerPeerAgent({
  name: "invoice-reconciler",
  endpoint: "https://agents.example.com/a2a/invoice-reconciler",
  protocol: "a2a",
  secret: "<the external agent's token>"
})
```

**Python SDK**

```python
from wexa import Fabric

fabric = Fabric()
out = fabric.register_peer_agent(
    name="invoice-reconciler",
    endpoint="https://agents.example.com/a2a/invoice-reconciler",
    protocol="a2a",
    secret="<the external agent's token>",
)
```

## Errors

Both SDKs raise the same typed errors, chosen from the gateway's own error string first and its
HTTP status second. `register-peer-agent` 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 |
| --- | --- | --- |
| `ValidationError` | 422 | `name` or `endpoint` is missing, or `protocol` is not `mcp` or `a2a`. |
| `UpstreamError` | 502 | A peer agent connection with this `name` already exists in the project. The message says so and that nothing was created. Retrying will not help: pick a different name. |
| `ApprovalRequired` | 202 | A policy held this call for a person to approve. The error carries the approval id; see below. |
| `ConfigurationError` | 5xx | `register-peer-agent` is not available to you. Retrying will not help. |

## Governance

Every call to `register-peer-agent` runs through the same ten-stage lifecycle as every other 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.

`register-peer-agent` 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

[`handshake-peer-agent`](/docs/tools/handshake-peer-agent) to test the endpoint first,
[`list-peer-agents`](/docs/tools/list-peer-agents),
[`delete-peer-agent`](/docs/tools/delete-peer-agent),
[`create-process-flow`](/docs/tools/create-process-flow) for the external agent node,
[the tool index](/docs/tools/overview), [errors](/docs/tools/errors),
and [which identifier goes where](/docs/tools/identifiers).
