---
title: "Rebuild an AI Agent's knowledge index (v2)"
method: POST
path: "/v2/agents/{idOrAddress}/knowledge/rebuild"
tags: ["Agents"]
---

# Rebuild an AI Agent's knowledge index (v2)

`POST /v2/agents/{idOrAddress}/knowledge/rebuild`

## Request

- Base URL: `https://api.chat.ethora.com`
- URL: `https://api.chat.ethora.com/v2/agents/{idOrAddress}/knowledge/rebuild`
- Auth: one of:
  - HTTP bearer
  - HTTP bearer

Re-embeds the agent's stored pages and documents from their saved
text, without crawling or uploading anything again. Runs in the
background: the response says how much was queued, and
`GET /v2/agents/{idOrAddress}/knowledge` shows `rebuilding: true` until
it finishes.

`onlyMissing: true` (the default) re-embeds only what has no chunks.
`onlyMissing: false` drops all of the agent's chunks first and embeds
everything again.

Owner only. Supports `User JWT` and `B2B Server JWT`. Requires the
`ai` license feature.

## Path parameters

- `idOrAddress` string, required

## Request body

- object
  - `onlyMissing` boolean

## Response `202`

Rebuild started.
```
{ ok: true, pages: number, docs: number }   // queued for embedding
```

## Other responses

- `400`: Bad Request
- `401`: Unauthorized
- `403`: `FORBIDDEN` (not the owner) or `LICENSE_FEATURE_NOT_INCLUDED`.
- `404`: ``` { error: 'Agent not found', code: 'AGENT_NOT_FOUND' } ```
- `409`: ``` { error: 'The index is already being rebuilt', code: 'REBUILD_IN_PROGRESS' } ```
- `422`: ``` { error: string, code: 'VALIDATION_ERROR' } ```
- `500`: Internal Server Error
- `502`: ``` { error: 'Could not reach the AI service', code: 'AI_SERVICE_ERROR' } ```
- `503`: ``` { error: 'AI service is not configured', code: 'AI_SERVICE_UNAVAILABLE' } ```

---

[API](https://skmtc.dev/ethora/apis/platform-api.md) · [All operations](https://skmtc.dev/ethora/apis/platform-api/llms.txt) · [OpenAPI document](https://skmtc.dev/ethora/apis/platform-api/revisions/01b6e64378ee?raw)
