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

# Restore Agent Version

> Copies a version's config into your draft (created if you have none), replacing what the draft holds. Nothing callers hear changes. With `publish=live` (agents with deployments off only), production runs that version right away instead, and no draft changes; this also needs the `agents:deploy` permission.



## OpenAPI

````yaml /api-reference/openapi.json post /v2/voice-agents/{voiceAgentId}/versions/{versionId}/restore
openapi: 3.0.1
info:
  title: Hamsa API
  description: >-
    The Hamsa API: voice agents and their calls, phone numbers, batch calls and
    knowledge bases; speech to text, text to speech, voices and AI content.
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.tryhamsa.com
security: []
paths:
  /v2/voice-agents/{voiceAgentId}/versions/{versionId}/restore:
    post:
      summary: Restore an agent version
      description: >-
        Copies a version's config into your draft (created if you have none),
        replacing what the draft holds. Nothing callers hear changes. With
        `publish=live` (agents with deployments off only), production runs that
        version right away instead, and no draft changes; this also needs the
        `agents:deploy` permission.
      parameters:
        - in: path
          name: voiceAgentId
          required: true
          description: ID of the voice agent.
          schema:
            type: string
            format: uuid
            example: fc6f158b-24c2-45a6-957b-c57c0a8979b5
        - in: path
          name: versionId
          required: true
          description: ID of the version (from List Agent Versions).
          schema:
            type: string
            format: uuid
            example: 3b9e2c71-8f4d-4a6b-9c1e-2d7f5a8b0c34
        - in: query
          name: publish
          required: false
          description: >-
            `live`: production runs this version now (deployments off only).
            Omit to restore into your draft.
          schema:
            type: string
            enum:
              - live
            example: live
        - in: header
          name: Idempotency-Key
          required: false
          description: >-
            Optional, up to 255 characters. Retry with the same key after a
            network error and you get the first answer back instead of the
            change being made twice (kept 10 minutes). Same key with a different
            body: 422 `IdempotencyKeyReused`. While the first request still
            runs: 409 `IdempotencyKeyInProgress`.
          schema:
            type: string
            maxLength: 255
            example: 0b6f3c1e-retry-1
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  message:
                    type: string
                    example: success
                  data:
                    oneOf:
                      - type: object
                        title: Into your draft
                        properties:
                          kind:
                            type: string
                            enum:
                              - draft
                            example: draft
                          hasDraft:
                            type: boolean
                            example: true
                          revision:
                            type: string
                            format: uuid
                            description: Your draft's new revision.
                            example: e2f7a9c3-6b1d-4e5f-a8c2-7d3b9f0e1a56
                          savedBy:
                            $ref: '#/components/schemas/AgentDraftAuthor'
                          updatedAt:
                            type: string
                            format: date-time
                            example: '2026-10-28T09:15:00.000Z'
                          restoredFrom:
                            type: object
                            properties:
                              versionId:
                                type: string
                                format: uuid
                                example: 3b9e2c71-8f4d-4a6b-9c1e-2d7f5a8b0c34
                              versionNumber:
                                type: integer
                                example: 2
                              versionLabel:
                                type: string
                                example: Before the FAQ flow
                          draft:
                            $ref: '#/components/schemas/AgentDraftSummary'
                      - type: object
                        title: Live (publish=live)
                        properties:
                          kind:
                            type: string
                            enum:
                              - live
                            example: live
                          version:
                            $ref: '#/components/schemas/AgentVersion'
        '400':
          description: >-
            Invalid request (including an `Idempotency-Key` over 255
            characters), or (`publish=live`) the version uses an expensive model
            and the agent has no LLM API key
            (`LLMApiKeyRequiredForExpensiveModel`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentVersionError'
        '401':
          description: 'Unauthorized: missing or invalid API key.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentVersionError'
        '403':
          description: >-
            Your API key or role does not have `agents:restore_version`, or
            (`publish=live`) `agents:deploy`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentVersionError'
        '404':
          description: Voice agent or version not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentVersionError'
        '409':
          description: >-
            Your draft changed while it was being replaced
            (`DraftStaleRevision`). Try again. Or the same `Idempotency-Key` is
            still running (`IdempotencyKeyInProgress`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentVersionError'
        '422':
          description: >-
            `publish=live` on an agent with deployments on (`NotAllowedInState`,
            reason `VERSIONING_ON`): point an environment at the version
            instead. Or the `Idempotency-Key` was used with a different request
            (`IdempotencyKeyReused`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentVersionError'
        '500':
          description: Server Side Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentVersionError'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    AgentDraftAuthor:
      type: object
      description: A project member.
      properties:
        id:
          type: string
          format: uuid
          example: b7d9e979-4a16-437b-8571-4ed92a94faa8
        name:
          type: string
          example: Sara Ahmad
        email:
          type: string
          nullable: true
          example: sara@example.com
    AgentDraftSummary:
      type: object
      description: A member's draft of the agent.
      properties:
        id:
          type: string
          format: uuid
          description: Draft ID.
          example: 9a4c1e6b-2f3d-4b8a-8e7c-5d1f0a2b3c47
        author:
          $ref: '#/components/schemas/AgentDraftAuthor'
        status:
          type: string
          enum:
            - open
            - proposed
            - published
            - discarded
            - expired
          description: >-
            `open`: being edited by its author. `proposed`: waiting for review.
            `published`: went into a version. `discarded`: thrown away.
            `expired`: left unsaved for 7 days.
          example: open
        baseVersionNumber:
          type: integer
          description: The version the draft started from.
          example: 4
        versionsBehind:
          type: integer
          description: >-
            How many versions the draft is behind the version new drafts start
            from. `0` when it is up to date; update it with `POST
            /draft/rebase`.
          example: 0
        changedPaths:
          type: array
          items:
            type: string
          description: >-
            The settings that differ from the base version, as paths in the
            agent body.
          example:
            - conversation.preamble
            - llm.temperature
        revision:
          type: string
          format: uuid
          description: >-
            The draft's current revision. Send it as `baseRevision` when you
            save, so you don't overwrite a newer save.
          example: e2f7a9c3-6b1d-4e5f-a8c2-7d3b9f0e1a56
        proposedAt:
          type: string
          format: date-time
          description: When it was proposed.
          example: '2026-10-28T09:15:00.000Z'
        proposalNote:
          type: string
          description: The note sent with the proposal.
          example: New opening line for Saudi callers.
        lastSentBack:
          type: object
          description: The last time a reviewer sent it back.
          properties:
            by:
              $ref: '#/components/schemas/AgentDraftAuthor'
            note:
              type: string
              example: Please keep the greeting under 10 seconds.
            at:
              type: string
              format: date-time
              example: '2026-10-28T09:15:00.000Z'
        combinedFrom:
          type: array
          description: The proposals a reviewer combined into this draft.
          items:
            type: object
            properties:
              draftId:
                type: string
                format: uuid
                example: 9a4c1e6b-2f3d-4b8a-8e7c-5d1f0a2b3c47
              revision:
                type: string
                format: uuid
                example: e2f7a9c3-6b1d-4e5f-a8c2-7d3b9f0e1a56
              author:
                $ref: '#/components/schemas/AgentDraftAuthor'
        expiresAt:
          type: string
          format: date-time
          description: >-
            An open draft expires 7 days after its last save. Not set while
            proposed.
          example: '2026-11-04T09:15:00.000Z'
        publishedAs:
          type: integer
          description: The version number it was published as (`published` only).
          example: 5
        closedBy:
          $ref: '#/components/schemas/AgentDraftAuthor'
          description: Who published or discarded it.
        closedAt:
          type: string
          format: date-time
          example: '2026-10-28T09:15:00.000Z'
        closedNote:
          type: string
          description: The note left when it was discarded.
          example: Covered by the new FAQ flow.
        lastVia:
          $ref: '#/components/schemas/AgentDraftVia'
          description: Where the last save came from.
        proposedVia:
          $ref: '#/components/schemas/AgentDraftVia'
          description: Where the proposal came from.
        updatedAt:
          type: string
          format: date-time
          description: When the author last saved.
          example: '2026-10-28T09:15:00.000Z'
        valueKeys:
          type: array
          items:
            type: string
          description: Names of the draft's test values, sorted. `[]` when none.
          example:
            - ORDER_ID
    AgentVersion:
      type: object
      description: >-
        A published version: a frozen copy of the agent's config. Versions are
        permanent.
      properties:
        id:
          type: string
          format: uuid
          description: Version ID.
          example: 3b9e2c71-8f4d-4a6b-9c1e-2d7f5a8b0c34
        agentId:
          type: string
          format: uuid
          example: fc6f158b-24c2-45a6-957b-c57c0a8979b5
        versionNumber:
          type: integer
          description: 'Version number: 1, 2, 3... Numbers are never reused.'
          example: 4
        versionLabel:
          type: string
          description: Short name. Left out when the version has none.
          example: Arabic greeting
        changeSummary:
          type: string
          description: What changed. Left out when the version has none.
          example: Rewrote the opening line.
        createdBy:
          $ref: '#/components/schemas/AgentVersionActor'
          description: Who published it.
        publishedBy:
          $ref: '#/components/schemas/AgentVersionActor'
          description: Same as `createdBy`.
        sources:
          type: array
          description: >-
            The proposed drafts it was published from, in the order applied.
            Left out when none.
          items:
            type: object
            properties:
              draftId:
                type: string
                format: uuid
                example: 9a4c1e6b-2f3d-4b8a-8e7c-5d1f0a2b3c47
              author:
                $ref: '#/components/schemas/AgentVersionActor'
        createdAt:
          type: string
          format: date-time
          example: '2026-10-28T09:15:00.000Z'
        status:
          type: string
          enum:
            - APPROVED
            - PENDING
          description: >-
            `APPROVED`: can be deployed. `PENDING`: waiting for approval, cannot
            be deployed.
          example: APPROVED
        isCurrentVersion:
          type: boolean
          description: >-
            `true` for the newest version. It is not necessarily the version
            callers hear: see `isLive`.
          example: true
        isLive:
          type: boolean
          example: false
          description: >-
            `true` when callers hear this version: prod serves it (both versions
            during an A/B test). `false` otherwise. After a roll back, an older
            version is live and the newest is not.
    AgentVersionError:
      type: object
      properties:
        code:
          type: integer
          description: Service error code (8400, 8403, 8404, 8409, ...).
          example: 8409
        message:
          type: string
          example: >-
            Your draft changed in another tab or through your API key. Reload it
            and try again.
        messageKey:
          type: string
          description: Stable error key.
          example: DraftStaleRevision
        params:
          type: object
          additionalProperties: true
          description: >-
            Details. `reason` names the case (for example `STALE_REVISION`,
            `NO_DRAFT`, `SESSION_ONLY`); `action` names a missing permission
            (for example `agents:deploy`).
          example:
            reason: STALE_REVISION
            revision: e2f7a9c3-6b1d-4e5f-a8c2-7d3b9f0e1a56
    AgentDraftVia:
      type: object
      description: Where the change came from.
      properties:
        kind:
          type: string
          enum:
            - dashboard
            - api_key
          example: api_key
        keyRef:
          type: string
          description: The API key's reference (`api_key` only).
          example: sk_live_4f2a
        keyName:
          type: string
          description: The API key's name (`api_key` only).
          example: CRM sync
    AgentVersionActor:
      type: object
      description: A project member.
      properties:
        id:
          type: string
          format: uuid
          example: b7d9e979-4a16-437b-8571-4ed92a94faa8
        name:
          type: string
          example: Sara Ahmad
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        Pass the API key in the Authorization header, You need to put Token
        keyword before the API key. e.g. 'Authorization: Token <api-key>'

````

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