---
title: "Rollback Branch by Git Branch Name"
method: POST
path: "/agents/{namespace_slug}/{agent_name}/branches/{branch}/rollback"
tags: ["Branches"]
---

# Rollback Branch by Git Branch Name

`POST /agents/{namespace_slug}/{agent_name}/branches/{branch}/rollback`

Roll back a branch to a previous version by namespace, agent, and git branch name.

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

## Path parameters

- `namespace_slug` string, required
- `agent_name` string, required
- `branch` 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.dev/terminaluse/apis/sb0-api.md) · [All operations](https://skmtc.dev/terminaluse/apis/sb0-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/terminaluse/sb0-api/revisions/f24a474dc415/schema)
