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

# Update Knowledge

> Modify an existing knowledge item or change its owning assistant

**Partial** update: send only the fields you want to change. Fields left out stay
as they are.

## Path Parameters

<ParamField path="id" type="string" required>
  Knowledge item UUID
</ParamField>

## Body

<ParamField body="name" type="string">
  New name (1 to 255 characters)
</ParamField>

<ParamField body="description" type="string">
  New description, up to 1000 characters
</ParamField>

<ParamField body="content" type="string">
  New indexed text. Replaces the previous content.
</ParamField>

<ParamField body="usage_instruction" type="string">
  New usage instruction, up to 2000 characters
</ParamField>

<ParamField body="assistant_id" type="string">
  Changes the scope of the knowledge item. See the table below.
</ParamField>

## Changing the owning assistant

The `assistant_id` field has three distinct behaviors:

| What you send       | Effect                                         |
| ------------------- | ---------------------------------------------- |
| field absent        | Scope stays as it is                           |
| `""` (empty string) | Makes the knowledge item **global**            |
| An assistant's UUID | Links the knowledge item **to that assistant** |

<Warning>
  Sending `""` is not the same as omitting the field. The empty string is what
  removes the link to the assistant and returns the knowledge item to the global
  scope.
</Warning>

## Response

Returns `200 OK` with the updated knowledge item.

<RequestExample>
  ```bash cURL theme={null}
  curl -X PUT "https://api.leavo.ai/backend/knowledge/9f1c2d34-5678-4abc-9def-0123456789ab" \
    -H "Authorization: Bearer your_api_key_here" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Return policy 2026",
      "content": "Returns within 45 days upon presentation of the receipt."
    }'
  ```

  ```javascript JavaScript theme={null}
  const id = '9f1c2d34-5678-4abc-9def-0123456789ab';

  const response = await fetch(`https://api.leavo.ai/backend/knowledge/${id}`, {
    method: 'PUT',
    headers: {
      'Authorization': 'Bearer your_api_key_here',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      name: 'Return policy 2026',
      content: 'Returns within 45 days upon presentation of the receipt.'
    })
  });

  console.log(await response.json());
  ```

  ```python Python theme={null}
  import requests

  knowledge_id = '9f1c2d34-5678-4abc-9def-0123456789ab'

  response = requests.put(
      f'https://api.leavo.ai/backend/knowledge/{knowledge_id}',
      headers={'Authorization': 'Bearer your_api_key_here'},
      json={
          'name': 'Return policy 2026',
          'content': 'Returns within 45 days with the receipt.'
      }
  )

  print(response.json())
  ```
</RequestExample>

<ResponseExample>
  ```json 200 OK theme={null}
  {
    "id": "9f1c2d34-5678-4abc-9def-0123456789ab",
    "tenant_id": "d6b10acc-2307-413f-a4de-4c2edf3f9a70",
    "name": "Return policy 2026",
    "description": "Exchange and return rules",
    "content": "Returns within 45 days upon presentation of the receipt.",
    "source_url": null,
    "usage_instruction": "Use when the lead asks about exchanges or returns.",
    "assistant_id": null,
    "excluded_assistant_ids": [],
    "created_at": "2026-01-15T10:30:00Z",
    "updated_at": "2026-02-10T08:45:00Z"
  }
  ```
</ResponseExample>

## Link to an assistant

```bash cURL theme={null}
curl -X PUT "https://api.leavo.ai/backend/knowledge/9f1c2d34-5678-4abc-9def-0123456789ab" \
  -H "Authorization: Bearer your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"assistant_id": "3f8a1b2c-4d5e-6f70-8192-a3b4c5d6e7f8"}'
```

## Make it global again

```bash cURL theme={null}
curl -X PUT "https://api.leavo.ai/backend/knowledge/9f1c2d34-5678-4abc-9def-0123456789ab" \
  -H "Authorization: Bearer your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"assistant_id": ""}'
```

## Replace the file

Send the request as `multipart/form-data` with the `file` field. The same
extensions and the same 10 MB limit from
[creation](/en/api-reference/knowledge/create) apply.

```bash cURL theme={null}
curl -X PUT "https://api.leavo.ai/backend/knowledge/9f1c2d34-5678-4abc-9def-0123456789ab" \
  -H "Authorization: Bearer your_api_key_here" \
  -F "name=Product manual v2" \
  -F "file=@manual_v2.pdf"
```

## Errors

| Code  | Description                                                                             |
| ----- | --------------------------------------------------------------------------------------- |
| `400` | Field over the character limit, empty `name`, unsupported extension, or file over 10 MB |
| `401` | Missing or invalid API key                                                              |
| `404` | Knowledge item not found, or `assistant_id` does not belong to this organization        |
