What You'll Build
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.
What You’ll Learn
This guide teaches you to:- Use natural language to connect to the Notion API directly with Continue CLI for powerful automation
- Configure Notion API access with proper permissions and security
- Run prompts in both TUI (interactive) and headless modes
- Create automated workflows that generate docs, manage tasks, and sync data
Prerequisites
Before starting, ensure you have:- Continue CLI installed (
npm i -g @continuedev/cli
) - A Notion workspace with Editor (or higher) access
- Node.js 18+ installed locally
- Continue account with Hub access
Agent usage requires credits – create a Continue API key at
hub.continue.dev/settings/api-keys
and store it as a secret.
1
Install Continue CLI
2
Create Notion Integration & Get API Key
- Go to Notion Integrations
- Click + New integration → give it a name (e.g. “Continue Integration”)
- Select your workspace
- Under Content Capabilities, enable:
- ✅ Read content
- ✅ Update content
- ✅ Insert content
- Under Comment Capabilities, enable:
- ✅ Read comments
- ✅ Insert comments
- Under User Capabilities, select:
- ✅ Read user information including email addresses
- Click Submit and copy the Internal Integration Secret (starts with
secret_
)
This token is your
NOTION_API_KEY
.
Keep it safe – you won’t be able to view it again.- In Notion, open each database or top-level page you want accessible → Share → Invite your new integration → Full access.
3
Configure API Access
Set your Notion API key as an environment variable in your terminal:
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.
When you close the terminal, the variable won’t persist. To test your API key, run the curl command below in the same session.
4
Add Workspace Keys to Terminal Session
Depending on what you want
cn
to accomplish, you’ll need to add your Notion workspace keys to the terminal session. The workspace key is your Notion database ID. Run the following command:You can find your database ID by:
- Opening your Notion changelog database
- Looking at the URL - it will be something like: https://www.notion.so/your-workspace/DATABASE_ID?v=…
- The DATABASE_ID is the long string of characters between the last / and the ?
Running Continue AI Agent with Notion API
🚀 Choose Your Interface
Continue CLI offers two powerful modes for Notion automation:
TUI mode for interactive workflows and Headless mode for automated scripts.
- 🖥️ TUI Mode (Interactive)
- 🤖 Headless Mode (Automated)
1
Launch Interactive Mode
Navigate to your project directory and run:
2
Run Your First Prompt
In the TUI interface, enter:
TUI mode lets you review and approve each action before execution,
perfect for learning and debugging.
API Connection Notes
API Connection Notes
- Environment variable
NOTION_API_KEY
must be set before running Continue CLI - Continue automatically uses the API key to authenticate with Notion
- No need for manual curl commands - just reference “the API key stored in this session”
- For complex workflows, Continue maintains the API connection throughout
- Consider creating aliases or scripts for frequently used prompts
Quick Start Example
Working example that demonstrates the power of Continue with Notion API:📊 Weekly Sprint Summary
This exact command has been tested and works:What this does:
- Connects to your Notion workspace using the API key
- Analyzes your sprint data
- Calculates completion metrics
- Creates a comprehensive retrospective with visualizations
Example Prompts & Workflows
With the Notion API configured, you can use natural language prompts to automate your workspace. Here are examples for both TUI and headless modes:API Documentation
TUI Mode:Headless Mode:
Sprint Planning from Code
Headless Mode (Automated):
Changelog from PRs
Daily Standup Automation
Advanced Workflows
Notion + GitHub
Requires GitHub repository access. To add GitHub access, update your integration settings.
Test Coverage Report
Blog Post Review
Weekly Report Generation
Security Best Practices
Protect Your API Keys:
- Never commit
NOTION_API_KEY
to version control - Use environment variables or secure secret managers
- Rotate API keys every 90 days
- Grant integration access only to required databases/pages
- Monitor API usage through Notion’s integration dashboard
- Use
.env
files with.gitignore
for local development
Next Steps
- Create a GitHub Actions workflow to automate changelog generation on releases
- Build a daily standup bot that runs every morning and posts to Slack
- Set up database templates in Notion for consistent formatting
- Explore batch operations to update multiple pages efficiently
- Implement error handling for API rate limits and network issues
Troubleshooting
Common Issues and Solutions
Common Issues and Solutions
API Key Not Found:
- Ensure
NOTION_API_KEY
is exported in your current shell session - Check for typos in the environment variable name
- Verify the key starts with
secret_
- Share the specific database with your integration in Notion
- Ensure the integration has the correct permissions (Read, Write, Insert)
- Verify Continue CLI has internet access
- Check network connectivity to api.notion.com
- Ensure your Notion workspace allows API access
- Notion API has rate limits (3 requests per second)
- Implement exponential backoff for automated scripts
- Consider batching operations when possible