> ## Documentation Index
> Fetch the complete documentation index at: https://docs.terminaluse.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Rollback Branch

> 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



## OpenAPI

````yaml openapi.json POST /branches/{branch_id}/rollback
openapi: 3.1.0
info:
  title: Sb0 API
  version: 0.1.0
servers: []
security: []
paths:
  /branches/{branch_id}/rollback:
    post:
      tags:
        - Branches
      summary: Rollback Branch
      description: |-
        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
      operationId: branches_rollback
      parameters:
        - in: path
          name: branch_id
          required: true
          schema:
            title: Branch Id
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RollbackRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RollbackResponse'
          description: Successful Response
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
          description: Validation Error
components:
  schemas:
    RollbackRequest:
      description: Request model for rolling back a branch.
      properties:
        target_version_id:
          anyOf:
            - type: string
            - type: 'null'
          description: >-
            Version ID to rollback to (defaults to previous version if not
            specified)
          title: Target Version Id
      title: RollbackRequest
      type: object
    RollbackResponse:
      description: Response from a rollback operation.
      properties:
        branch_id:
          description: Branch ID
          title: Branch Id
          type: string
        from_git_hash:
          description: Git hash of the previous version
          title: From Git Hash
          type: string
        from_version_id:
          description: Version ID that was rolled back FROM
          title: From Version Id
          type: string
        message:
          description: Human-readable status message
          title: Message
          type: string
        to_git_hash:
          description: Git hash of the target version
          title: To Git Hash
          type: string
        to_version_id:
          description: Version ID that was rolled back TO
          title: To Version Id
          type: string
        version_status:
          $ref: '#/components/schemas/VersionStatus'
          description: Target version status
      required:
        - branch_id
        - from_version_id
        - to_version_id
        - from_git_hash
        - to_git_hash
        - version_status
        - message
      title: RollbackResponse
      type: object
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          title: Detail
          type: array
      title: HTTPValidationError
      type: object
    VersionStatus:
      description: Status of a version in its lifecycle.
      enum:
        - DEPLOYING
        - ACTIVE
        - FAILED
        - UNHEALTHY
        - DRAINING
        - RETIRED
        - ROLLED_BACK
      title: VersionStatus
      type: string
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          title: Location
          type: array
        msg:
          title: Message
          type: string
        type:
          title: Error Type
          type: string
      required:
        - loc
        - msg
        - type
      title: ValidationError
      type: object

````