***

title: Agent Versioning
sidebarTitle: Versioning
description: Edit agent config safely with drafts, published versions, and rollback.
---------------------

For clean Markdown of any page, append .md to the page URL. For a complete documentation index, see https://docs.smallest.ai/atoms/atoms-platform/features/llms.txt. For full documentation content, see https://docs.smallest.ai/atoms/atoms-platform/features/llms-full.txt.

Every agent's config — prompt, tools, voice, language, post-call metrics, and more — is managed as **versions**. You edit in isolated **drafts**, publish drafts as new versions, and activate the version you want live. Previous versions are kept so you can compare and restore at any time.

***

## Core Concepts

| Concept            | Description                                                                                                         |
| ------------------ | ------------------------------------------------------------------------------------------------------------------- |
| **Version**        | An immutable snapshot of agent config. Only metadata (label, description, pin) can change after publish.            |
| **Active version** | The single version currently serving calls. Every agent has exactly one.                                            |
| **Draft**          | A mutable workspace forked from a version or from another draft. Edits are auto-saved and do not affect live calls. |
| **Revision**       | Each edit inside a draft increments a revision counter, giving you a save history per draft.                        |

When you open an older or non-active version, the editor is **read-only** — the only way to change it is to create a draft from it.

<Frame caption="Read-only view. Editing requires a draft.">
  ![Create a draft to edit](https://files.buildwithfern.com/smallest-ai.docs.buildwithfern.com/d5dbf07f99f6faa22682f50e5a24f9416890b08924481678ea769182d2f781df/products/atoms/pages/platform/building-agents/images/agent-versioning/01-create-draft-modal.png)
</Frame>

***

## Creating a Draft

Drafts can be forked from either a published version or another draft:

* From the **active version** — click **Create Draft** on a read-only version.
* From any **older version** — open the Version history panel, then **New draft** next to the version.
* From an **existing draft** — hover a draft in the Drafts panel and click **New draft** to fork it.

<Frame caption="Fork a new draft from an existing draft.">
  ![New draft from draft](https://files.buildwithfern.com/smallest-ai.docs.buildwithfern.com/b62ebfe17216e6ed9838d8e11189caa8d89ea0aee646232c9cbbcddf1cc4c365/products/atoms/pages/platform/building-agents/images/agent-versioning/08-drafts-new-draft-hover.png)
</Frame>

Once the draft is created, the agent header switches from `V1 (Read-only)` to `Draft #N` and every field in the editor becomes editable.

<Frame caption="Draft #2-ce62 is now editable. Edits auto-save with a revision counter.">
  ![Draft editable](https://files.buildwithfern.com/smallest-ai.docs.buildwithfern.com/1efcd0c6f8eeff6eeb6b600f2c2013f3b99b24f3e1ef64013453714f87c9685b/products/atoms/pages/platform/building-agents/images/agent-versioning/02-editing-draft.png)
</Frame>

<Tip>
  Drafts are private scratch space. Multiple drafts can exist in parallel — for example, one experimenting with a new voice and another tuning the prompt.
</Tip>

***

## Browsing Versions and Drafts

The version switcher at the top of the editor has two tabs:

<Tabs>
  <Tab title="Version history">
    Every published version, newest first. The currently-active one is tagged **Active**. Older versions show a **Restore** action; the active one shows a **New draft** link.

    <Frame caption="Version history. V1 is active.">
      ![Version history](https://files.buildwithfern.com/smallest-ai.docs.buildwithfern.com/cff468436cd2efb9650ea7dffda6cfb5cd6b6e1cb1c485be79be23372003f99e/products/atoms/pages/platform/building-agents/images/agent-versioning/03-version-history.png)
    </Frame>
  </Tab>

  <Tab title="Drafts">
    All open drafts for this agent, with their source version and a revision counter. Drafts persist until discarded or published.

    <Frame caption="Two drafts, both forked from V1.">
      ![Drafts panel](https://files.buildwithfern.com/smallest-ai.docs.buildwithfern.com/8210a75f48f274abcc8234adaf005cb39c0c4983b6bdc195ac3a710e8ddd400b/products/atoms/pages/platform/building-agents/images/agent-versioning/04-drafts-panel.png)
    </Frame>
  </Tab>
</Tabs>

***

## Comparing Versions

Use **Compare versions** to see exactly what changed between any two snapshots — published versions or drafts.

<Steps>
  <Step title="Pick a base and a comparison">
    Both dropdowns list all published versions and all open drafts.

    <Frame>
      ![Select versions to compare](https://files.buildwithfern.com/smallest-ai.docs.buildwithfern.com/a72e3ea60fc173a25222b305beb525cb9e7292dcbd4c1ab37a7677e238f7e376/products/atoms/pages/platform/building-agents/images/agent-versioning/05-compare-versions-select.png)
    </Frame>
  </Step>

  <Step title="Review the diff">
    Sections are shown only if they changed. Red is removed content, green is added. The Workflow Prompt section shows a line-by-line diff:

    <Frame>
      ![Prompt diff](https://files.buildwithfern.com/smallest-ai.docs.buildwithfern.com/b035b6226adf9668d0de2bf92a9953038565f18ff6135d39c3d1ee82289aff20/products/atoms/pages/platform/building-agents/images/agent-versioning/06-compare-versions-prompt-diff.png)
    </Frame>
  </Step>

  <Step title="Inspect config sections">
    LLM model, voice config, and language settings each render as their own grouped diff:

    <Frame>
      ![Config diff](https://files.buildwithfern.com/smallest-ai.docs.buildwithfern.com/5e6d05c594d0ed67f81e205763c69e3a67c1c4ce5c0cdb5e2064cb5792aace42/products/atoms/pages/platform/building-agents/images/agent-versioning/07-compare-versions-config-diff.png)
    </Frame>
  </Step>
</Steps>

***

## Publishing a Draft

When a draft is ready, click **Publish** in the top right. The Review Changes dialog shows the diff against the current active version and asks for a label + description.

<Frame caption="Review diff, label the version, and choose whether to activate on publish.">
  ![Review Changes](https://files.buildwithfern.com/smallest-ai.docs.buildwithfern.com/96d41535273960aba0891086a7f64c426abfb9fb6ddde693f51464b7f1ec150e/products/atoms/pages/platform/building-agents/images/agent-versioning/09-review-changes-publish.png)
</Frame>

| Field                         | Required   | Description                                                      |
| ----------------------------- | ---------- | ---------------------------------------------------------------- |
| **Version label**             | Yes        | Short human-readable name (e.g., "Version 2 with Hindi").        |
| **Description**               | No         | Longer note about what changed and why.                          |
| **Activate after publishing** | Default on | When enabled, the new version immediately takes over live calls. |

After publishing, the draft is removed and the new version appears in the Version history. If you chose to activate, it also becomes the new `Active` entry. The previous active version gets a **Restore** action.

<Frame caption="V2 is now active. V1 can still be restored.">
  ![After publish](https://files.buildwithfern.com/smallest-ai.docs.buildwithfern.com/34591ca02c015b041b3840dbfa9b77256b18284fdb0307784726c5e57bc0e649/products/atoms/pages/platform/building-agents/images/agent-versioning/10-after-publish-v2-active.png)
</Frame>

***

## Restoring an Older Version

Click **Restore** next to an older version to set it active again. The currently-active version is not deleted — you can swap back any time. Restoring never modifies config; it just changes which version serves live calls.

***

## Managing Versions via API

Every action in the UI is available through the public API.

<Tip>
  All examples assume `BASE="https://api.smallest.ai/atoms/v1"` and `API_KEY` is set in your environment.
</Tip>

### Full flow — edit, publish, activate

```python
import os
import requests

API_KEY = os.environ["SMALLEST_API_KEY"]
AGENT_ID = "YOUR_AGENT_ID"
BASE = "https://api.smallest.ai/atoms/v1"
HEADERS = {"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"}

# 1. Read the active version
agent = requests.get(f"{BASE}/agent/{AGENT_ID}", headers=HEADERS).json()
active_version_id = agent["data"]["activeVersionId"]

# 2. Fork a draft from the active version
draft = requests.post(
    f"{BASE}/agent/{AGENT_ID}/drafts",
    headers=HEADERS,
    json={"sourceVersionId": active_version_id, "draftName": "tune-prompt"},
).json()
draft_id = draft["data"]["draftId"]

# 3. Update fields on the draft (any subset is allowed)
requests.patch(
    f"{BASE}/agent/{AGENT_ID}/drafts/{draft_id}/config",
    headers=HEADERS,
    json={
        "singlePromptConfig": {
            "prompt": "You are a helpful assistant..."
        },
        "synthesizer": {
            "voiceConfig": {"model": "waves_lightning_large", "voiceId": "nyah"},
            "speed": 1.2,
        },
    },
).raise_for_status()

# 4. Publish as a new version and activate it
published = requests.post(
    f"{BASE}/agent/{AGENT_ID}/drafts/{draft_id}/publish",
    headers=HEADERS,
    json={"label": "v2 - friendlier prompt", "description": "Softened tone", "activate": True},
).json()
print("New active version:", published["data"]["version"]["_id"])
```

### Common operations

| Operation               | Method + Path                                                           |
| ----------------------- | ----------------------------------------------------------------------- |
| List drafts             | `GET /agent/{id}/drafts`                                                |
| Fork a draft            | `POST /agent/{id}/drafts` with `sourceVersionId` or `sourceDraftId`     |
| Rename a draft          | `PATCH /agent/{id}/drafts/{draftId}`                                    |
| Discard a draft         | `DELETE /agent/{id}/drafts/{draftId}`                                   |
| Update draft config     | `PATCH /agent/{id}/drafts/{draftId}/config`                             |
| Diff draft vs version   | `GET /agent/{id}/drafts/{draftId}/diff?versionId=...`                   |
| Publish a draft         | `POST /agent/{id}/drafts/{draftId}/publish`                             |
| List published versions | `GET /agent/{id}/versions`                                              |
| Get one version         | `GET /agent/{id}/versions/{versionId}`                                  |
| Diff two versions       | `GET /agent/{id}/versions/diff?baseId=...&compareId=...`                |
| Activate a version      | `PATCH /agent/{id}/versions/{versionId}/activate`                       |
| Update version metadata | `PATCH /agent/{id}/versions/{versionId}` (label, description, isPinned) |

See the full schema in the [API Reference](/atoms/api-reference).

### Reading active config

`GET /agent/{id}` returns the agent document with the active version's resolved config merged under `_resolvedConfig`:

```bash
curl -H "Authorization: Bearer $SMALLEST_API_KEY" \
  "$BASE/agent/$AGENT_ID" \
  | jq '.data | {activeVersionId, prompt: ._resolvedConfig.prompt, tools: ._resolvedConfig.tools, analytics: ._resolvedConfig.postCallAnalyticsConfig}'
```

<Note>
  `GET /agent/{id}/workflow` returns `{prompt, tools}` for the active version only. The `versionId` query parameter on this endpoint is currently ignored — to inspect a non-active version's config, call `GET /agent/{id}/versions/{versionId}` instead.
</Note>

<Warning>
  `PATCH /workflow/{id}` still works but **bypasses versioning**. It writes directly to the legacy workflow document: the change is not captured as a version, and any field missing from the PATCH payload can be silently wiped. On a versioned agent, always go through `PATCH /agent/{id}/drafts/{draftId}/config` and publish.
</Warning>

***

## Related

<CardGroup cols={2}>
  <Card title="Post-Call Metrics" icon="chart-line" href="/atoms/atoms-platform/features/post-call-metrics">
    Configure metrics through the draft flow
  </Card>

  <Card title="API Reference" icon="code" href="/atoms/api-reference">
    Full list of draft and version endpoints
  </Card>
</CardGroup>