documents

findAndReplaceTextInDocument

Find and replace EXACT substrings in a document (NOT regex: wildcards and patterns are matched literally). Replaces EVERY occurrence and returns the replacement count; best for renames and repeated phrases. For a single targeted change at a known location, prefer editDocument (anchor patches). Case-sensitive by default. Diagrams/images are automatically protected — only document text is affected. Returns document.versionTimestamp (the fresh optimistic-lock token) like every other mutating tool, so you can chain straight into editDocument or the diagram tools. Pass versionTimestamp to opt into optimistic locking (optional here — whole-document find/replace is position-independent). Note: when the replace value contains a <!-- REFERENCE: {...} --> marker (e.g. inserting a user mention), it round-trips losslessly through the editor and triggers notifications if it adds a new user mention.

post/tools/findAndReplaceTextInDocument

Request

  • Base URL: https://api.stablebaseline.io/functions/v1/cloud-serve/api/v1
  • URL: https://api.stablebaseline.io/functions/v1/cloud-serve/api/v1/tools/findAndReplaceTextInDocument
  • Auth: HTTP bearer

Request body

projectIdstring

Optional. Narrows a friendly-id lookup to one project. Only needed when a friendly id is ambiguous — TAS-/IMP-/PLN- ids are numbered per PROJECT, so the same id can exist in several. Ignored when the id is a UUID.

documentIdstring required
findstring required

Text to search for.

replacestring required

Replacement text. Empty string to delete occurrences.

caseSensitiveboolean

Case-sensitive matching. Default: true.

versionTimestampnumber

Optional optimistic-lock token from getDocument() or a previous write; validated when provided. (Alias accepted: documentVersionTimestamp.)

changeSummarystring

Version history summary.

Response

Tool result (shape varies per tool — refer to the tool's docs for the exact return value).

object required

Changes

No recorded changes to this operation across all 1 revision of this API.