Markdown content
Update a page's content as markdown
Insert or replace content in a page using markdown.
PATCH
TypeScript SDK
Use cases
Updating content with search-and-replace (recommended)
Use theupdate_content command to make targeted edits using an array of search-and-replace operations. Each operation specifies an old_str to find and a new_str to replace it with. This is the recommended approach for making precise edits without rewriting the full page.
Replacing all page content (recommended)
Use thereplace_content command to replace the entire page content with new markdown. Provide the full replacement content in new_str.
Inserting content
Use theinsert_content command to add new markdown content to a page without rewriting existing content. Set position to choose where it goes:
An
anchor is existing page content in the request’s markdown_version syntax. It must match exactly one place on the page and start where a block starts, including the block’s leading Markdown syntax: - [ ] Draft agenda, not Draft agenda. Anchored positions require markdown_version: "v2". To copy an exact anchor, read the page with Retrieve page markdown in the same markdown_version.
The after parameter is deprecated. It takes an ellipsis-based selection ("start text...end text") and inserts after the matched range, which can land partway into a block. Use position with after_content instead. On 2026-12-01, after is read as an after_content anchor.
Replacing a content range (legacy)
Use thereplace_content_range command to replace a matched range of existing content with new markdown. The content_range parameter uses the same ellipsis-based selection format as after.
Use
update_content instead. replace_content_range works only on 2026-03-11 and older. On 2026-12-01, it returns a 400 validation_error and the page doesn’t change.General behavior
Returns apage_markdown object containing the full page content as markdown after the update, in the request’s markdown_version syntax, including truncated and unknown_block_ids fields for large pages.
Set allow_async: true at the top level of the request body to receive an HTTP 202 response with an async_task object instead of waiting for the markdown update to finish in the original request. This is useful for high block-count markdown updates, especially replace_content requests and large batches of update_content operations.
Set markdown_version: "v2" at the top level of the request body to write and read Notion-flavored Markdown instead of enhanced markdown. v2 is recommended. v1 is deprecated. It’s the default on 2026-03-11 and older. On 2026-12-01, v2 is the default and v1 returns a 400 validation_error. A synchronous response can include a warnings array when the parser changed or ignored content, or when an old_str did not match. Async updates (allow_async: true) don’t return warnings. See Markdown versions.
If allow_async is omitted or false, this endpoint keeps its existing synchronous response behavior. allow_async changes response behavior only; it does not change validation, permissions, or which operation runs. See Retrieve an async task and Working with markdown content for polling examples.
RequirementsYour connection must have update content capabilities on the target page in order to call this endpoint. To update your connection’s capabilities, navigate to the Developer portal, select your connection, open the Configuration tab, and scroll to the Capabilities section.Attempting to call this endpoint without update content capabilities returns an HTTP response with a 403 status code.
Errors
Each Public API endpoint can return several possible error codes. See the Error codes section of the Status codes documentation for more information.
Authorizations
Headers
The API version to use for this request. The latest version is 2026-12-01.
Available options:
2026-03-11, 2026-12-01 Body
application/json
- Insert Content
- Replace Content Range
- Update Content
- Replace Content
The Markdown syntax to use. v2 is Notion-flavored Markdown and is recommended. v1 is enhanced markdown. It's deprecated. It's the default on 2026-03-11 and older. On 2026-12-01, v2 is the default and v1 returns a 400 validation_error.
Available options:
v1, v2