Documentation Index
Fetch the complete documentation index at: https://developers.notion.com/llms.txt
Use this file to discover all available pages before exploring further.
Log in
Authenticate with your Notion workspace:ntn login requires full workspace membership. Guests and restricted members cannot log in with the Notion CLI. If you need CLI access, ask a workspace admin to upgrade your role. See Personal access tokens for more on who can create tokens.Log in without a browser
On a remote machine, container, or CI runner that can’t open a browser,ntn login automatically falls back to a two-step flow:
- Run
ntn loginon the headless machine. It prints a URL, a verification code, and antn login pollcommand. - Open the URL in any browser, sign in, and confirm the verification code.
- Run
ntn login pollon the original machine to redeem the token.
ntn login again to start over.
For unattended use (CI, scripts, bots), prefer a personal access token instead.
Target a specific workspace
To run a single command against a non-default workspace without switching defaults, setNOTION_WORKSPACE_ID:
ntn debug.
Use a personal access token
For unattended use, authenticate with a personal access token (PAT) by exporting it asNOTION_API_TOKEN:
NOTION_API_TOKEN takes precedence over anything stored in the keychain, so the same shell can mix ntn login-based commands and PAT-based commands depending on what’s exported.
Inspect your session
Log out
config.json and workspaces.json files themselves stay in place — run ntn login to repopulate them.
Where credentials are stored
Tokens live in your OS credential store (Keychain on macOS, Secret Service on Linux) under the service namenotion-cli, with the workspace ID as the account.
Two files sit alongside them in the CLI config directory:
config.json— CLI version, default workspace per, and the optionalkeyringtoggle.workspaces.json— cached workspace IDs and names for the interactive picker.
NOTION_HOME if set, otherwise $XDG_CONFIG_HOME/notion, $HOME/.config/notion, or $HOME/.notion as fallbacks.
Opt out of the OS keychain
On systems without a usable keychain,ntn login fails with a keychain error. Common examples include Docker containers, CI runners, SSH sessions to a Linux server, etc.
Set NOTION_KEYRING=0 to store tokens in plain JSON at auth.json in the config directory instead. Treat that file like any other secret.
"keyring": false in config.json. The env var always wins.
Environment variables
| Variable | Purpose |
|---|---|
NOTION_API_TOKEN | When this is set, it’ll take precedence over ntn login’s keychain entry. Handy for scripts and CI. |
NOTION_WORKSPACE_ID | Override the default workspace for a single command. |
NOTION_KEYRING | Set to 0 to use file-based storage instead of the OS keychain. |
NOTION_HOME | Override the config directory. |
NOTION_ENV | Same as --env. Rarely needed. |
ntn login --help for the full list.