> ## 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.

# GET /v1/agents/{id}/prompts/{section}/versions

> The history of one section, newest first.

Every text that section has held. A version is written **on each save that changes the text**, so saving without editing does not pad the history, and the newest version is what the agent is reading right now.

## Endpoint

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

## Required scope

`agents:read`

## Path parameters

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

## Query parameters

| Parameter | Type     | Description                           |
| --------- | -------- | ------------------------------------- |
| `limit`   | `number` | Records per page (1-200, default 50). |
| `offset`  | `number` | Records to skip.                      |

## Example request

<CodeGroup>
  ```bash curl theme={"system"}
  curl "https://api.keebai.com/v1/agents/6650a1b2c3d4e5f6a7b8c9d0/prompts/business_context/versions?limit=10" \
    -H "Authorization: Bearer kbai_pk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  ```

  ```js JavaScript theme={"system"}
  const resp = await fetch(
    "https://api.keebai.com/v1/agents/6650a1b2c3d4e5f6a7b8c9d0/prompts/business_context/versions",
    { headers: { Authorization: `Bearer ${process.env.KEEBAI_API_TOKEN}` } },
  );
  const { data } = await resp.json();
  const [current, previous] = data;
  ```
</CodeGroup>

## Response

### 200 OK

```json theme={"system"}
{
  "data": [
    {
      "_id": "6651aaaa1111bbbb2222cccc",
      "agent_id": "6650a1b2c3d4e5f6a7b8c9d0",
      "section": "business_context",
      "version_number": 4,
      "markdown": "# Quiénes somos\n\nBarbería en Providencia...",
      "label": null,
      "created_by": "ops@cliente.cl",
      "restored_from": null,
      "created_at": "2026-08-14T18:21:04.112Z"
    },
    {
      "_id": "6651aaaa1111bbbb2222bbbb",
      "agent_id": "6650a1b2c3d4e5f6a7b8c9d0",
      "section": "business_context",
      "version_number": 3,
      "markdown": "# Quiénes somos\n\nBarbería...",
      "label": null,
      "created_by": null,
      "restored_from": null,
      "created_at": "2026-08-02T11:07:55.900Z"
    }
  ],
  "limit": 50,
  "offset": 0
}
```

### 404 Not Found

No agent with that id in the token's company and project.

## Operational notes

* **The first item is the current text.** There is no `is_current` flag because there is nothing to disagree with: the highest `version_number` is what the agent reads.
* **`version_number` is per section**, not per agent. Two sections both have a version 1.
* **`created_by` is who saved it** — a portal user's email, the PAT owner's email when it came through this API, or `null` for versions written before the field existed.
* **`restored_from` names the version this one copied**, when it was born from a restore. It is how you tell an edit from a rollback.
* **An agent created before section history existed starts at version 1** with whatever text it had at that moment, not with its real past.


## OpenAPI

````yaml GET /v1/agents/{id}/prompts/{section}/versions
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:
    get:
      tags:
        - agents
      summary: Historial de una seccion
      description: >-
        Las versiones de esa seccion, de la mas nueva a la mas vieja. Se escribe
        una en cada guardado que cambia el texto: guardar sin cambiar nada no
        infla el historial.
      operationId: PublicAgentsController_listPromptVersions
      parameters:
        - name: id
          required: true
          in: path
          schema:
            type: string
        - name: section
          required: true
          in: path
          schema:
            type: string
        - name: limit
          required: false
          in: query
          schema:
            minimum: 1
            maximum: 200
            default: 50
            type: number
        - name: offset
          required: false
          in: query
          schema:
            minimum: 0
            default: 0
            type: number
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicPromptVersionListResponseDto'
      security:
        - PAT: []
components:
  schemas:
    PublicPromptVersionListResponseDto:
      type: object
      properties:
        limit:
          type: number
        offset:
          type: number
        has_more:
          type: boolean
          description: Si hay al menos una pagina mas despues de esta.
        data:
          type: array
          items:
            $ref: '#/components/schemas/PublicPromptVersionDto'
      required:
        - limit
        - offset
        - has_more
        - data
    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`.

````