---
title: "Roll back to a previous version"
method: POST
path: "/websiteSourceCode/published/rollback-version"
tags: ["Publishing"]
---

# Roll back to a previous version

`POST /websiteSourceCode/published/rollback-version`

## Request

- Base URL: `https://api.cactal.ai/v1`
- URL: `https://api.cactal.ai/v1/websiteSourceCode/published/rollback-version`
- Auth: HTTP bearer

Validates and republishes an earlier version as a new head and published version, preserving history. Takes the edit lease when no `leaseToken` is sent.

## Request body

- object
  - `websiteId` string, required
  - `leaseToken` string: Omit to have Cactal take the edit lease for you; pass a token from websiteSourceCode.lease.acquire to take over from another editor.
  - `version` integer, required

## Response `200`

The re-published version now live and its serving deployment.

- object
  - `websiteId` string, required: Id of the website.
  - `publishedVersion` integer, required: Source version now live: a new head version whose files match the requested version.
  - `deployment` object: The ready deployment now serving the site.
    - `id` string, required: Unique id of the deployment.
    - `status` 'building' | 'ready' | 'failed', required: Build state of the deployment.
    - `failureMessage` string, nullable: Human-readable build failure summary. `null` unless `status` is `failed`.
    - `failureKind` 'transient' | 'permanent' | 'unknown', nullable: Failure category. `null` unless `status` is `failed`.

## Other responses

- `400`: Validation failed. The response `message` names the first invalid field.
- `401`: Missing, invalid, expired, or revoked API key.
- `403`: The authenticated principal lacks the required capability.
- `404`: The resource does not exist or is outside the principal’s access scope.
- `409`: The request conflicts with the current state of the resource.
- `429`: Rate limit exceeded. Retry after the number of seconds in the `Retry-After` header.

---

[API](https://skmtc.dev/cactal/apis/cactal-api.md) · [All operations](https://skmtc.dev/cactal/apis/cactal-api/llms.txt) · [OpenAPI document](https://skmtc.dev/cactal/apis/cactal-api/revisions/9cd0fb5eacdd?raw)
