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

# Update Knowledge

Use this API to replace a rule-based knowledge source's content. Velt converts the new content, re-extracts its rules, re-embeds them, and bumps the source's version. Knowledge chunks are not re-chunked.

> [!NOTE]
>
> This API applies only to rule-based sources. Velt classifies every source when you ingest it: a source is rule-based when enough of its lines read like rules, meaning bullets, numbered items, or checkboxes that also carry directive wording such as `must`, `never`, or `ensure`. Checklists and guideline documents qualify; prose documents do not, whatever their file type. Calling this API for a source that is not rule-based returns `FAILED_PRECONDITION` with the message `Version diff is only supported for rule-based knowledge sources.`

# Endpoint

`POST https://api.velt.dev/v2/memory/knowledge/update`

# Headers

**x-velt-api-key** `string` *required*

Your API key.

**x-velt-auth-token** `string` *required*

Your [Auth Token](https://velt.dev/docs/security/auth-tokens.md).

# Body

#### Params

**data** `object` *required*

**properties**

**sourceId** `string` *required*

The knowledge source to update.

**newContent** `string` *required*

The replacement content.

## **Example Requests**

#### Replace a source's content

```JSON theme={null}
{
  "data": {
    "sourceId": "src_9a8...",
    "newContent": "# Brand Guidelines v2\n\n- Always cite medical claims..."
  }
}
```

# Response

The response reports a diff of extracted rules (`added`, `removed`, `unchanged`) and the new version number.

#### Success Response

```JSON theme={null}
{
  "result": {
    "diff": {
      "added": ["..."],
      "removed": ["..."],
      "unchanged": 12
    },
    "newVersion": 2
  }
}
```

#### Failure Response

The endpoint returns `NOT_FOUND` for an unknown `sourceId`, `FAILED_PRECONDITION` when the source is not rule-based, and `INVALID_ARGUMENT` when `sourceId` or `newContent` is missing or empty.

```JSON theme={null}
{
  "error": {
    "message": "ERROR_MESSAGE",
    "status": "INVALID_ARGUMENT"
  }
}
```

```js theme={null}
{
  "result": {
    "diff": {
      "added": ["..."],
      "removed": ["..."],
      "unchanged": 12
    },
    "newVersion": 2
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.