kb_documents_edit_apply
Apply an ordered batch of edits to an open edit session, all-or-nothing — if any edit cannot be applied (no match / ambiguous / overlapping / out of range) the whole batch is rejected and the buffer is left unchanged. Edit types: "replace" (old_string unique unless replace_all=true, new_string), "line_range" (start_line/end_line/content), "section" (heading + mode replace_body|insert_after_heading|delete_section, with level/parent to disambiguate). Returns the cumulative base→working unified diff; pass an empty edits array to just re-fetch the diff without mutating.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| diff | No | Which diff to return: full (default) cumulative base→working; none to skip the diff body for long sessions; delta = only this batch change. | |
| edits | Yes | Ordered edits applied atomically against the current buffer. Empty array = diff refresh only. | |
| session_id | Yes | Open edit session id (required) | |
| tenant_slug | No | Tenant slug to target. Required when your token grants several workspaces; omit when it grants one. If you omit it with several, the refusal names your default workspace; call kb_tenants_list to see every workspace the token grants. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| diff | Yes | ||
| expires_at | Yes | ||
| session_id | Yes |