← Back to CLIs
Nardjo

notion-cli

Use the official Notion CLI (`ntn`) to call the Notion API, read/write pages as Markdown, query data sources, manage file uploads, and operate Notion Workers. Use when user mentions Notion CLI, ntn, Notion API from terminal, Notion pages, Notion databases/data sources, Notion files, Notion Workers, worker deploy, worker env vars, or querying/updating Notion content.

Install

$ npx api2cli install Nardjo/notion-cli

Details

Skill type: Official CLI
Auth type: bearer
Version: 0.14.0
Author: Nardjo
Views: 2

README

notion-cli

Use the official Notion CLI, invoked as ntn. This skill is intentionally a wrapper guide around Notion's own CLI, not a custom REST wrapper.

References:

When To Use This Skill

  • Call Notion API endpoints from the terminal
  • Inspect supported Notion API paths and endpoint docs
  • Read, create, update, or trash Notion pages
  • Query Notion data sources and resolve database IDs to data source IDs
  • Upload or list files through Notion file uploads
  • Create, deploy, inspect, execute, and debug Notion Workers
  • Manage Worker environment variables, syncs, OAuth, runs, and webhooks

Installed CLI

ntn --version
ntn --help

If ntn is missing:

curl -fsSL https://ntn.dev | bash

This machine also has an api2cli-compatible alias:

notion-cli --help

The alias delegates to ntn; prefer ntn in examples because it matches Notion's docs.

Authentication

Prefer an existing token in NOTION_API_TOKEN for API/page/data source/file commands:

echo "${NOTION_API_TOKEN:+set}"

If no token is available, use browser login for interactive workspace auth:

ntn login
ntn logout

Important env vars:

VariablePurpose
NOTION_API_TOKENAPI token; overrides keychain auth
NOTION_API_VERSIONOverrides Notion-Version
NOTION_WORKSPACE_IDSelects workspace without prompting
NOTION_KEYRING=0Uses file auth at ~/.config/notion/auth.json
NOTION_WORKERS_CONFIG_FILESelects workers.json path
NOTION_HOMEOverrides CLI state/cache root

Working Rules

  • Run ntn <command> --help before using unfamiliar syntax.
  • Use ntn api ls to discover supported public API endpoints.
  • Use ntn api <path> --docs and ntn api <path> --spec before constructing complex requests.
  • Prefer ntn pages get/create/update for Markdown page content.
  • Use ntn api for properties, templates, comments, custom endpoint methods, or endpoints not covered by convenience commands.
  • Confirm before destructive operations: ntn pages trash, ntn workers delete, ntn workers env unset, ntn workers env push, sync state reset, or --allow-deleting-content.
  • Never print or commit Notion tokens.

API Commands

CommandDescription
ntn api lsList supported public API endpoints; no auth required
ntn api ls --jsonEndpoint index as JSON
ntn api <path> --helpHelp for one endpoint
ntn api <path> --docsOfficial markdown docs for one endpoint
ntn api <path> --specReduced OpenAPI fragment for one endpoint
ntn api v1/users page_size==100GET with query param
ntn api v1/pages -d '{"parent":{"page_id":"abc123"}}'POST with JSON body
ntn api v1/pages parent[page_id]=abc123POST with inline body field
ntn api v1/pages/abc123 -X PATCH archived:=trueMethod override with typed JSON assignment

Inline input syntax:

SyntaxMeaningExample
Header:ValueHeaderAccept:application/json
name==valueQuery parampage_size==100
path=valueBody stringparent[page_id]=abc123
path:=jsonTyped JSON bodyarchived:=true

Body source rule: use exactly one of stdin JSON, -d/--data, or inline body inputs.

Pages

CommandDescription
ntn pages get <page-id>Retrieve page as Markdown with frontmatter
ntn pages get <page-id> --jsonRetrieve page as JSON, useful for truncated/unknown blocks
ntn pages create --content '# Title\n\nBody' --jsonCreate page from inline Markdown
ntn pages create --parent page:<id> < page.mdCreate page under page parent from stdin
ntn pages create --parent database:<id> < page.mdCreate page under database parent
ntn pages create --parent data-source:<id> < page.mdCreate page under data source parent
ntn pages update <page-id> --content '# Updated' --jsonReplace page content from inline Markdown
ntn pages update <page-id> < page.mdReplace page content from file/stdin
ntn pages update <page-id> --allow-deleting-content < page.mdAllow child page/database deletion during update; confirm first
ntn pages trash <page-id> --yesTrash page; confirm first

Flags: --content <markdown>, --parent page:<id>|database:<id>|data-source:<id>, --json, --plain, --notion-version <version>.

Data Sources

CommandDescription
ntn datasources resolve <database-id> --jsonResolve a database ID to contained data source IDs
ntn datasources query <data-source-id> --jsonQuery pages in a data source
ntn datasources query <id> --limit 50 --jsonLimit page size
ntn datasources query <id> --start-cursor <cursor> --jsonContinue pagination
ntn datasources query <id> -s "Name asc" -s "Created desc" --jsonSort results
ntn datasources query <id> --filter '{"property":"Done","checkbox":{"equals":true}}' --jsonFilter with raw Notion JSON
ntn datasources query <id> --filter-file filter.json --jsonRead filter from file
ntn datasources query <id> --filter-file - --jsonRead filter from stdin

Use datasources resolve first when the user gives a database ID. datasources query requires a data source ID.

Files

CommandDescription
ntn files create < file.pngUpload local bytes from stdin
ntn files create --filename photo.png --content-type image/png < /tmp/blob --jsonUpload stdin with explicit metadata
ntn files create --external-url https://example.com/photo.png --jsonCreate external URL upload
ntn files get <upload-id> --jsonRetrieve upload details
ntn files list --jsonList file uploads

Note: ntn files list currently returns only the first page.

Workers

CommandDescription
ntn workers new [directory]Scaffold Worker project
ntn workers new my-worker --install --gitScaffold, install deps, init git
ntn workers deploy --name <name> --jsonCreate/deploy new Worker
ntn workers deploy --jsonUpdate existing Worker from workers.json
ntn workers deploy --local-build --jsonBuild locally before upload
ntn workers list --jsonList Workers
ntn workers get [worker-id] --jsonShow Worker details
ntn workers create --name <name> --jsonCreate Worker without deploying code
ntn workers delete [worker-id] --yes --jsonDelete Worker; confirm first
ntn workers exec <key> -d '{"foo":"bar"}'Execute capability with JSON input
ntn workers exec <key> --streamStream capability output
ntn workers exec <key> --local --dotenv .envExecute locally with env file
ntn workers capabilities list --jsonList deployed capabilities
ntn workers usage --jsonShow current-period AI credit usage
ntn workers tuiOpen interactive terminal UI

Common Worker flags: --worker-id <id>, --workers-config-file <path>, --json, --plain.

Worker Env

CommandDescription
ntn workers env set KEY=value OTHER=valueSet one or more remote env vars
ntn workers env list [worker-id] --jsonList env var keys; values hidden
ntn workers env unset <key> --worker-id <id>Remove remote env var; confirm first
ntn workers env pull [worker-id] --file .env --yesPull remote env vars to file
ntn workers env pull [worker-id] --no-filePrint env vars instead of writing
ntn workers env push [worker-id] --file .env --yesPush local .env; confirm first

Worker Syncs

CommandDescription
ntn workers sync status [capability-key] --no-watch --jsonPrint sync status once
ntn workers sync status --interval 5Watch sync status
ntn workers sync trigger <key> --jsonTrigger sync now
ntn workers sync trigger <key> --preview --jsonPreview without writing target
ntn workers sync trigger <key> --context '<json>' --localResume preview locally
ntn workers sync pause <key> --jsonPause sync
ntn workers sync resume <key> --jsonResume sync
ntn workers sync state get <key> --jsonShow cursor/stats
ntn workers sync state reset <key> --jsonReset cursor/stats; confirm first

Worker OAuth, Runs, Webhooks

CommandDescription
ntn workers oauth show-redirect-urlPrint OAuth redirect URL
ntn workers oauth start <key> --jsonStart provider OAuth flow
ntn workers oauth token <key> --plainPrint OAuth token for debugging; avoid logging
ntn workers runs list [worker-id] --jsonList recent runs
ntn workers runs logs <run-id> --jsonFetch logs for a run
ntn workers webhooks list [worker-id] --jsonList webhook URLs

Diagnostics And Maintenance

CommandDescription
ntn doctorCheck auth, keychain, network, and config health
ntn updateUpdate CLI
ntn update --forceReinstall latest version
ntn completions zshGenerate shell completions

Output Format

ntn does not use the api2cli JSON envelope. Commands that support --json return Notion CLI's native JSON. Use --plain only for simple tab-separated scripting.

Verification

Minimum checks after install or update:

ntn --version
ntn --help
ntn api ls --plain
ntn doctor
Sponsors