replace_in_note
Replace specific text in a note only when it matches the expected occurrence count, preventing unintended rewrites. Submit multiple edits in one call for efficient batch updates.
Instructions
Replace exact text in a note without resending the rest. Refuses unless find occurs exactly expected_count times (default 1) — protects against a loose find rewriting more than intended. Accepts either find/replace or old_string/new_string (same pair, either naming works).
For several replacements in one note, pass edits (array of {find/old_string, replace/new_string, expected_count}) instead of the singular fields — one row lock and one re-embed for the whole batch instead of one per call. Edits apply in order, and each one's find is matched against the note as already changed by the edits before it, not the original content — an earlier edit can create the text a later one needs, or remove the text a later one expects to find; sequence them accordingly. If any step's count does not match, the whole batch is refused and the note is left completely untouched — the error names which edit index failed and how many times its find text actually occurred. Do not combine edits with the singular find/replace/old_string/new_string/expected_count fields — use one form or the other.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | No | ||
| find | No | Text to replace. Alias: old_string | |
| edits | No | Multiple find/replace steps applied in order in a single call — see main description. | |
| title | No | Alternative to id; resolved like get_note | |
| replace | No | Replacement text. Alias: new_string | |
| new_string | No | Alias for replace | |
| old_string | No | Alias for find | |
| expected_count | No | ||
| expected_updated_at | No | ISO updated_at from when you read the note; refuses the write if it changed since |