---
docId: doc_062654f2e8fa4913b8d0bbf168cd8d51
title: Versions and how to go back
sidebarTitle: Go back to a version
description: "View and compare versions, publish changes or return to an earlier version."
---

<script>
  import { Steps, Ways } from '$lib/components';
</script>

# Versions and how to go back

<span id="what-youll-build"></span>

Check which agent version is published and compare it with the draft before publishing changes. To recover earlier settings, restore them into the draft or return to a previous publication with rollback.

Each saved change to versioned configuration creates a fixed version. Versions aren't changed or deleted from the history.

An agent tracks two versions:

- **The draft** is the version you edit. Every change you save creates a new version and moves the draft to it. Your customers don't see it.
- **The published version** is the version that answers your customers. It only changes when you publish or roll back.

| What you do | What changes |
|-------------|--------------|
| Edit the draft | The draft. The published version stays the same |
| Restore a version | The draft. The published version stays the same |
| Publish | The published version |
| Roll back | The published version. The draft stays the same |

An agent's version 1 is published when you create it. The name, photo, status, owners and file and tool connections apply immediately and aren't part of versions.

## Before you start

You need an [agent](/guides/create-an-agent) with its id in `AGENT_ID`.

To use the platform, see [Drafts and versions](/help/agents/versions) and [History and publishing](/help/agents/publish-history).

<Steps>
<Steps.Step>

**Check the draft and published version**

([Get an agent](/api-reference/agents/get))

<Ways tabs="api,sdk,asistente">
<Ways.Way name="api">

```bash
curl https://api.platic.ai/v1/agents/$AGENT_ID \
  -H "Authorization: Bearer $PLATIC_API_KEY"
```

</Ways.Way>
<Ways.Way name="sdk">

```ts
import { Platic } from "platic-sdk";

const platic = new Platic({ apiKey: process.env.PLATIC_API_KEY! });
const agentId = process.env.AGENT_ID!;

const agent = await platic.agents.get(agentId);
```

</Ways.Way>
<Ways.Way name="asistente">
<Ways.Say>

Which version of Sales is published and which one is the draft on?

</Ways.Say>

Tool: [`get_agent`](/mcp/tools#get_agent).

</Ways.Way>
</Ways>

`draft.versionId` is the draft and `publication.versionId` is the published version. `hasUnpublishedChanges` is `true` when the draft has something your customers don't see yet.

</Steps.Step>
<Steps.Step>

**See the versions and compare two**

The list goes from newest to oldest, each with its number, who made it (`createdBy`), where from (`source`) and its note. ([List versions](/api-reference/agents/versions/list))

<Ways tabs="api,sdk,asistente">
<Ways.Way name="api">

```bash
curl https://api.platic.ai/v1/agents/$AGENT_ID/versions \
  -H "Authorization: Bearer $PLATIC_API_KEY"
```

</Ways.Way>
<Ways.Way name="sdk">

```ts
for await (const version of platic.agents.versions.iterate(agentId)) {
  console.log(version.versionId, version.createdBy, version.note);
}
```

</Ways.Way>
<Ways.Way name="asistente">
<Ways.Say>

Show me the version history of Sales.

</Ways.Say>

Tool: [`list_agent_versions`](/mcp/tools#list_agent_versions).

</Ways.Way>
</Ways>

The list doesn't include each version's configuration. To see it in full, use [Get a version](/api-reference/agents/versions/get).

The comparison returns changed sections with their previous (`before`) and new (`after`) content. Before publishing, compare the published version with the draft. ([Compare versions](/api-reference/agents/versions/compare))

<Ways tabs="api,sdk,asistente">
<Ways.Way name="api">

```bash
curl "https://api.platic.ai/v1/agents/$AGENT_ID/versions/v3/compare?with=v5" \
  -H "Authorization: Bearer $PLATIC_API_KEY"
```

</Ways.Way>
<Ways.Way name="sdk">

```ts
const diff = await platic.agents.versions.compare(agentId, "v3", "v5");
```

</Ways.Way>
<Ways.Way name="asistente">
<Ways.Say>

What changed between the published version of Sales and its draft?

</Ways.Say>

Tool: [`compare_agent_versions`](/mcp/tools#compare_agent_versions).

</Ways.Way>
</Ways>

The first version is the before and the one in `with` is the after. Use the `versionId` of the published version and of the draft.

</Steps.Step>
<Steps.Step>

**Validate before publishing**

Validate changes against the draft without saving them. The response tells you whether they can be saved and published, and lists any problems. ([Validate the draft](/api-reference/agents/drafts/validate))

<Ways tabs="api,sdk,asistente">
<Ways.Way name="api">

```bash
curl https://api.platic.ai/v1/agents/$AGENT_ID/draft/validate \
  -H "Authorization: Bearer $PLATIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "instructions": "You are the sales assistant for Acme. Answer in under 50 words and offer free shipping." }'
```

</Ways.Way>
<Ways.Way name="sdk">

```ts
const check = await platic.agents.draft.validate(agentId, {
  instructions: "You are the sales assistant for Acme. Answer in under 50 words and offer free shipping.",
});
```

</Ways.Way>
<Ways.Way name="asistente">
<Ways.Say>

Without saving anything, check whether Sales could be published with these instructions: answer in under 50 words and offer free shipping.

</Ways.Say>

Tool: [`validate_agent_draft`](/mcp/tools#validate_agent_draft).

</Ways.Way>
</Ways>

`valid` says whether it could be saved and `publishable`, whether it could then be published. Each problem comes in `issues`, with its path and its explanation. To also know whether the agent answers better, [test it](/guides/evals).

</Steps.Step>
<Steps.Step>

**Publish a specific version**

If you omit `versionId`, you publish the draft. If you include it, you publish that version. ([Publish](/api-reference/agents/publications/publish))

<Ways tabs="api,sdk,asistente">
<Ways.Way name="api">

```bash
curl https://api.platic.ai/v1/agents/$AGENT_ID/publication \
  -H "Authorization: Bearer $PLATIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "versionId": "v5", "note": "Shorter answers" }'
```

</Ways.Way>
<Ways.Way name="sdk">

```ts
await platic.agents.publish(agentId, { versionId: "v5", note: "Shorter answers" });
```

</Ways.Way>
<Ways.Way name="asistente">
<Ways.Say>

Publish version 5 of Sales.

</Ways.Say>

Tool: [`publish_agent_version`](/mcp/tools#publish_agent_version).

</Ways.Way>
</Ways>

From the next message on, the agent answers with that version. The note is optional and stays in the publication history.

</Steps.Step>
<Steps.Step>

**Restore a version into the draft**

Bring an old version back to keep editing from there. It creates a new version with its content and moves the draft to it. The published version doesn't change. ([Restore the draft](/api-reference/agents/drafts/restore))

<Ways tabs="api,sdk,asistente">
<Ways.Way name="api">

```bash
curl https://api.platic.ai/v1/agents/$AGENT_ID/draft/restore \
  -H "Authorization: Bearer $PLATIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "versionId": "v3" }'
```

</Ways.Way>
<Ways.Way name="sdk">

```ts
await platic.agents.draft.restore(agentId, { versionId: "v3" });
```

</Ways.Way>
<Ways.Way name="asistente">
<Ways.Say>

Restore version 3 into the Sales draft.

</Ways.Say>

Tool: [`restore_agent_version`](/mcp/tools#restore_agent_version).

</Ways.Way>
</Ways>

History is not rewritten: the new version says which one it was copied from in `restoredFromVersionId`. When you have reviewed it, publish it.

</Steps.Step>
<Steps.Step>

**Go back to a previous publication**

Roll back to return to a version that was previously published. This changes the version the agent uses and keeps the draft unchanged. ([List publications](/api-reference/agents/publications/list), [Roll back](/api-reference/agents/publications/rollback))

<Ways tabs="api,sdk,asistente">
<Ways.Way name="api">

```bash
curl https://api.platic.ai/v1/agents/$AGENT_ID/publications \
  -H "Authorization: Bearer $PLATIC_API_KEY"

curl https://api.platic.ai/v1/agents/$AGENT_ID/publication/rollback \
  -H "Authorization: Bearer $PLATIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "versionId": "v3" }'
```

</Ways.Way>
<Ways.Way name="sdk">

```ts
const { data: history } = await platic.agents.publications.list(agentId);

await platic.agents.rollback(agentId, { versionId: "v3" });
```

</Ways.Way>
<Ways.Way name="asistente">
<Ways.Say>

The new version of Sales is answering badly. Go back to the one that was published before.

</Ways.Say>

Tool: [`list_agent_publications`](/mcp/tools#list_agent_publications) and [`rollback_agent_publication`](/mcp/tools#rollback_agent_publication).

</Ways.Way>
</Ways>

In the history, each entry has the version that was published (`versionId`) and the one that was before (`previousVersionId`). Rolling back only accepts a version that was already published; for any other, [publish it](/api-reference/agents/publications/publish) instead.

Use rollback to return to an earlier publication. To edit from an earlier version, restore it into the draft and publish it when it's ready.

</Steps.Step>
</Steps>

## Check it worked

[Get the agent](/api-reference/agents/get) again: `publication.versionId` is the version you published or rolled back to, `draft.versionId` is where you left the draft, and `hasUnpublishedChanges` tells you whether they differ.

## Next steps

- [Test it before you publish](/guides/evals): run your scenarios against the draft and the published version.
- [Add a chat to your site](/guides/web-chat): the web chat is also changed in a draft and published.
- Reference: [draft](/api-reference/agents/drafts/get), [versions](/api-reference/agents/versions/list) and [publication](/api-reference/agents/publications/get).
