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

# The deployment pipeline

> Manage versions, testing, and deploying updates.

<div className="simplified-only">
  Two environments on Agent Builder: **Sandbox**, where your changes land for testing, and **Live**, where real callers reach your agent. You publish a version into Sandbox, test it, then promote it to Live when you're happy.

  ```mermaid theme={"theme":{"light":"github-light","dark":"github-dark"}}
  stateDiagram-v2
      [*] --> Draft: Make changes
      Draft --> Sandbox: Publish
      Sandbox --> Live: Promote

      Live --> Sandbox: Rollback

      note right of Draft: Edits in progress
      note right of Sandbox: Testing
      note right of Live: Production
  ```

  <Warning>
    **Publishing isn't the same as going live.** Drafts must be **published** to Sandbox first. They only reach your callers when you **promote** to Live.
  </Warning>

  ## Publish a draft to Sandbox

  Whenever you make changes (via Agent Builder or directly), a draft banner appears at the top of the page with two options:

  * **Delete** reverts to the most recent published version.
  * **Publish** saves the draft as a version. Add a short description if you want a note for future you.

  <Frame caption="Removing a draft from a version line">
    <img src="https://mintcdn.com/polyai/5TqB0Il1JYn5J7QH/images/deployment/draft-line.png?fit=max&auto=format&n=5TqB0Il1JYn5J7QH&q=85&s=7180c593cf44b6e80b98308c6b075eff" alt="delete-publish" style={{ maxWidth: '720px', width: '100%', margin: '0 auto', display: 'block' }} width="3008" height="912" data-path="images/deployment/draft-line.png" />
  </Frame>

  Once published, the version becomes your active **Sandbox** deployment. Find it under **Deployments** in the sidebar.

  ## Test in Sandbox

  Click **Test** in the top-right of any page to open the Agent Debugging panel. Choose **Call agent** or **Webchat**, pick **Sandbox** from the environment dropdown, and try the scenario you're worried about. Every test call lands in [Conversations](/analytics/conversations/introduction) with a transcript.

  If something looks off, the [iterate-after-a-call](/learn/iterate-open-platform) flow walks through fixing it.

  ## Promote to Live

  When the Sandbox version handles real scenarios properly, promote it.

  1. Open **Deployments** in the sidebar.
  2. In the **Sandbox** tab, click the overflow menu (three dots) next to the version.
  3. Select **Promote to Live**.
  4. Tick the confirmation box and click **Promote**.

  <Frame caption="Deployments page in Agent Builder mode showing the Sandbox tab with a list of published versions">
    <img src="https://mintcdn.com/polyai/3x0H8UF7m563JYpi/images/deployment/op-deployments-list.png?fit=max&auto=format&n=3x0H8UF7m563JYpi&q=85&s=421897fa0d0d1edb15da7d2b4a0a212d" alt="Deployments page in Agent Builder mode showing the Sandbox tab with a list of published versions" style={{ maxWidth: '720px', width: '100%', margin: '0 auto', display: 'block' }} width="3012" height="1514" data-path="images/deployment/op-deployments-list.png" />
  </Frame>

  <Frame caption="Promote version live confirmation modal with an 'I understand and wish to continue' checkbox and a Promote button">
    <img src="https://mintcdn.com/polyai/3x0H8UF7m563JYpi/images/deployment/op-promote-to-live.png?fit=max&auto=format&n=3x0H8UF7m563JYpi&q=85&s=305cc939a96ae65536803a4b07487a20" alt="Promote version live confirmation modal warning that the version will receive live customer traffic, with an 'I understand and wish to continue' checkbox and a Promote button" style={{ maxWidth: '720px', width: '100%', margin: '0 auto', display: 'block' }} width="2494" height="1098" data-path="images/deployment/op-promote-to-live.png" />
  </Frame>

  Once it's Live, every new caller (via Web Calling, the shareable link, or anywhere else you've placed the agent) hits the promoted version immediately.

  ## Roll back

  If a Live version is causing problems, roll back.

  1. Open **Deployments > Live** in the sidebar.
  2. Open the overflow menu on the version you want to roll back.
  3. Click **Rollback**, then confirm.

  The previous version becomes Live again. You can promote forward whenever you're ready.

  ## Compare versions

  Side-by-side diffs let you check what changed between two versions before you promote. Open **Deployments** or **Project History**, select a version, and click **Compare**. Sorting is newest-first.

  <Frame caption="Version comparison view showing two deployments side by side with line-level diffs across Functions, Variables, Flows, and other agent settings">
    <img src="https://mintcdn.com/polyai/3x0H8UF7m563JYpi/images/deployment/op-version-comparison.png?fit=max&auto=format&n=3x0H8UF7m563JYpi&q=85&s=35f6a29f401936f0cae4f3e913df7d84" alt="Version comparison view showing two deployments side by side with line-level diffs across Functions, Variables, Flows, and other agent settings" style={{ maxWidth: '720px', width: '100%', margin: '0 auto', display: 'block' }} width="2512" height="1500" data-path="images/deployment/op-version-comparison.png" />
  </Frame>

  [Tracking changes →](/environments-and-versions/diffs)
</div>

<div className="full-only">
  Test agent changes before they reach live callers. Draft → Sandbox → Pre-release → Live.

  <Note>
    **New to environments?** Start with the [Environments tutorial](/learn/guides/get-started/environments) for a hands-on introduction. For detailed workflows and best practices, see [Version management](/learn/maintain/version-management).
  </Note>

  <Warning>
    **Saving is not the same as going live.** Saved changes are drafts. Drafts must be **published** to Sandbox, then **promoted** through Pre-release to Live. Unpublished changes don't appear in any environment.
  </Warning>

  ```mermaid theme={"theme":{"light":"github-light","dark":"github-dark"}}
  stateDiagram-v2
      [*] --> Draft: Make changes
      Draft --> Sandbox: Publish
      Sandbox --> PreRelease: Promote
      PreRelease --> Live: Promote
      
      Live --> PreRelease: Rollback
      PreRelease --> Sandbox: Rollback
      
      note right of Draft: Development
      note right of Sandbox: Testing
      note right of PreRelease: UAT staging
      note right of Live: Production
  ```

  ## Creating a version

  A <Tooltip tip="The state between the latest published version and ongoing changes. Drafts become versions upon publishing.">draft</Tooltip> version
  is created whenever changes are made to an agent. A draft banner appears at the top of the page, allowing you to:

  * **Delete**: Revert to the most recent published version.

  * **Publish**: Save the draft as a version, optionally adding a description highlighting changes made and any notes for future
    collaborators.

  <Frame caption="Removing a draft from a version line">
    <img src="https://mintcdn.com/polyai/5TqB0Il1JYn5J7QH/images/deployment/draft-line.png?fit=max&auto=format&n=5TqB0Il1JYn5J7QH&q=85&s=7180c593cf44b6e80b98308c6b075eff" alt="delete-publish" style={{ maxWidth: '720px', width: '100%', margin: '0 auto', display: 'block' }} width="3008" height="912" data-path="images/deployment/draft-line.png" />
  </Frame>

  Once published, the version becomes your active <Tooltip tip="Development environment where users build, change, and test versions of an agent.">Sandbox</Tooltip> deployment
  and you can access it from **Deployments > Environments** in the sidebar.

  <Frame caption="Promoting a version across environments">
    <img src="https://mintcdn.com/polyai/5TqB0Il1JYn5J7QH/images/deployment/publish.png?fit=max&auto=format&n=5TqB0Il1JYn5J7QH&q=85&s=a14b7586e810487d51cf3f36d7ac6f57" alt="active-publish" style={{ maxWidth: '720px', width: '100%', margin: '0 auto', display: 'block' }} width="2996" height="1194" data-path="images/deployment/publish.png" />
  </Frame>

  ## Promoting a version

  Promotion moves a version from one environment to the next. The environments include Sandbox,
  <Tooltip tip="A staging environment for user acceptance testing (UAT) before promoting to production.">Pre-release</Tooltip>,
  and <Tooltip tip="The production environment. This is where the agent handles live traffic.">Live</Tooltip>.

  ### Pre-release

  Staging environment for user acceptance testing (UAT).

  1. Go to **Deployments > Environments** in the sidebar.

  2. Click the **Options Menu** next to the desired version.

  3. Select **Promote to Pre-release**.

  ### Live

  Production. Changes affect all active calls immediately.

  1. Go to the **Pre-release** tab in **Deployments > Environments**.

  2. Click the overflow menu (three vertical dots) next to the version.

  3. Select **Promote to Live**.

  4. Confirm your selection by checking the box and clicking **Promote**.

  <Tabs>
    <Tab title="Confirm">
      <Frame caption="initiate release">
        <img src="https://mintcdn.com/polyai/5TqB0Il1JYn5J7QH/images/deployment/initiate-release.png?fit=max&auto=format&n=5TqB0Il1JYn5J7QH&q=85&s=ae0808b47d34e08a0b35310d33533c40" alt="initiate release" style={{ maxWidth: '720px', width: '100%', margin: '0 auto', display: 'block' }} width="2990" height="1402" data-path="images/deployment/initiate-release.png" />
      </Frame>
    </Tab>

    <Tab title="Complete">
      <Frame caption="release confirmed and live">
        <img src="https://mintcdn.com/polyai/5TqB0Il1JYn5J7QH/images/deployment/release-confirmed.png?fit=max&auto=format&n=5TqB0Il1JYn5J7QH&q=85&s=c3cd3a16140c6dfae7645f08a6ad5970" alt="release confirmed and live" style={{ maxWidth: '720px', width: '100%', margin: '0 auto', display: 'block' }} width="2486" height="888" data-path="images/deployment/release-confirmed.png" />
      </Frame>
    </Tab>
  </Tabs>

  ## Comparing versions and environments

  Before promoting changes, you can compare versions across environments using a side-by-side diff view.

  1. Go to the **Deployments** section and open **Environments** or **Project History**.

  2. Select a version and click **Compare** to view differences between **Sandbox**, **Pre-release**, and **Live**.

  3. Versions appear in **reverse chronological order** (newest first) for easier navigation.

  For detailed information on tracking changes between versions, see [Tracking changes](/environments-and-versions/diffs).

  ## Rolling back to a previous version

  Roll back to a previous version if needed:

  1. Go to **Deployments > Environments** in the sidebar.

  2. Select the **Options Menu** for the desired version.

  3. Click **Rollback**.

  4. Confirm the rollback.

  The system confirms when the rollback is complete.

  <Tabs>
    <Tab title="Initiate">
      <Frame caption="initiate rollback">
        <img src="https://mintcdn.com/polyai/5TqB0Il1JYn5J7QH/images/deployment/initiate-rollback.png?fit=max&auto=format&n=5TqB0Il1JYn5J7QH&q=85&s=67798e6444ee259482d374847a28b657" alt="initiate rollback" style={{ maxWidth: '720px', width: '100%', margin: '0 auto', display: 'block' }} width="3006" height="1456" data-path="images/deployment/initiate-rollback.png" />
      </Frame>
    </Tab>

    <Tab title="Confirm">
      <Frame caption="confirm rollback">
        <img src="https://mintcdn.com/polyai/5TqB0Il1JYn5J7QH/images/deployment/rollback-confirmed.png?fit=max&auto=format&n=5TqB0Il1JYn5J7QH&q=85&s=02fb656796bac10631bc15510b21c75b" alt="confirm rollback" style={{ maxWidth: '720px', width: '100%', margin: '0 auto', display: 'block' }} width="2504" height="1420" data-path="images/deployment/rollback-confirmed.png" />
      </Frame>
    </Tab>
  </Tabs>

  ## Testing your agent

  Main page: [Quickstart: test your agent](/get-started/quickstart#test-your-agent)

  Test your agent in any environment:

  1. Click the **Play Chat** icon in the top-right corner of the screen.

  2. Select the environment containing the version you want to test.

  ## Assigning phone numbers

  Each environment can have its own phone number. To assign:

  1. Go to **Configure > Numbers** in the sidebar.

  Assign phone numbers and SIP headers per version.

  <Frame caption="assign version phone numbers">
    <img src="https://mintcdn.com/polyai/5TqB0Il1JYn5J7QH/images/deployment/assign-number.png?fit=max&auto=format&n=5TqB0Il1JYn5J7QH&q=85&s=e5408f65e67ed97a11d810d9c2c36dc8" alt="assign version phone numbers" style={{ maxWidth: '720px', width: '100%', margin: '0 auto', display: 'block' }} width="3006" height="1610" data-path="images/deployment/assign-number.png" />
  </Frame>

  <div className="developer-only">
    ## Automate with the Agents API

    The same pipeline is available programmatically, which is useful for wiring deployments into CI or orchestrating releases across many agents.

    <AccordionGroup>
      <Accordion title="Deploy via the Agents API" icon="code">
        The [Agents API](/api-reference/agents/introduction) exposes [publish](/api-reference/agents/endpoint/deployments/publish-the-current-draft-to-an-environment), [promote](/api-reference/agents/endpoint/deployments/promote-a-deployment-to-the-next-environment), and [rollback](/api-reference/agents/endpoint/deployments/rollback-to-a-previous-deployment) as the CI-friendly equivalents of the UI actions above.

        <CodeGroup>
          ```bash curl theme={"theme":{"light":"github-light","dark":"github-dark"}}
          # Publish the current draft to sandbox
          curl -X POST https://api.us.poly.ai/v1/agents/AGENT_ID/deployments/publish \
            -H "x-api-key: $POLYAI_API_KEY" \
            -H "Content-Type: application/json" \
            -d '{ "environment": "sandbox" }'

          # Promote a sandbox deployment to pre-release
          curl -X POST https://api.us.poly.ai/v1/agents/AGENT_ID/deployments/DEPLOYMENT_ID/promote \
            -H "x-api-key: $POLYAI_API_KEY"
          ```

          ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
          import os, requests

          BASE = "https://api.us.poly.ai"
          HEADERS = {"x-api-key": os.environ["POLYAI_API_KEY"]}

          # Publish the current draft to sandbox
          resp = requests.post(
              f"{BASE}/v1/agents/{AGENT_ID}/deployments/publish",
              headers=HEADERS,
              json={"environment": "sandbox"},
          )
          deployment_id = resp.json()["id"]

          # Promote to pre-release once sandbox checks pass
          requests.post(
              f"{BASE}/v1/agents/{AGENT_ID}/deployments/{deployment_id}/promote",
              headers=HEADERS,
          )
          ```
        </CodeGroup>
      </Accordion>
    </AccordionGroup>
  </div>

  ## Related pages

  <CardGroup cols={2}>
    <Card title="Compare versions" icon="code-compare" href="/environments-and-versions/diffs">
      Side-by-side diff of any two versions before promoting.
    </Card>

    <Card title="Project history" icon="clock-rotate-left" href="/environments-and-versions/project-history">
      Audit trail of all published versions and changes.
    </Card>

    <Card title="Test suite" icon="flask-vial" href="/analytics/test-suite/introduction">
      Run regression tests against Draft or Sandbox.
    </Card>

    <Card title="Deployments endpoints" icon="square-terminal" href="/api-reference/agents/endpoint/deployments/publish-the-current-draft-to-an-environment">
      Publish, promote, and rollback from the Agents API.
    </Card>
  </CardGroup>
</div>
