> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apostra.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Register an agent

> Register a private sales or creative agent in your organization's Agents account with save_agent.

Call `save_agent` with no `agentId` to register a private agent in your
organization's Agents account. Name that account with `accountId` on the call
(see [Name the account on every call](https://docs.apostra.com/v3/name-the-account.md)). If your
organization does not have an Agents account, create it from the organization's
**Accounts** screen or with `save_account` in the organization account.

Supply a unique `idempotencyKey`. Repeating the exact request returns the
original agent with `created: false`. Registering records the agent's identity
only. It never publishes the agent, connects a source or asks for credentials.

You can register a **sales** or a **creative** agent this way. To set up a buyer
agent, use `save_buyer_agent` and see
[Buyer-agent credentials](https://docs.apostra.com/v2/setup/buyer-agent-credentials.md) instead.

> [!NOTE]
>
> This is available only to an account admin who is signed in as themselves.
> Service tokens and delegated sessions cannot register agents. See
> [Who can do what with an agent](https://docs.apostra.com/v3/connect-an-agent.md#who-can-do-what-with-an-agent).

## Register an agent

```json theme={null}
{
  "accountId": "ACCOUNT_ID",
  "kind": "creative",
  "displayName": "Acme Creative Agent",
  "operator": { "kind": "NEW", "displayName": "Acme" },
  "idempotencyKey": "20000000-0000-4000-8000-000000000003"
}
```

| Field | Required | Notes |
| - | - | - |
| `kind` | Yes | `sales` or `creative`. |
| `displayName` | Yes | The agent's name, 1 to 255 characters after trimming. |
| `salesMode` | No | Sales agents only: `WHOLESALE`, `COMPOSING` or `BOTH`. A sales agent you register without one is `WHOLESALE`. Sending it for a creative agent is refused. |
| `operator` | No | Who operates the agent. `{ "kind": "EXISTING", "operatorUid": "..." }` reuses a claimed operator your organization owns. `{ "kind": "NEW", "displayName": "..." }` creates one with the agent. Omit it to create an operator named after the agent. |
| `idempotencyKey` | Yes | A UUID. Reuse it only for the same request, to recover safely from an interrupted response. |

If you already run the agent, send its `agentUrl` instead of `kind` and
`displayName`: Apostra reads the agent and registers what it finds. An
`operator` cannot be sent with an `agentUrl`. See
[Connect an agent from its URL](https://docs.apostra.com/v3/connect-an-agent.md#connect-an-agent-from-its-url).
To register a proposal agent, which is registered from its URL so Apostra can
check that it answers proposal requests, see
[Connect your own proposal agent](https://docs.apostra.com/v3/connect-a-proposal-agent.md).

## What comes back

A new registration and an exact replay both return the agent in
`structuredContent`:

```json theme={null}
{
  "kind": "agent",
  "outcome": "developer_created",
  "object": {
    "agentId": "20000000-0000-4000-8000-000000000001",
    "displayName": "Acme Creative Agent",
    "role": "CREATIVE",
    "href": "/42/agents/20000000-0000-4000-8000-000000000001",
    "created": true
  }
}
```

`href` is a handoff target for the agent's page in the web app. It is not a
public agent URL. To open the page from a chat host, call `open_agent_page` with
the `agentId`.

## When a registration is refused

* The input is malformed: an empty name, a `salesMode` on a creative agent, or
  an `operator` that is not one of the two shapes. The error is
  `VALIDATION_FAILED` and names the field.
* The caller is not a signed-in admin of the Agents account, or the account
  named is not an Agents account. Name the organization's Agents account, or
  create one first.
* The requested existing operator is not owned and claimed by your organization.
* The `idempotencyKey` was used before with different input, or a `NEW`
  operator's name duplicates an active operator in your organization. Select the
  existing claimed operator instead.

See [Errors](https://docs.apostra.com/v3/errors.md) for the error contract.

## An operator Apostra mapped and nobody has claimed

Apostra sometimes maps a known operator to your organization before anyone on
your team claims it, for example from an audited legacy integration. An agent
behind a mapped but unclaimed operator is marked **Apostra mapped · unclaimed**
in My agents. It cannot receive production revisions, certification or new
connections until an organization admin claims it. Claiming keeps the
operator's identity, revisions, bindings and history. It never creates a second
copy.

`operator.kind: "EXISTING"` accepts only a claimed operator, because registering
a new agent under an unclaimed operator would duplicate an identity Apostra
already knows about. Claim the mapped operator first, then register the agent
under it. See
[Claim an agent Apostra mapped to your organization](https://docs.apostra.com/v3/connect-an-agent.md#claim-an-agent-apostra-mapped-to-your-organization).

## Open the registration from a chat host

`open_create_agent_task` opens the Connect an agent task for an account admin,
on the organization MCP surface. See
[Connect an agent in an Agents account](https://docs.apostra.com/v3/connect-an-agent.md#start-building)
for the task, and the other ways to start.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.