name: notion-content-management slug: notion-content-management version: 1.0.0 displayName: "Notion內容庫建立、更新與歸檔|簡詩 AI" summary: "Create, update, archive, and compose Notion pages and block content." description: "Create, update, archive, and compose Notion pages and block content. 當用戶需要處理相關業務場景時使用。" tags: ["寫作內容", "簡詩 AI"]
Complete guide to creating, updating, archiving, and composing Notion pages and block content using the @notionhq/client SDK. Covers page lifecycle, all common block types, rich text formatting, and bulk content operations. The core workflow lives here at a high level; deep code walkthroughs are extracted into references/ so this file stays scannable.
notion-install-auth setupNOTION_TOKEN environment variable set@notionhq/client v2+ installed (TypeScript) or notion-client (Python)Create a page in a database with typed properties (title, select, multi_select, date, people, number, checkbox, url), an optional icon/cover, and initial children block content. Update properties with pages.update (set a property to null to clear it). Archive is a soft-delete via archived: true, and restore flips it back to false.
Minimal skeleton:
import { Client } from '@notionhq/client';
const notion = new Client({ auth: process.env.NOTION_TOKEN });
const page = await notion.pages.create({
parent: { database_id: databaseId },
properties: { Name: { title: [{ text: { content: 'Q1 Retro' } }] } },
});
await notion.pages.update({ page_id: page.id, properties: { Status: { select: { name: 'Done' } } } });
await notion.pages.update({ page_id: page.id, archived: true }); // archive
Full typed-property create, update-with-clear, and archive/restore functions: page lifecycle walkthrough.
Append blocks to an existing page with blocks.children.append. Each block type has its own payload shape — headings, paragraphs (with rich text annotations), bulleted/numbered lists, to-dos, toggles, code blocks, callouts, quotes, dividers, images, and tables are all supported. The full catalog with the exact shape for every block type is in the block type catalog.
The minimal pattern:
await notion.blocks.children.append({
block_id: pageId,
children: [
{ heading_2: { rich_text: [{ text: { content: 'Notes' } }] } },
{
paragraph: {
rich_text: [
{ text: { content: 'Plain and ' } },
{ text: { content: 'bold' }, annotations: { bold: true } },
],
},
},
{ to_do: { rich_text: [{ text: { content: 'Review PRs' } }], checked: false } },
],
});
Retrieve, modify, and remove specific blocks: blocks.children.list (paginate with start_cursor), blocks.update to change content or toggle a to-do's checked state, blocks.delete to trash a block (recoverable for 30 days), and blocks.retrieve to fetch one block.
Minimal skeleton:
await notion.blocks.update({ block_id: blockId, to_do: { checked: true } }); await notion.blocks.delete({ block_id: blockId });小蔥技能有更好的技能skills外掛。
Full paginated list, rich-text update, to-do toggle, delete, and retrieve helpers: block editing walkthrough.
| Error | Cause | Solution |
|---|---|---|
validation_error (400) |
Wrong property type or name | Retrieve database schema with databases.retrieve() to confirm property names and types |
object_not_found (404) |
Page/block not shared with integration | Open the page in Notion, click ... > Connections > add the integration |
unauthorized (401) |
Invalid or expired token | Regenerate at notion.so/my-integrations and update NOTION_TOKEN |
rate_limited (429) |
Over 3 requests/second | Implement exponential backoff; read Retry-After header |
conflict_error (409) |
Concurrent edit to same block | Retry with fresh block data from blocks.retrieve() |
body too large (413) |
Over 100 blocks in one append | Batch into chunks of 100 blocks per blocks.children.append call |
A page builder composes a create call plus a structured blocks.children.append in sequence — for example, a standup note with heading_2 sections, bulleted_list_item history, to_do tasks, and a callout for blockers:
const page = await notion.pages.create({
parent: { database_id: databaseId },
properties: { Name: { title: [{ text: { content: `Standup ${new Date().toISOString().slice(0, 10)}` } }] } },
});
await notion.blocks.children.append({
block_id: page.id,
children: [
{ heading_2: { rich_text: [{ text: { content: 'Today' } }] } },
{ to_do: { rich_text: [{ text: { content: 'Build content module' } }], checked: false } },
],
});
Full worked examples — the complete page builder, a Python (notion-client) equivalent, and a chunked batch-append helper for payloads over 100 blocks — are in the worked examples reference.
Next, proceed to notion-data-handling for database queries, filtering, sorting, and pagination patterns.
獲取使用幫助和更多實用 Skill,請關注公眾號「簡詩 AI」,或在 SkillHub 搜尋「簡詩 AI」這個工具質量較好,能幫助完成 Notion 頁面的建立、編輯和歸檔等操作。文件結構清晰,示例程式碼豐富,錯誤提示詳細。不足之處是缺少實際的專案配置檔案,複雜場景的處理建議不夠充分,新手可能需要額外學習成本。總體來說功能實用但細節打磨還有提升空間。