Skip to main content
PATCH
TypeScript SDK

Use cases

Use the update_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. Use the replace_content command to replace the entire page content with new markdown. Provide the full replacement content in new_str.

Inserting content (legacy)

Use the insert_content command to add new markdown content to a page. Provide position: { "type": "start" } to prepend, position: { "type": "end" } to explicitly append, or omit position to append to the end of the page. You can also provide an after selection to insert at a specific point; after uses an ellipsis-based selection format: "start text...end text".
We recommend using update_content or replace_content instead. The insert_content command is still supported but may be deprecated in a future version.

Replacing a content range (legacy)

Use the replace_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.
We recommend using update_content instead. The replace_content_range command is still supported but may be deprecated in a future version.

General behavior

Returns a page_markdown object containing the full page content as enhanced markdown after the update, 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. 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.
Newlines in contentThe content field expects standard markdown with actual newline characters. In JSON, \n is the escape sequence for a newline — for example, "## Heading\n\nParagraph" creates a heading followed by a paragraph.When using cURL, wrap the --data body in single quotes ('...') so that \n is passed through to the JSON parser. Avoid $'...' quoting, which converts \n into a literal newline and produces invalid JSON.Note that the interactive API explorer on this page does not support multiline input. To test with newlines, use cURL, an SDK, or any HTTP client that sends properly encoded JSON.
Protecting child pages and databasesBy default, this endpoint refuses to delete child pages or databases. If an operation would remove them, a validation_error is returned listing the affected items. Set allow_deleting_content to true in the command body (replace_content_range, update_content, or replace_content) to permit deletion.

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

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Headers

Notion-Version
enum<string>
required

The API version to use for this request. The latest version is 2026-03-11.

Available options:
2026-03-11

Path Parameters

page_id
string
required

The ID of the page to update.

Body

application/json
type
string
required

Always insert_content

Allowed value: "insert_content"
insert_content
object
required

Insert new content into the page.

allow_async
boolean

Set to true to opt into receiving an async_task result when this update operation is accepted for background execution. If omitted or false, the endpoint keeps the existing synchronous response shape.

Response

object
string
required

The type of object, always 'page_markdown'.

Allowed value: "page_markdown"
id
string<uuid>
required

The ID of the page or block.

markdown
string
required

The page content rendered as enhanced Markdown.

truncated
boolean
required

Whether the content was truncated due to exceeding the record count limit.

unknown_block_ids
string<uuid>[]
required

Block IDs that could not be loaded (appeared as tags in the markdown). Pass these IDs back to this endpoint to fetch their content separately.

Maximum array length: 100