# Update knowledge base

> PATCH https://api.nabrah.ai/api/ext/kb/{knowledge_base_id}

Group: Knowledge bases. Page: https://www.nabrah.ai/en/docs/api-reference/knowledge-bases/update-knowledge-base

Updates a knowledge base's `name`, `key`, and/or `desc`. All fields are optional — send only what you want to change; an empty body is rejected. A changed `key` must remain unique in the project (**409** on conflict). Returns **404** if the KB does not exist.

## Authorization

- `X-API-Key` (string, header, required): your workspace API key.

## Path parameters

- `knowledge_base_id` (string, required): Identifier of the knowledge base to update. From POST /api/ext/kb or GET /api/ext/kb.

## Body (application/json)

### Example: Update description

Refine when the agent should use this KB.

```json
{
  "desc": "Answers about billing, invoices, and refunds only."
}
```

### Example: Rename

Change the display name and key.

```json
{
  "name": "Billing FAQ",
  "key": "billing_faq"
}
```

## Response

### 200 Successful Response

Content type: `application/json`

```json
{
  "id": "00000000-0000-4000-8000-000000000000",
  "project_id": "00000000-0000-4000-8000-000000000000",
  "name": "string",
  "key": "string",
  "desc": "string",
  "document_count": 0,
  "created_at": "2026-01-15T12:00:00.000Z",
  "updated_at": "2026-01-15T12:00:00.000Z"
}
```

### 422 Validation Error

Content type: `application/json`

```json
{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string"
    }
  ]
}
```

## Request examples

### cURL

```bash
curl --request PATCH \
  --url 'https://api.nabrah.ai/api/ext/kb/<knowledge_base_id>' \
  --header 'X-API-Key: <your-api-key>' \
  --header 'Content-Type: application/json' \
  --data '{
  "desc": "Answers about billing, invoices, and refunds only."
}'
```

### Python

```python
import requests

url = "https://api.nabrah.ai/api/ext/kb/<knowledge_base_id>"
headers = {
    "X-API-Key": "<your-api-key>",
}
payload = {
    "desc": "Answers about billing, invoices, and refunds only."
}

response = requests.patch(url, headers=headers, json=payload)
response.raise_for_status()
print(response.json())
```

### JavaScript

```javascript
const response = await fetch("https://api.nabrah.ai/api/ext/kb/<knowledge_base_id>", {
  method: "PATCH",
  headers: {
    "X-API-Key": "<your-api-key>",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "desc": "Answers about billing, invoices, and refunds only."
  }),
});

const data = await response.json();
console.log(data);
```

### Go

```go
package main

import (
	"fmt"
	"io"
	"net/http"
	"strings"
)

func main() {
	payload := strings.NewReader(`{
  "desc": "Answers about billing, invoices, and refunds only."
}`)

	req, _ := http.NewRequest("PATCH", "https://api.nabrah.ai/api/ext/kb/<knowledge_base_id>", payload)
	req.Header.Set("X-API-Key", "<your-api-key>")
	req.Header.Set("Content-Type", "application/json")

	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()

	out, _ := io.ReadAll(res.Body)
	fmt.Println(string(out))
}
```
