Notion Public API Skill
Use this skill to run Notion Public API operations through uxc + OpenAPI.
Reuse the uxc skill for shared execution, OAuth, and error-handling guidance.
Prerequisites
- -
uxc is installed and available in PATH. - Network access to
https://api.notion.com/v1. - Access to the curated OpenAPI schema URL:
-
https://raw.githubusercontent.com/holon-run/uxc/main/skills/notion-openapi-skill/references/notion-public.openapi.json
- - A Notion integration token or OAuth credential with content read access.
- For writes, the integration also needs the corresponding Notion insert/update content capabilities.
Scope
This skill covers a read-first Notion REST surface focused on traversal plus common content writes:
- - token identity validation
- title search for pages, data sources, and databases
- page lookup
- block lookup
- recursive traversal via block-children pagination
- page property retrieval
- page creation
- page updates, including trash/restore via INLINECODE6
- block append
- block updates
- block deletion
- data source retrieval and query
- legacy database retrieval and query
This skill does not cover:
- - full Notion REST coverage
- comments, file uploads, webhooks, page move, or schema mutation
- automatic recursive traversal loops inside one single command
Endpoint And Version
- - base URL: INLINECODE7
- required version header for this skill: INLINECODE8
The schema is intentionally curated around traversal and schema discovery. It is not a full dump of the Notion API.
Authentication
Notion Public API requires:
- - INLINECODE9
- INLINECODE10
Recommended: dedicated REST credential
If you already have an internal integration token:
CODEBLOCK0
How to get the internal integration token:
- 1. Open the Notion integrations dashboard and create an internal integration for your workspace.
- In the integration configuration page, copy the API secret shown by Notion.
- In Notion UI, open each target page, data source, or database and add this integration via
Share or Connections. - Use that API secret as
NOTION_API_TOKEN or pass it directly to uxc auth credential set.
Without connecting the integration to the target content, REST calls may authenticate successfully but still fail with access errors or return incomplete search results.
If you want OAuth-managed tokens for the REST host:
CODEBLOCK1
Advanced: reuse the same OAuth credential as notion-mcp
This is technically possible in uxc if the existing credential already has a valid Notion OAuth access token.
Important:
- - once an OAuth credential uses custom headers, include
Authorization=Bearer {{secret}} explicitly - adding
Notion-Version=2026-03-11 on the shared credential means the same header will also be sent to INLINECODE19 - that extra header is expected to be harmless, but this is an interoperability assumption rather than an explicit Notion guarantee
Shared-credential setup:
CODEBLOCK2
Validate the effective mapping when auth looks wrong:
CODEBLOCK3
Core Workflow
- 1. Use the fixed link command by default:
-
command -v notion-openapi-cli
- If missing, create it:
uxc link notion-openapi-cli https://api.notion.com/v1 --schema-url https://raw.githubusercontent.com/holon-run/uxc/main/skills/notion-openapi-skill/references/notion-public.openapi.json
- INLINECODE22
- 2. Inspect operation schema first:
-
notion-openapi-cli post:/search -h
-
notion-openapi-cli get:/blocks/{block_id}/children -h
-
notion-openapi-cli post:/pages -h
-
notion-openapi-cli patch:/blocks/{block_id}/children -h
- INLINECODE27
- 3. Prefer read validation before broader traversal:
-
notion-openapi-cli get:/users/me
-
notion-openapi-cli post:/search '{"query":"Roadmap","filter":{"property":"object","value":"page"},"page_size":10}'
- INLINECODE30
- 4. Traverse recursively outside the API call boundary:
- use
get:/blocks/{block_id}/children page by page
- for every returned child block with
has_children=true, call
get:/blocks/{block_id}/children again on that child ID
- 5. Use data source or legacy database reads to discover schema before property-sensitive queries:
-
notion-openapi-cli get:/data_sources/{data_source_id} data_source_id=<uuid>
-
notion-openapi-cli post:/data_sources/{data_source_id}/query data_source_id=<uuid> '{"page_size":25}'
- INLINECODE36
- 6. Execute writes only after explicit user confirmation:
- create page:
notion-openapi-cli post:/pages '{...}'
- append blocks:
notion-openapi-cli patch:/blocks/{block_id}/children '{...}'
- update page or block:
notion-openapi-cli patch:/pages/{page_id} '{...}'
- delete block: INLINECODE40
Operation Groups
Session / Discovery
- - INLINECODE41
- INLINECODE42
Page And Block Traversal
- - INLINECODE43
- INLINECODE44
- INLINECODE45
- INLINECODE46
Page And Block Writes
- - INLINECODE47
- INLINECODE48
- INLINECODE49
- INLINECODE50
- INLINECODE51
Data Source Reads
- - INLINECODE52
- INLINECODE53
Legacy Database Reads
- - INLINECODE54
- INLINECODE55
Guardrails
- - Keep automation on the JSON output envelope; do not use
--text. - Parse stable fields first:
ok, kind, protocol, data, error. - This skill fixes
Notion-Version at the credential/header layer instead of requiring it as an operation argument. Keep the credential header on 2026-03-11 unless you intentionally migrate the whole skill surface. - This skill is read-first, but it now includes common content writes. Always confirm intent before
post:/pages, patch:/pages/{page_id}, patch:/blocks/{block_id}/children, patch:/blocks/{block_id}, or delete:/blocks/{block_id}. - On Notion API version
2026-03-11, archived has been replaced by in_trash for request and response semantics. Prefer in_trash in update payloads. - INLINECODE73 supports up to 100 new children in one request and up to two levels of nested blocks in a single payload.
- INLINECODE74 updates block content, but it does not update child lists. Use
patch:/blocks/{block_id}/children to append nested content. - Prefer
data_sources endpoints over legacy databases endpoints for new workflows. Keep legacy database reads only for compatibility with older shared links and IDs. - INLINECODE78 returns only one nesting level at a time. Recursive traversal must be performed by repeated calls.
- Notion may return fewer results than
page_size; always check has_more and next_cursor. - INLINECODE82 is equivalent to
uxc https://api.notion.com/v1 --schema-url <notion_openapi_schema> <operation> ....
References
- - Usage patterns: INLINECODE84
- Curated OpenAPI schema: INLINECODE85
- Notion API reference: https://developers.notion.com/reference
- Retrieve a database: https://developers.notion.com/reference/retrieve-a-database
- Retrieve a block: https://developers.notion.com/reference/retrieve-a-block
- Versioning: https://developers.notion.com/reference/versioning
Notion 公共 API 技能
使用此技能通过 uxc + OpenAPI 运行 Notion 公共 API 操作。
复用 uxc 技能以获取共享执行、OAuth 和错误处理指导。
前提条件
- - uxc 已安装并可在 PATH 中使用。
- 可访问 https://api.notion.com/v1 的网络。
- 可访问精选的 OpenAPI 模式 URL:
- https://raw.githubusercontent.com/holon-run/uxc/main/skills/notion-openapi-skill/references/notion-public.openapi.json
- - 具有内容读取权限的 Notion 集成令牌或 OAuth 凭证。
- 对于写入操作,集成还需要相应的 Notion 插入/更新内容能力。
范围
此技能涵盖以读取优先的 Notion REST 接口,专注于遍历及常见内容写入:
- - 令牌身份验证
- 页面、数据源和数据库的标题搜索
- 页面查找
- 块查找
- 通过块子级分页进行递归遍历
- 页面属性检索
- 页面创建
- 页面更新,包括通过 in_trash 进行删除/恢复
- 块追加
- 块更新
- 块删除
- 数据源检索和查询
- 旧版数据库检索和查询
此技能不涵盖:
- - 完整的 Notion REST 覆盖
- 评论、文件上传、Webhook、页面移动或模式变更
- 在单个命令内自动递归遍历循环
端点和版本
- - 基础 URL:https://api.notion.com/v1
- 此技能所需的版本头:Notion-Version: 2026-03-11
该模式特意围绕遍历和模式发现进行精选。它不是 Notion API 的完整转储。
身份验证
Notion 公共 API 需要:
- - Authorization: Bearer
- Notion-Version: 2026-03-11
推荐:专用 REST 凭证
如果您已有内部集成令牌:
bash
uxc auth credential set notion-openapi \
--auth-type api_key \
--header Authorization=Bearer {{secret}} \
--header Notion-Version=2026-03-11 \
--secret-env NOTIONAPITOKEN
uxc auth binding add \
--id notion-openapi \
--host api.notion.com \
--path-prefix /v1 \
--scheme https \
--credential notion-openapi \
--priority 100
如何获取内部集成令牌:
- 1. 打开 Notion 集成仪表板,为您的空间创建一个内部集成。
- 在集成配置页面中,复制 Notion 显示的 API 密钥。
- 在 Notion UI 中,打开每个目标页面、数据源或数据库,通过 共享 或 连接 添加此集成。
- 将该 API 密钥用作 NOTIONAPITOKEN 或直接传递给 uxc auth credential set。
如果未将集成连接到目标内容,REST 调用可能成功进行身份验证,但仍会因访问错误而失败,或返回不完整的搜索结果。
如果您希望为 REST 主机使用 OAuth 管理的令牌:
bash
uxc auth oauth start notion-openapi \
--endpoint https://api.notion.com/v1 \
--redirect-uri http://127.0.0.1:8788/callback \
--client-id \
--scope read
uxc auth oauth complete notion-openapi \
--session-id \
--authorization-response http://127.0.0.1:8788/callback?code=...
uxc auth credential set notion-openapi \
--auth-type oauth \
--header Authorization=Bearer {{secret}} \
--header Notion-Version=2026-03-11
uxc auth binding add \
--id notion-openapi \
--host api.notion.com \
--path-prefix /v1 \
--scheme https \
--credential notion-openapi \
--priority 100
高级:复用与 notion-mcp 相同的 OAuth 凭证
如果现有凭证已具有有效的 Notion OAuth 访问令牌,这在技术上可以在 uxc 中实现。
重要提示:
- - 一旦 OAuth 凭证使用自定义头,请显式包含 Authorization=Bearer {{secret}}
- 在共享凭证上添加 Notion-Version=2026-03-11 意味着相同的头也将发送到 mcp.notion.com/mcp
- 预计该额外头是无害的,但这是一种互操作性假设,而非 Notion 的明确保证
共享凭证设置:
bash
uxc auth credential set notion-mcp \
--auth-type oauth \
--header Authorization=Bearer {{secret}} \
--header Notion-Version=2026-03-11
uxc auth binding add \
--id notion-openapi-shared \
--host api.notion.com \
--path-prefix /v1 \
--scheme https \
--credential notion-mcp \
--priority 100
当身份验证看起来有问题时,验证有效的映射:
bash
uxc auth binding match https://api.notion.com/v1
核心工作流程
- 1. 默认使用固定链接命令:
- command -v notion-openapi-cli
- 如果缺失,创建它:
uxc link notion-openapi-cli https://api.notion.com/v1 --schema-url https://raw.githubusercontent.com/holon-run/uxc/main/skills/notion-openapi-skill/references/notion-public.openapi.json
- notion-openapi-cli -h
- 2. 首先检查操作模式:
- notion-openapi-cli post:/search -h
- notion-openapi-cli get:/blocks/{block_id}/children -h
- notion-openapi-cli post:/pages -h
- notion-openapi-cli patch:/blocks/{block_id}/children -h
- notion-openapi-cli post:/data
sources/{datasource_id}/query -h
- 3. 在进行更广泛的遍历之前,优先进行读取验证:
- notion-openapi-cli get:/users/me
- notion-openapi-cli post:/search {query:Roadmap,filter:{property:object,value:page},page_size:10}
- notion-openapi-cli get:/blocks/{block
id}/children blockid=
page_size=100
- 4. 在 API 调用边界之外递归遍历:
- 使用 get:/blocks/{block_id}/children 逐页进行
- 对于每个返回的 haschildren=true 的子块,再次对该子 ID 调用 get:/blocks/{blockid}/children
- 5. 在属性敏感查询之前,使用数据源或旧版数据库读取来发现模式:
- notion-openapi-cli get:/datasources/{datasourceid} datasource_id=
- notion-openapi-cli post:/datasources/{datasourceid}/query datasourceid= {pagesize:25}
- notion-openapi-cli get:/databases/{databaseid} databaseid=
- 6. 仅在获得用户明确确认后执行写入操作:
- 创建页面:notion-openapi-cli post:/pages {...}
- 追加块:notion-openapi-cli patch:/blocks/{block_id}/children {...}
- 更新页面或块:notion-openapi-cli patch:/pages/{page_id} {...}
- 删除块:notion-openapi-cli delete:/blocks/{blockid} blockid=
操作组
会话/发现
- - get:/users/me
- post:/search
页面和块遍历
- - get:/pages/{pageid}
- get:/pages/{pageid}/properties/{propertyid}
- get:/blocks/{blockid}
- get:/blocks/{block_id}/children
页面和块写入
- - post:/pages
- patch:/pages/{pageid}
- patch:/blocks/{blockid}/children
- patch:/blocks/{blockid}
- delete:/blocks/{blockid}
数据源读取
- - get:/datasources/{datasourceid}
- post:/datasources/{datasourceid}/query
旧版数据库读取
- - get:/databases/{databaseid}
- post:/databases/{databaseid}/query
防护措施
- - 保持自动化在 JSON 输出信封上;不要使用 --text。
- 首先解析稳定字段:ok、kind、protocol、data、error。
- 此技能在凭证/头层