---
docId: doc_7cd96cbcdb21477abd2737aa866917a1
title: Roll back a publication
description: Puts a version that was already published back into production without touching the draft.
api:
  group: agentes/publicacion
  auth: bearer
  operations:
    - operationId: rollback
      method: POST
      path: '/v1/agents/{agentId}/publication/rollback'
      postmanName: Roll back a publication
---

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

# Roll back a publication

Return to an earlier version if the one you published does not work as expected. Send the `versionId` of a version that **was already published**. Your draft and work in progress are preserved.

## Example

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

```bash
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
await platic.agents.rollback("agent_123", { versionId: "v3" });
```

</Ways.Way>
</Ways>

## Path parameters

| Parameter | Type | Description | Required |
|-----------|------|-------------|----------|
| `agentId` | string | Agent id | ✓ |

## Request body

| Field | Type | Description | Required |
|-------|------|-------------|----------|
| `versionId` | string | A version that was already published, for example `v3`. You find it in the [publication history](/api-reference/agents/publications/list) | ✓ |
| `note` | string | Publication note, up to 500 characters | - |

```json
{
  "versionId": "v3",
  "note": "Go back to the previous version"
}
```

## Response

The fields are those from [Get the publication](/api-reference/agents/publications/get#response-fields), with `last.action: "rollback"`:

```json
{
  "status": "success",
  "data": {
    "agentId": "Xq8mTe2LwP4kZ1aB9cDf",
    "publication": { "versionId": "v3", "number": 3 },
    "last": {
      "publicationId": "p4",
      "action": "rollback",
      "versionId": "v3",
      "previousVersionId": "v5",
      "createdAt": "2026-10-28T12:40:00.000Z",
      "createdBy": { "kind": "api_key", "keyId": "k3yId" },
      "source": "api",
      "via": null,
      "note": "Go back to the previous version"
    }
  }
}
```

## Errors

| Status | `details.code` | When |
|--------|----------------|------|
| `403` | `FORBIDDEN` | The credential can't edit this agent |
| `404` | `AGENT_NOT_FOUND` | The agent doesn't exist in the workspace or was deleted |
| `404` | `VERSION_NOT_FOUND` | `versionId` doesn't exist on that agent |
| `409` | `NOT_PREVIOUSLY_PUBLISHED` | That version was never published. Use [Publish a version](/api-reference/agents/publications/publish) |
| `409` | `CONFLICT` | Someone else changed this at the same time. Try again |
| `422` | `INVALID_SUBAGENT_LINK` | That version links a subagent that was already deleted. It isn't published |

```json
{
  "code": 409,
  "error": "Conflict - The resource state conflicts with this request",
  "details": {
    "code": "NOT_PREVIOUSLY_PUBLISHED",
    "message": "Version v4 was never published; use publish instead"
  }
}
```

## Notes

- The rollback stays in the [publication history](/api-reference/agents/publications/list) as one more entry, with `action: "rollback"`.
- To bring an old version into the draft and keep editing it, without touching production, use [Restore a version](/api-reference/agents/drafts/restore).
