Prerequisites
- Node.js 18+
- A Notion integration token with write access to your workspace
- A Notion parent page where exported pages will be created
- A Moxn API key with read permissions (create one at Settings > API Keys in the web app)
Create a Notion Integration
If you don’t already have one from importing:- Go to notion.so/my-integrations and click New integration
- Name it (e.g. “Moxn Exporter”), select your workspace, and click Submit
- Copy the Internal Integration Secret — this is your
NOTION_TOKEN - In Notion, open the parent page where you want exports to land
- Click the … menu > Connections > Connect to and select your integration
The integration needs write access to the parent page. If you already have an integration from importing, you can reuse it.
Quick Start
Export all documents to Notion:You can set
NOTION_TOKEN and MOXN_API_KEY as environment variables instead of passing them as flags.How It Works
The export runs in two passes:1. Fetch
The tool fetches documents from the Moxn API matching your filters (path prefix, date range).2. Create Pages
Each document is created as a Notion page under your parent page. Sections become blocks:| KB Content | Notion Result |
|---|---|
| Section heading | H2 heading block |
| Rich text | Paragraph blocks with formatting |
| Code blocks | Code block with language |
| Images | Image blocks (uploaded to Notion) |
| Mermaid diagrams | Code block with mermaid language |
| Tables | Table blocks |
| Lists | Bulleted/numbered list blocks |
3. Resolve Links
After all pages are created, the tool makes a second pass to convert internal KB document links into Notion page mentions, preserving cross-references.4. Report
A summary shows what was created, skipped, or failed.Conflict Strategy
When you re-run the export and pages already exist in Notion:--conflict-strategy=skip (default) — existing pages are left untouched:
--conflict-strategy=update — existing pages are updated with the latest content:
The tool matches existing pages by title. If you renamed a document in Moxn after a previous export, it will be created as a new page rather than updating the old one.
CLI Options
| Option | Default | Description |
|---|---|---|
--api-key <key> | $MOXN_API_KEY | Moxn API key (required) |
--api-url <url> | https://moxn.dev | Moxn API base URL |
--notion-token <token> | $NOTION_TOKEN | Notion integration token (required) |
--parent-page-id <id> | (none) | Notion page under which to create pages (required) |
--base-path <path> | / | Only export documents under this path prefix |
--conflict-strategy <strategy> | skip | How to handle existing pages: skip or update |
--created-after <date> | (none) | Only include docs created after this date (ISO 8601) |
--created-before <date> | (none) | Only include docs created before this date (ISO 8601) |
--modified-after <date> | (none) | Only include docs modified after this date (ISO 8601) |
--modified-before <date> | (none) | Only include docs modified before this date (ISO 8601) |
--dry-run | false | Preview without making changes |
--json | false | Output results as JSON |
Examples
Export everything to Notion
Export a subtree
Update existing pages
Export recent changes
Dry run
Troubleshooting
Error: Notion token required
Error: Notion token required
Pass your token via
--notion-token or set the environment variable:Error: --parent-page-id is required
Error: --parent-page-id is required
You must specify the Notion page where exported content will be created. Get the page ID from the URL — it’s the 32-character hex string after the page title.
Pages are missing from Notion
Pages are missing from Notion
The Notion integration must have write access to the parent page. In Notion, open the parent page, click … > Connections > Connect to and select your integration.
Cross-references aren't linking correctly
Cross-references aren't linking correctly
Internal links are resolved in a second pass after all pages are created. If the target document wasn’t included in the export (e.g., filtered out by
--base-path), the link is left as plain text.Export is slow
Export is slow
The Notion API has rate limits (~3 requests/second). For large workspaces, expect the export to take a few minutes. Use
--base-path or date filters to export a smaller subset.Next Steps
Import from Notion
Import Notion content back into Moxn
Export to Local Files
Download as markdown files instead