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

# Roll back a branch to a tag

> Restore a branch's data and index schema from a tag in the same collection. The tag must have a published snapshot. Before its first snapshot, rollback returns 400. The branch keeps its identity and records a new committed snapshot. Ordinary reads show the restored snapshot; consistentRead also includes eligible inherited WAL and new writes. Bulk writes appear after build. Writes admitted before rollback may still complete on the previous stream. Each request resolves the current branch by name. Sending the request again performs another rollback and can undo intervening writes. If two requests attempt to replace the same active WAL stream, one succeeds and the other returns 409.



## OpenAPI

````yaml post /collections/{collectionName}/branches/{branchName}/rollback
openapi: 3.1.1
info:
  title: LambdaDB API
  summary: LambdaDB Open API Spec
  version: 1.3.0
servers:
  - url: https://{projectHost}
    description: LambdaDB API endpoints
    variables:
      projectHost:
        description: The project-scoped URL of the API
        default: api.lambdadb.ai/projects/example-project
security: []
tags:
  - name: collections
    description: Create, describe, configure, list, and delete collections.
  - name: versioning
    description: Manage branches, tags, and aliases within a collection.
  - name: collections.docs
    description: Write, fetch, list, and bulk upload documents.
paths:
  /collections/{collectionName}/branches/{branchName}/rollback:
    post:
      tags:
        - versioning
      summary: Roll Back a Branch to a Tag
      description: >-
        Restore a branch's data and index schema from a tag in the same
        collection. The tag must have a published snapshot. Before its first
        snapshot, rollback returns 400. The branch keeps its identity and
        records a new committed snapshot. Ordinary reads show the restored
        snapshot; consistentRead also includes eligible inherited WAL and new
        writes. Bulk writes appear after build. Writes admitted before rollback
        may still complete on the previous stream. Each request resolves the
        current branch by name. Sending the request again performs another
        rollback and can undo intervening writes. If two requests attempt to
        replace the same active WAL stream, one succeeds and the other returns
        409.
      operationId: rollbackBranch
      parameters:
        - $ref: '#/components/parameters/CollectionName'
        - $ref: '#/components/parameters/BranchName'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required:
                - tag
              properties:
                tag:
                  type: string
                  minLength: 3
                  maxLength: 52
                  pattern: ^[a-zA-Z0-9_-]{3,52}$
            examples:
              example:
                value:
                  tag: release-42
      responses:
        '200':
          description: Committed rollback result.
          content:
            application/json:
              schema:
                type: object
                required:
                  - branchId
                  - headSnapshot
                properties:
                  branchId:
                    type: string
                  headSnapshot:
                    $ref: '#/components/schemas/SnapshotDetails'
                    description: >-
                      New head committed on the destination branch by this
                      rollback.
              examples:
                example:
                  value:
                    branchId: main-branch-id
                    headSnapshot:
                      snapshotId: rollback-snapshot-id
                      snapshotCommittedAt: 1788336000000
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BadRequest'
              examples:
                example:
                  summary: Example response for bad request
                  value:
                    message: Invalid request
        '401':
          description: Unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Unauthenticated'
              examples:
                example:
                  summary: Example response for authentication failure
                  value:
                    message: Authentication failed
        '404':
          $ref: '#/components/responses/ResourceNotFound'
        '409':
          $ref: '#/components/responses/CatalogConflict'
        '413':
          $ref: '#/components/responses/PayloadTooLarge'
        '429':
          description: Too many requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TooManyRequests'
              examples:
                example:
                  summary: Example response for too many requests
                  value:
                    message: Too many requests
          headers:
            Retry-After:
              description: >-
                Optional retry delay in seconds. Not present on every 429
                response.
              schema:
                type: string
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InternalServerError'
              examples:
                example:
                  summary: Example response for internal server error
                  value:
                    message: Internal server error
        '502':
          $ref: '#/components/responses/BadGateway'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
        '504':
          $ref: '#/components/responses/GatewayTimeout'
      security:
        - ProjectApiKey: []
components:
  parameters:
    CollectionName:
      in: path
      name: collectionName
      description: Collection name.
      required: true
      schema:
        type: string
    BranchName:
      in: path
      name: branchName
      required: true
      schema:
        type: string
        minLength: 3
        maxLength: 52
        pattern: ^[a-zA-Z0-9_-]{3,52}$
  schemas:
    SnapshotDetails:
      title: SnapshotDetails
      type: object
      properties:
        snapshotId:
          type: string
          description: Immutable snapshot identity.
        snapshotCommittedAt:
          type: integer
          format: int64
          description: >-
            Snapshot commit time as Unix epoch milliseconds, distinct from ref
            creation time and collection dataUpdatedAt.
      required:
        - snapshotId
        - snapshotCommittedAt
    BadRequest:
      title: BadRequest
      type: object
      properties:
        message:
          type: string
    Unauthenticated:
      title: Unauthenticated
      type: object
      properties:
        message:
          type: string
    TooManyRequests:
      title: TooManyRequests
      type: object
      properties:
        message:
          type: string
    InternalServerError:
      title: InternalServerError
      type: object
      properties:
        message:
          type: string
    ResourceNotFound:
      title: ResourceNotFound
      type: object
      properties:
        message:
          type: string
    MessageResponse:
      type: object
      properties:
        message:
          type: string
      required:
        - message
  responses:
    ResourceNotFound:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ResourceNotFound'
          examples:
            example:
              summary: Example response for resource not found
              value:
                message: Resource not found
    CatalogConflict:
      description: >-
        Conditional catalog conflict. Refresh the resource state before deciding
        whether to retry.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/MessageResponse'
    PayloadTooLarge:
      description: >-
        Request exceeds the Gateway transport limit. Reduce the request size or
        use bulk upsert when supported.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/MessageResponse'
    BadGateway:
      description: >-
        Unexpected downstream failure. A failed write response may leave its
        outcome uncertain.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/MessageResponse'
    ServiceUnavailable:
      description: >-
        Transient catalog or storage dependency failure. Use bounded retries
        where the operation permits.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/MessageResponse'
    GatewayTimeout:
      description: >-
        Gateway request deadline exceeded. A write may have been applied; verify
        its outcome before retrying.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/MessageResponse'
  securitySchemes:
    ProjectApiKey:
      type: apiKey
      in: header
      name: x-api-key
      description: Project API Key.
      x-speakeasy-example: <YOUR_PROJECT_API_KEY>

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.