---
title: "Rollback Branch"
method: POST
path: "/branches/{branch_id}/rollback"
tags: ["Branches"]
---

# Rollback Branch

`POST /branches/{branch_id}/rollback`

Roll back a branch to a previous version by branch ID.

    Key behavior:
    - EnvVar table is NOT modified (remains pending state)
    - Uses Version.secrets_snapshot as deployed state

## Path parameters

- `branch_id` string, required

## Request body

- RollbackRequest — Request model for rolling back a branch.
  - `target_version_id` string, nullable — Version ID to rollback to (defaults to previous version if not specified)

## Response `200`

Successful Response

- RollbackResponse — Response from a rollback operation.
  - `branch_id` string, required — Branch ID
  - `from_git_hash` string, required — Git hash of the previous version
  - `from_version_id` string, required — Version ID that was rolled back FROM
  - `message` string, required — Human-readable status message
  - `to_git_hash` string, required — Git hash of the target version
  - `to_version_id` string, required — Version ID that was rolled back TO
  - `version_status` 'DEPLOYING' | 'ACTIVE' | 'FAILED' | 'UNHEALTHY' | 'DRAINING' | 'RETIRED' | 'ROLLED_BACK', required — Status of a version in its lifecycle.

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/terminaluse/apis/sb0-api.md) · [All operations](https://skmtc.net/terminaluse/apis/sb0-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/terminaluse/sb0-api/versions/f24a474dc415/schema)
