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

# Restore a flow version

> Restores a flow's **draft** to the content of one of its versions (name, groups, edges, events, variables, settings, theme, public id, tenant and tool description) and returns the version's id. Get `historyId` from **List flow versions**; a version with `hasDanglingReferences` is refused with `400`.

It does not publish: agents keep running the published version until you call **Publish a flow**.

<Warning>The restore **overwrites** the current draft without an `updatedAt` check, so any edit not yet published is lost. Read the draft with **Get a flow** first if you may want it back.</Warning>

The tool rules of **Update a flow** apply, except that a restore may rename: both tenants must be ones your token grants (`403`), and a tool whose name or tenant changes must not collide with another tool in its tenant (`400`).



## OpenAPI

````yaml /api-reference/specs/controlled-flows/v1.json post /v1/typebots/{flowId}/history/{historyId}/rollback
openapi: 3.0.3
info:
  title: Controlled Flows API
  version: 1.0.0
  description: >-
    Read, build, validate and publish controlled flows and the tools agents
    call.
servers:
  - url: https://api.cloudhumans.com/typebot
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Workspaces
    description: The workspaces that hold your flows.
  - name: Flows
    description: >-
      Read, create, change, validate and publish flows. Writes land in the
      draft; only a publish makes them live.
  - name: Versions
    description: The saved versions of a flow, and restoring one.
  - name: Credentials
    description: >-
      REST API credentials that HTTP Request blocks send without exposing the
      secret in the flow.
paths:
  /v1/typebots/{flowId}/history/{historyId}/rollback:
    post:
      tags:
        - Versions
      summary: Restore a flow version
      description: >-
        Restores a flow's **draft** to the content of one of its versions (name,
        groups, edges, events, variables, settings, theme, public id, tenant and
        tool description) and returns the version's id. Get `historyId` from
        **List flow versions**; a version with `hasDanglingReferences` is
        refused with `400`.


        It does not publish: agents keep running the published version until you
        call **Publish a flow**.


        <Warning>The restore **overwrites** the current draft without an
        `updatedAt` check, so any edit not yet published is lost. Read the draft
        with **Get a flow** first if you may want it back.</Warning>


        The tool rules of **Update a flow** apply, except that a restore may
        rename: both tenants must be ones your token grants (`403`), and a tool
        whose name or tenant changes must not collide with another tool in its
        tenant (`400`).
      operationId: restoreFlowVersion
      parameters:
        - name: flowId
          in: path
          required: true
          description: >-
            The flow's internal id, e.g. `clx9z8y7x6w5v4u3t2s1`. Get it from
            **List flows** (the `id` field of each flow). It is NOT the
            `publicId` slug that appears in a flow's public URL: a slug answers
            404 here. A flow your token cannot write to answers 404,
            indistinguishable from one that does not exist.
          schema:
            type: string
        - name: historyId
          in: path
          required: true
          description: >-
            The snapshot to restore, the `id` of an entry of **List flow
            versions** for this same flow. A snapshot of another flow answers
            404.
          schema:
            type: string
      responses:
        '200':
          description: The draft was restored. Publish it to make it live.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestoreResult'
        '400':
          description: >-
            The snapshot cannot be restored: it has edges pointing at groups or
            blocks that no longer exist, or it would produce a TOOL whose name
            is already used in the destination tenant. Nothing was changed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Missing, expired or invalid credentials.
        '403':
          description: >-
            The tenant the flow has before the restore (if it is a TOOL) or the
            one it would end up with is not one your token grants. Nothing was
            changed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: >-
            No such flow or snapshot, or none your token can write to — the two
            are deliberately indistinguishable.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit applied by the API gateway. Back off and retry.
components:
  schemas:
    RestoreResult:
      type: object
      required:
        - message
        - historyId
      properties:
        message:
          type: string
          description: A sentence naming the snapshot the draft was restored to.
        historyId:
          type: string
          description: The snapshot the draft was restored to.
      description: The outcome of a restore. The restored draft is not published yet.
    Error:
      type: object
      properties:
        message:
          type: string
          description: What went wrong.
        code:
          type: string
          description: Error code, e.g. `NOT_FOUND` or `BAD_REQUEST`.
        issues:
          type: array
          description: Per-field validation problems, present on a 400 for invalid input.
          items:
            type: object
            additionalProperties: true
      required:
        - message
        - code
      description: Something the caller needs to fix.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````

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