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

# Promote an agent to another environment

> Copy a tested agent from one location of your organization to another, for example from xpander cloud to a production cluster. Later changes reach the copy only when you publish them, and secrets are never copied.

Your organization's [locations](https://docs.xpander.ai/run/locations.md) are its environments. A common setup uses **xpander cloud** as staging and a self-hosted cluster, for example **acme-prod-eks**, as production. **Promote** copies an agent from the location it runs in to another location in one step. The copy uses the connections and secrets of the target location. After that, a change to the agent reaches the copy only when you **Publish** it.

![Diagram](https://docs.xpander.ai/images/diagrams/use-agents-promote-27aef5f5.svg)

Every version number on these screens is the agent's own version, as Agent settings shows it. The examples on this page use the agent **Support**: it is promoted at version 1, edited to version 3, published, and then sent back to version 1.

## Before you start

* The target location is in your organization and shows **Connected** in **Platform > Agents > Runtime > Locations**. To add a self-hosted location, see [Locations and environments](https://docs.xpander.ai/run/locations.md#add-a-location).
* You can edit the agent. A person who can only view the agent sees where it runs, with no **Promote** or **Publish** button. The promote and publish calls answer `403` for them.
* The target location has its own connection for each skill connection the agent uses, for example **Salesforce production** for **Salesforce**. If it has none, you can remove that skill from the copy.

## Where the agent runs

Open the agent, then **Agent settings**. The **Environments** row is directly under **Access**. For an agent that was never promoted, it says **Runs in xpander cloud. Not promoted yet.**

![Environments row: Runs in xpander cloud. Not promoted yet. with a Promote button](https://mintcdn.com/xpanderai-099931d1/WvGKFO2B7MDZFb8d/images/use/promote/row-not-promoted.png?fit=max\&auto=format\&n=WvGKFO2B7MDZFb8d\&q=85\&s=2a8997c2576d813628c1562540ca3c39)

Agent settings > Environments, before the first promotion. Shown with sample data.

## Promote the agent

**1. Pick the location**

Click **Promote**. The list shows your organization's other locations, each with its name, type and address. The location the agent runs in is not in the list. A location that is not **Connected** is off and shows its status, for example **Setup incomplete** or **Unreachable**.

![Promote to list with acme-prod-eks and research-lab, which is off with the status Setup incomplete](https://mintcdn.com/xpanderai-099931d1/WvGKFO2B7MDZFb8d/images/use/promote/location-list.png?fit=max\&auto=format\&n=WvGKFO2B7MDZFb8d\&q=85\&s=a336bec0cc4e5da33a56ca3558956f8d)

The Promote list: acme-prod-eks can be picked, research-lab is off. Shown with sample data.

**2. Read what is copied**

The dialog **Promote Support to acme-prod-eks** says where the copy goes and lists under **Copied**, with their current values:

| Copied | What the copy gets |
| - | - |
| **Instructions and model** | The instructions and the model, as Agent settings names it |
| **Skills** | Every skill, except the skills of a connection you remove from the copy |
| **Mode and schedule** | Chat or autonomous, and the agent's schedules |

A grey **Not copied** line names what stays on the source. See [What is not copied](#what-is-not-copied).

**3. Map each connection**

The **Connections** table lists each connection the agent uses, with a picker of the target location's connections for the same skill, and **Remove from copy**.

A connection is picked for you only in two cases: you promoted this agent to this location before, or the target location has only one connection for that skill. A connection with no pick has a red dot and the red line **Pick a connection for Salesforce, or remove the Salesforce skill in the copy.** **Promote** stays off until every connection is mapped or removed.

![Promote Support to acme-prod-eks dialog with Copied, Not copied: Support handbook, Slack, and Salesforce marked with a red dot and Pick a connection](https://mintcdn.com/xpanderai-099931d1/WvGKFO2B7MDZFb8d/images/use/promote/promote-unmapped.png?fit=max\&auto=format\&n=WvGKFO2B7MDZFb8d\&q=85\&s=3cdb84336bd97cc0a72b3852bfe179ad)

Salesforce has no pick yet, so Promote is off. Shown with sample data.

**Remove from copy** takes the connection and its skills off the copy. The **Skills** row then says what was removed in the copy.

If the agent has two connections for one skill, map both to the same connection in the target location. The copy uses one connection per skill.

**4. Promote**

When every connection is mapped or removed, the grey line **Secrets are never copied. acme-prod-eks uses its own.** shows and **Promote** turns on. Click **Promote**.

![Promote dialog with Salesforce mapped to Salesforce production and the Promote button on](https://mintcdn.com/xpanderai-099931d1/WvGKFO2B7MDZFb8d/images/use/promote/promote-mapped.png?fit=max\&auto=format\&n=WvGKFO2B7MDZFb8d\&q=85\&s=5286a41f7b3a717bdcb1c33d71694faf)

Every connection is mapped, so Promote is on. Shown with sample data.

An agent with the same name now exists in acme-prod-eks. It runs version 1 with the connections you picked. The agent in xpander cloud does not change. The **Environments** row says **Runs in xpander cloud. acme-prod-eks runs version 1.**

![Environments row: Runs in xpander cloud. acme-prod-eks runs version 1.](https://mintcdn.com/xpanderai-099931d1/WvGKFO2B7MDZFb8d/images/use/promote/row-promoted.png?fit=max\&auto=format\&n=WvGKFO2B7MDZFb8d\&q=85\&s=3559fedd001dd859502d5c9f45444e2a)

Agent settings > Environments after the promotion. Shown with sample data.

The copy runs in acme-prod-eks as any agent there runs: chats and tool calls in that location use its connections, not the ones of the source. This works for a self-hosted location with no outbound internet too: the control plane writes the copy, and the location runs it.

An agent has at most one copy in each location. In the **Promote** list, a location the agent is already promoted to shows **Promoted** in grey, and picking it opens **Publish**. A second promote to the same location answers `409`.

## Publish changes

An edit to the source agent does not change the copy. Nothing publishes on its own. After two edits (version 2 edits the instructions, version 3 adds the Jira skill), the row says **acme-prod-eks runs version 1. 2 changes are not published.** with a **Publish** button.

![Environments row: acme-prod-eks runs version 1. 2 changes are not published. with Publish and Promote buttons](https://mintcdn.com/xpanderai-099931d1/WvGKFO2B7MDZFb8d/images/use/promote/row-pending.png?fit=max\&auto=format\&n=WvGKFO2B7MDZFb8d\&q=85\&s=d3f5fd75a5099cb919af944ede4bab98)

Two changes are not published yet. Shown with sample data.

Click **Publish**. The dialog **Publish 2 changes to acme-prod-eks** shows:

* **Version to publish**, the latest version by default.
* **Changes**: each change since the version the copy runs, with who made it and when, for example **Version 3 · Added skill Jira** and **Version 2 · Edited instructions**.
* The line **acme-prod-eks moves from version 1 to version 3. You can publish version 1 again to go back.**

![Publish dialog with Version 3 latest, the change list and the line acme-prod-eks moves from version 1 to version 3](https://mintcdn.com/xpanderai-099931d1/WvGKFO2B7MDZFb8d/images/use/promote/publish-changes.png?fit=max\&auto=format\&n=WvGKFO2B7MDZFb8d\&q=85\&s=ef1193ba5e7fdf29ad040132f3b99fee)

Publish 2 changes to acme-prod-eks. Shown with sample data.

A change that adds a connection asks for a connection under **New connections**, with the same rules as Promote: pick one in the target location or remove it from the copy. **Publish** stays off until each one is mapped or removed.

![Publish dialog with New connections: Jira with a red dot and the line Pick a connection for Jira, or remove the Jira skill in the copy.](https://mintcdn.com/xpanderai-099931d1/WvGKFO2B7MDZFb8d/images/use/promote/publish-new-connection.png?fit=max\&auto=format\&n=WvGKFO2B7MDZFb8d\&q=85\&s=600c528b83ab2ca41ec132fa9c7848ea)

The new Jira skill needs a connection in acme-prod-eks. Shown with sample data.

Click **Publish**. The copy runs version 3, and the row says **acme-prod-eks runs version 3.** A chat with the copy shows the new behavior.

## Go back to an earlier version

Open **Publish** and pick an earlier version in **Version to publish**, for example **Version 1**. The dialog is titled **Publish version 1 to acme-prod-eks** and says **acme-prod-eks goes back to version 1.** Click **Publish**.

![Publish version 1 to acme-prod-eks dialog with the line acme-prod-eks goes back to version 1.](https://mintcdn.com/xpanderai-099931d1/WvGKFO2B7MDZFb8d/images/use/promote/publish-go-back.png?fit=max\&auto=format\&n=WvGKFO2B7MDZFb8d\&q=85\&s=cb28f61281087beddce5634eb6dc4367)

Go back: publish version 1 again. Shown with sample data.

The copy runs version 1 again. The row says **acme-prod-eks runs version 1. 2 changes are not published.**, because versions 2 and 3 are on the source and not on the copy.

## Direct edits on the copy are replaced

The source agent is the one you edit. If someone edits the copy directly in the target location, the next publish replaces that edit. The **Publish** dialog warns with the grey line **Direct edits on the copy in acme-prod-eks will be replaced.**

![Publish dialog with the grey line Direct edits on the copy in acme-prod-eks will be replaced.](https://mintcdn.com/xpanderai-099931d1/WvGKFO2B7MDZFb8d/images/use/promote/publish-direct-edits.png?fit=max\&auto=format\&n=WvGKFO2B7MDZFb8d\&q=85\&s=cc8cbed13d922f70d46ffad246dc2eed)

Someone edited the copy in acme-prod-eks. Shown with sample data.

To keep a change, make it on the source agent and publish it.

## What is not copied

| Not copied | What to do in the target location |
| - | - |
| **Secrets**, including a model key set on the agent | Never copied. The copy uses the target location's connections and the secrets behind them. No secret value is in the requests, the responses, the stored promotion or the audit events, and the organization's Vault does not change. |
| **Sub-agents** and workflows the agent calls | Promote each one by itself, or add the target location's own to the copy. |
| **Knowledge bases** | Attach a knowledge base of the target location to the copy. |
| **Channel bindings**, such as Slack, Microsoft Teams, Telegram, WhatsApp, email and webhook addresses | Connect the copy to its channels in the target location. The API, MCP, A2A and xpander Chat entry points stay on the copy. |
| **Credentials typed into an MCP skill** on the agent (API key, client secret, headers, literal environment values) | The MCP skill is copied without them. Enter them again on the copy. A `${NAME}` reference to a secret is copied as the reference; save the secret on the copy in the target location. |

The **Promote** dialog names what stays on the source in its grey **Not copied** line, for example **Not copied: Support handbook, Slack.**

## Audit events

Each promotion and each publish writes an event to **Platform > AI governance > Audit log**. See [Audit and debugging](https://docs.xpander.ai/use/agents/audit.md).

| Event | Raw type | Records |
| - | - | - |
| **Agent promoted** | `agent_promoted` | Who, the agent, from location, to location, the version, the mapped connections (and the ones removed from the copy), `secrets_copied: 0` and the copy's id |
| **Agent published** | `agent_published_to_environment` | Who, the agent, the location, from version and to version (also for a go-back), the mapped new connections, `secrets_copied: 0` and the copy's id |

**Open agent in acme-prod-eks** on the event opens the copy, not the source agent.

![Agent promoted event: Dana Levi promoted Support from xpander cloud to acme-prod-eks, version 1, with Open agent in acme-prod-eks, the mapped connections and Secrets copied 0](https://mintcdn.com/xpanderai-099931d1/WvGKFO2B7MDZFb8d/images/use/promote/audit-promoted.png?fit=max\&auto=format\&n=WvGKFO2B7MDZFb8d\&q=85\&s=df4988afc7188c69846a7aa2a566a92b)

Agent promoted. Shown with sample data.

![Agent published event: Dana Levi published Support to acme-prod-eks, version 1 to version 3](https://mintcdn.com/xpanderai-099931d1/WvGKFO2B7MDZFb8d/images/use/promote/audit-published.png?fit=max\&auto=format\&n=WvGKFO2B7MDZFb8d\&q=85\&s=3f0a1a7ba004c28c4a0ec4af63dc6f57)

Agent published. Shown with sample data.

## API

xpander Chat uses these routes of the agents API. Each call acts for a signed-in person: a call with an organization key that no person owns answers `403`. Listing, previewing, promoting and publishing need the right to edit the agent; reading its promotions needs the right to use it.

| Method and path | What it does |
| - | - |
| `GET /agents/{agent_id}/promote/targets` | The organization's other locations, each with its status and, when the agent is promoted there, the version the copy runs |
| `GET /agents/{agent_id}/promote/{environment_id}/preview` | What a promotion copies, what is not copied, and for each connection the candidates in the target location and the pre-selected one |
| `POST /agents/{agent_id}/promote` | Promote. Body: `environment_id` and `connection_mapping` |
| `GET /agents/{agent_id}/promotions` | Each promoted location: the copy, the version it runs and how many changes are not published |
| `GET /agents/{agent_id}/promotions/{environment_id}/changes` | The changes since the version the copy runs, the new connections to map, and whether the copy was edited directly |
| `POST /agents/{agent_id}/promotions/{environment_id}/publish` | Publish a later or an earlier version. Body: `source_version` and `connection_mapping` |

`connection_mapping` maps each source connection id to a connection id in the target location, or to `"remove"` to take it off the copy:

```json theme={"dark"}
{
  "environment_id": "22222222-2222-4222-8222-222222222222",
  "connection_mapping": {
    "c-sf-stg": "c-sf-prod",
    "c-zd-stg": "remove"
  }
}
```

| Answer | When |
| - | - |
| `403` | The caller cannot edit the agent, or is not a person |
| `404` | No such location in the organization, or, on publish, the agent is not promoted there or the copy is gone. Promote it again. |
| `409` | The location is not connected (`Location acme-prod-eks is not connected.`), the agent already runs there, the agent is already promoted there, or another publish to the same location is running |
| `422` | A connection has no mapping, or the version to publish is a draft |

## Next steps

> [card] [Add a location](https://docs.xpander.ai/run/locations.md)
>
> Connect a self-hosted cluster to promote to.

> [card] [Read the audit log](https://docs.xpander.ai/use/agents/audit.md)
>
> Find every promotion and publish.


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