docs/guides/notion-continue-guide.mdx
import { OSAutoDetect } from '/snippets/OSAutoDetect.jsx' import CLIInstall from '/snippets/cli-install.mdx'
<OSAutoDetect /> <Card title="What You'll Build" icon="notion">A workflow that lets you query, update, and create Notion pages or database entries from natural-language prompts. Generate PRDs, sprint tasks, meeting notes, or status reports automatically – perfect for individual developers and cross-functional teams.
</Card>This guide teaches you to:
Before starting, ensure you have:
Agent usage requires credits – create a Continue API key at continue.dev/settings/api-keys and store it as a secret.
</Warning> <Steps> <Step title="Install Continue CLI"> <CLIInstall />Verify installation:
```bash
cn --version
```
<Info>
This token is your `NOTION_API_KEY`.
Keep it safe – you won't be able to view it again.
</Info>
8. In Notion, open each database or top-level page you want accessible → **Share** → **Invite** your new integration → **Full access**.
```bash
export NOTION_API_KEY="secret_xxx"
```
<Tip>
Running this command sets your API key for the current terminal session only.
When you close the terminal, the variable won't persist. To test your API key, run the curl command below in the same session.
```bash
curl -H "Authorization: Bearer $NOTION_API_KEY" \
-H "Notion-Version: 2022-06-28" \
https://api.notion.com/v1/databases
```
</Tip>
```bash
export NOTION_DATABASE_ID="your_database_id"
```
<Tip>
You can find your database ID by:
1. Opening your Notion changelog database
2. Looking at the URL - it will be something like:
https://www.notion.so/your-workspace/DATABASE_ID?v=...
3. The DATABASE_ID is the long string of characters between the last / and the ?
</Tip>
Continue CLI offers two powerful modes for Notion automation: TUI mode for interactive workflows and Headless mode for automated scripts.
</Card> <Tabs> <Tab title="🖥️ TUI Mode (Interactive)"><Steps>
<Step title="Launch Interactive Mode">
Navigate to your project directory and run:
```bash
cn
```
</Step>
<Step title="Run Your First Prompt">
In the TUI interface, enter:
```
1. Fetch my Notion databases using the Notion API key
and Database ID stored in this terminal session.
2. Look at the last week of Merged GitHub PRs, and create
a changelog entry in Notion summarizing the features and breaking changes.
```
<Tip>
TUI mode lets you review and approve each action before execution,
perfect for learning and debugging.
</Tip>
</Step>
</Steps>
**Flags explained:**
- `-p`: Run without TUI interface
- `--auto`: Execute without manual approval
<Warning>
Always test prompts in TUI mode first before running
them with `--auto` in production.
</Warning>
</Step>
</Steps>
NOTION_API_KEY must be set before running Continue CLIWorking example that demonstrates the power of Continue with Notion API:
<Card title="📊 Weekly Sprint Summary" icon="chart-line">This exact command has been tested and works:
# Weekly Sprint Summary
cn -p --auto "
1. Fetch Notion Sprint database
2. Analyze completed tasks vs planned
3. Generate sprint retrospective page
4. Add velocity metrics and burndown chart"
What this does:
With the Notion API configured, you can use natural language prompts to automate your workspace. Here are examples for both TUI and headless modes:
<CardGroup cols={1}> <Card title="API Documentation" icon="code"> **TUI Mode:** ```bash cn " 1. Fetch my Notion databases using the API key and secrets stored in this session 2. Generate API documentation for all endpoints in src/api/routes with request/response schemas 3. Create a page in Technical Docs database " ```**Headless Mode:**
```bash
cn -p --auto "Fetch my Notion databases using the API key and secrets stored in this session. Generate API docs
for src/api/routes and save to Notion in Technical Docs database"
```
<Info>
Requires GitHub repository access. To add GitHub access, update your [integration settings](https://continue.dev/settings/integrations).
</Info>
Protect Your API Keys:
NOTION_API_KEY to version control.env files with .gitignore for local developmentAPI Key Not Found:
NOTION_API_KEY is exported in your current shell sessionsecret_Database Access Denied:
Connection Issues:
Rate Limiting: