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

# POST /v1/agents/{id}/prompts/{section}/versions/{versionId}/restore

> Make an older version the current text of a section.

Puts the text of that version back as the section's current text.

**It does not mutate the history.** A restore writes a *new* version copying the old one and records where it came from in `restored_from`, so the version you were on is still there and the restore itself can be undone. A history that loses entries when you roll back is not a history.

## Endpoint

```
POST https://api.keebai.com/v1/agents/{id}/prompts/{section}/versions/{versionId}/restore
```

## Required scope

`agents:write`

## Path parameters

| Parameter   | Type     | Description                           |
| ----------- | -------- | ------------------------------------- |
| `id`        | `string` | `ObjectId` of the agent.              |
| `section`   | `string` | Section type.                         |
| `versionId` | `string` | `ObjectId` of the version to restore. |

## Example request

```bash curl theme={"system"}
curl -X POST https://api.keebai.com/v1/agents/6650a1b2c3d4e5f6a7b8c9d0/prompts/business_context/versions/6651aaaa1111bbbb2222bbbb/restore \
  -H "Authorization: Bearer kbai_pk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
```

## Response

### 201 Created

The version that was created, not the one you restored from.

```json theme={"system"}
{
  "_id": "6651aaaa1111bbbb2222dddd",
  "agent_id": "6650a1b2c3d4e5f6a7b8c9d0",
  "section": "business_context",
  "version_number": 5,
  "markdown": "# Quiénes somos\n\nBarbería en Providencia.",
  "label": null,
  "created_by": "ops@cliente.cl",
  "restored_from": "6651aaaa1111bbbb2222bbbb",
  "created_at": "2026-08-18T09:12:40.310Z"
}
```

### 403 Forbidden

The token does not have the `agents:write` scope.

### 404 Not Found

No agent with that id in the token's company and project, or no version with that id in that section.

## Operational notes

* **The new version number is the next one**, not the restored one. Version 5 can hold the text of version 3; `restored_from` is what tells you so.
* **Restoring a section the agent no longer has puts it back.** The section reappears with that text.
* **The agent picks it up on its next turn.** Conversations in flight finish on what they had.


## OpenAPI

````yaml POST /v1/agents/{id}/prompts/{section}/versions/{versionId}/restore
openapi: 3.0.0
info:
  title: Keebai Public API
  description: Superficie pública REST autenticada con Personal Access Tokens (PAT).
  version: 1.0.0
  contact: {}
servers:
  - url: https://api.keebai.com
    description: Production
security: []
tags: []
paths:
  /v1/agents/{id}/prompts/{section}/versions/{versionId}/restore:
    post:
      tags:
        - agents
      summary: Restaurar una version
      description: >-
        Deja el texto de esa version como el vigente. No muta el historial: crea
        una version nueva que copia la vieja y anota de cual salio, asi que
        restaurar tambien se puede deshacer.
      operationId: PublicAgentsController_restorePromptVersion
      parameters:
        - name: id
          required: true
          in: path
          schema:
            type: string
        - name: section
          required: true
          in: path
          schema:
            type: string
        - name: versionId
          required: true
          in: path
          schema:
            type: string
      responses:
        '201':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicPromptVersionDto'
      security:
        - PAT: []
components:
  schemas:
    PublicPromptVersionDto:
      type: object
      properties:
        _id:
          type: string
        agent_id:
          type: string
        section:
          type: string
          example: business_context
        version_number:
          type: number
          description: Correlativo dentro de la seccion; el mayor es el vigente.
        markdown:
          type: string
        label:
          type: object
          nullable: true
        created_by:
          type: object
          nullable: true
          description: Quien la guardo.
        restored_from:
          type: object
          nullable: true
          description: >-
            Version de la que se copio, cuando esta nacio de una restauracion.
            Restaurar no muta: crea una version nueva.
        created_at:
          type: string
      required:
        - _id
        - agent_id
        - section
        - version_number
        - markdown
        - label
        - created_by
        - restored_from
        - created_at
  securitySchemes:
    PAT:
      scheme: bearer
      bearerFormat: kbai_pk_<hex>
      type: http
      description: >-
        Personal Access Token con prefijo `kbai_pk_`. Generar desde el portal
        con permiso `developer.manage_tokens`.

````