Skip to main content

Overview

The Notion API supports reading, writing, and updating page content using markdown as an alternative to the block-based API. This is especially useful for agentic systems and developer tools that work natively with markdown. Three API surfaces are available:
On 2026-12-01, all three endpoints use Notion-flavored Markdown (v2) by default. On 2026-03-11 and older, they use enhanced markdown (v1). The examples in this guide send markdown_version: "v2", so they read and write the same syntax on every version. For the JavaScript examples, use @notionhq/client v5.29.0 or later.

Markdown versions

The markdown endpoints accept an optional markdown_version parameter. It picks the Markdown syntax for the request. Set markdown_version to v2 to read and write Notion-flavored Markdown. On 2026-12-01, leaving it out also uses v2. On 2026-03-11 and older, leaving it out or setting it to v1 uses enhanced markdown. The version applies to the whole request: v2 content is parsed as v2, and v2 responses are rendered as v2.
Enhanced markdown (v1) is deprecated. 2026-12-01 makes v2 the default and rejects markdown_version: "v1" with a 400 validation_error. 2026-03-11 and older keep v1 as the default for now. We plan to retire v1 on every Notion-Version, and we’ll post the retirement date in the changelog at least three months ahead. Set markdown_version to v2 now and test your integration. See Migrate to Notion-flavored Markdown for the syntax changes.
Where to send it: Any other value returns a 400 validation_error. On POST /v1/pages and the comment endpoints, markdown_version only applies to markdown. Sending it without markdown (for example, with children or rich_text) also returns a 400 validation_error. See the Notion-flavored Markdown format reference for the full v2 syntax. It’s generated from the same specification the Notion MCP server gives AI agents.
cURL

Transcripts in v2

v2 puts a meeting note’s transcript in a <meeting-notes-section-transcript> tag inside <meeting-notes>. Without include_transcript=true, the tag holds a placeholder that starts with Transcript omitted. and says how to load the transcript.

Update warnings

A v2 update can contain syntax that the parser doesn’t support, such as an unknown tag. The update still runs, and the PATCH /v1/pages/:page_id/markdown response includes a warnings array that says what the parser changed or ignored. In either version, an update_content edit whose old_str matches nothing is skipped while the matching edits apply, and each skipped edit appears in warnings with code no_match, or indentation_mismatch when the text is on the page with different indentation:
code is the warning category. The field is left out when there are no warnings, and other endpoints never return it. Async updates (allow_async: true) don’t return warnings in the task result. If no update_content edit matches, the request fails with validation_error and nothing changes. When your integration can read the page content, the error message also tells you to fetch the page again and base old_str on its current text.

Block type support

Use these v2 forms when creating or updating blocks. See the format reference for attributes and nested blocks.

Supported block types

For file-based blocks (image, file, video, audio, PDF), the URLs in the markdown output are pre-signed and ready to download. They expire after a short period, consistent with the block-based API.

Custom blocks

Place an instance of an existing custom block definition with <custom-block definition-id="UUID" /> on its own line. The instance inherits the definition’s bindings. New placements and definition changes require a live, readable definition in the destination workspace; they do not require separate workspace enablement. Definition creation remains in private alpha. Readback returns the definition reference, not the rendered contents. These instances previously appeared as <unknown> and were included in unknown_block_ids; they now use the custom-block tag. Instances with binding overrides still appear as <unknown>. An unchanged instance can survive update_content or replace_content even when the connection cannot read its definition or the definition was deleted. Adding another instance or changing its definition still requires authorization. Public requests reject definition-key, which is reserved for App deployments.

Unsupported block types

The following block types are not yet rendered in the markdown output. When encountered, they appear as <unknown url="..." alt="block_type" /> tags. The url links to the block in Notion, and alt indicates the original block type. Block types that are not recognized by the block API (returned as "unsupported") will also appear as <unknown> in the markdown output.
You can use the block-based API to retrieve structured data for any unsupported block types you encounter in the markdown output.

Creating a page with markdown

Use POST /v1/pages with the markdown parameter instead of children to create a page from a markdown string.
Separate blocks with a blank line, as in "# Heading\n\nParagraph" in JSON. Use <br /> for a line break inside a paragraph. With cURL, put the JSON body in single quotes to preserve the newline escapes.
Key behaviors:
  • The markdown parameter is mutually exclusive with children and content. You cannot use both.
  • If properties.title is omitted, the first # h1 heading is extracted as the page title.
  • Available to all connection types (public, internal, and personal access tokens).
  • Requires insert_content and insert_property capabilities.
  • Markdown that is too large or too heavily formatted to parse in one request returns a validation_error. So does markdown that would create more than 5,000 blocks, counting nested blocks. With allow_async: true, the request still returns an async_task, and the task ends as failed with that validation_error when you poll it. Retrying the same body fails the same way. Create the page with part of the content and add the rest with further requests, or split the content into child pages.
The response is a page object. Use its id for YOUR_PAGE_ID in the read and update examples.

Retrieving a page as markdown

Use GET /v1/pages/:page_id/markdown to retrieve a page’s content as markdown. It uses the syntax set by markdown_version. See Markdown versions for the default.
Response:
The create request uses the first heading as the page title. The body starts with the paragraph below it. In v2, separate paragraphs with a blank line (\n\n in JSON).

Query parameters

Key behaviors:
  • Available to all connection types (public, internal, and personal access tokens).
  • Requires read_content capability.
  • File URIs in the content are automatically converted to pre-signed URLs.

Unknown blocks, truncation, and permissions

Some blocks in a page may appear as <unknown> tags in the markdown output. This can happen for two reasons:
  1. Truncation — the page exceeds the record limit (approximately 20,000 blocks) and some blocks were not loaded.
  2. Permissions — the page contains child pages or other content that is not shared with the connection. The connection can access the parent page, but not those specific child blocks.
In both cases:
  • The truncated field is set to true.
  • The affected blocks appear as <unknown url="..." alt="..." /> tags in the markdown.
  • The unknown_block_ids array contains the IDs of these blocks.
You can attempt to fetch the content of unknown blocks by passing their IDs back to the same endpoint:
For blocks that were unknown due to truncation, this returns the subtree rooted at that block. For blocks that are unknown due to permissions, the request returns an object_not_found error — the connection does not have access to that content.
The unknown_block_ids array does not distinguish between truncated and inaccessible blocks. When re-fetching unknown block IDs, handle object_not_found errors gracefully as they indicate blocks the connection cannot access.
For the best experience, keep pages under a few thousand blocks. Very large pages may require multiple requests to fully retrieve.
Example: iteratively fetching a large page

Updating a page with markdown

Use PATCH /v1/pages/:page_id/markdown to insert or replace content in an existing page using markdown. The request body uses a discriminated union with four command variants. Use update_content to edit existing content, insert_content to add content at a position, and replace_content to replace the whole page. The older replace_content_range command works only on 2026-03-11 and older. 2026-12-01 rejects it.
In a JSON body, "## Heading\n\nParagraph text" creates a heading followed by a paragraph. Use <br /> for a line break inside a paragraph.When using cURL, wrap the --data body in single quotes so that \n is preserved for the JSON parser. Avoid $'...' quoting, which converts \n into a literal newline and produces invalid JSON.

Updating content with search-and-replace

Use update_content to make targeted edits with an array of search-and-replace operations. Each operation specifies old_str (content to find) and new_str (replacement content).
Each old_str must be a non-empty string that matches exactly one location in the page. If it matches multiple locations, a validation_error is returned — set replace_all_matches: true on that operation to replace all occurrences.

Replacing all page content

Use replace_content to replace the entire page content with new markdown.

Insert and range commands

The replace_content_range command and the insert_content.after parameter are no longer recommended. On 2026-03-11 and older, they use an ellipsis-based selection format that is less precise than update_content and anchored insert_content positions. On 2026-12-01, replace_content_range returns a 400 validation_error, and after is read as an after_content anchor. Use update_content, replace_content, or insert_content with position.
Insert new markdown content at the start of a page, next to a specific block, or at the end.
The position parameter supports start, end, after_content, and before_content. When you omit position, content is appended to the end of the page. An after_content or before_content anchor must match exactly one place on the page and start where a block starts, including the block’s leading Markdown syntax. The content goes next to that block, at its nesting level. Anchored positions require markdown_version: "v2". See Update page markdown for the full rules.The deprecated after parameter uses an ellipsis-based selection format on 2026-03-11 and older: "start text...end text". On 2026-12-01, after follows the after_content anchor rules, and ... is literal text. Use after_content instead. Don’t provide after and position in the same request.
Replace a matched range of existing content with new markdown. This command works only on 2026-03-11 and older. On 2026-12-01, it returns a 400 validation_error, so use update_content instead.
The content_range parameter uses the same ellipsis-based selection as after.

Safety: protecting child pages and databases

By default, the update endpoint refuses to delete child pages or databases. If an operation would delete them, a validation_error is returned listing the affected items. To allow deletion, set allow_deleting_content: true in the command body. This option is supported by replace_content_range, update_content, and replace_content:

Update response

All variants return the full page content as markdown after the update:
Key behaviors:
  • Available to all connection types (public, internal, and personal access tokens).
  • Requires update_content capability.
  • The content_range / after / old_str matching is case-sensitive.

Error responses

Meeting note transcripts

The update endpoint always skips meeting note transcript content, matching the default behavior of the GET endpoint. If you retrieve a page with include_transcript=true, the transcript text will appear in the response but cannot be used in content_range or after selections — the update endpoint does not see transcript content during matching and will return a validation_error for selections that span transcript text.

Running large markdown writes asynchronously

Create and update requests with large markdown bodies can take longer than typical HTTP client, browser, or edge timeout budgets. For those writes, set allow_async: true to receive an async_task handle and poll for completion. Async support is available for: Requests that omit allow_async, or set it to false, keep the existing synchronous response behavior. allow_async changes response behavior only; it does not change validation, permissions, or the operation being performed. Notion does not automatically convert a synchronous request into an async response.
Async task completion is polling-first in this version. Use poll_after_seconds from the task response as the minimum delay before polling again. Webhook notifications and ETA estimates are not part of the async task contract.

REST: Create a page asynchronously

Set allow_async: true on POST /v1/pages when creating a page from markdown:
The initial response is HTTP 202:

REST: Update markdown asynchronously

Set allow_async: true at the top level of the PATCH /v1/pages/:page_id/markdown request body:
The initial response is an async_task object with a status_url to poll. A 202 response means Notion accepted the request for background execution after initial request and access checks. Markdown parsing, content matching, and other update validation can still fail while the task runs, so always poll until the task reaches succeeded or failed.

Poll for completion

Poll the task’s status_url, or call Retrieve an async task with the returned id:
In the SDK for JavaScript and TypeScript (v5.23.0 and later), pages.create() and pages.updateMarkdown() accept allow_async: true, and asyncTasks.retrieve() polls the returned task:
An active task returns a non-terminal status and another polling hint:
A successful update task includes the same result shape as the synchronous update:
A failed task includes the standard Public API error shape:
If a task is retrying, Notion is retrying a retryable infrastructure or downstream-service failure. Continue polling with the returned poll_after_seconds guidance. If a task reaches failed, inspect the error before retrying; validation and permission failures usually require a corrected request. Completed and failed task metadata is retained for a bounded period. After expiry, polling the task returns the standard not-found response, so store any final result data your application needs. For the full status resource, see Retrieve an async task.

MCP async examples

For Notion MCP, pass allow_async: true to create_pages or update_page. The tool descriptions recommend this for most page writes unless the next step needs the created or updated page right away, or the async attempt is rejected as too large to queue. This is guidance to assistants, not a request default. When allow_async is omitted, create_pages keeps its synchronous behavior, and update_page waits for a synchronous result when it can but can still return an async_task if the work runs past the synchronous wait deadline.
Poll the task with notion-get-async-task:
The MCP status values are the same as REST: queued, running, retrying, succeeded, and failed. When the task succeeds, the response includes the create or update result. When it fails, the response includes an error object. Wait for succeeded before any step that depends on the new content.

Access control summary