Notion Connector
Sync Notion workspaces, pages, and databases into RetainDB for powerful knowledge base search.
The Notion connector indexes your workspace content, enabling AI-powered search across documentation, wikis, and databases.
Use Cases
- Knowledge Base Search — Find relevant docs across Notion
- Team Wiki — Query company wikis and documentation
- Project Docs — Search project specifications and notes
- Onboarding — Help new team members find relevant docs
Prerequisites
-
Notion Integration Token
- Go to Notion My Integrations
- Create a new integration
- Copy the "Internal Integration Token"
-
Share Pages with Integration
- Open each Notion page you want to sync
- Click Share → Invite
- Search for your integration name
Configuration
Creating a Notion Source
curl -X POST "https://api.retaindb.com/v1/projects/proj_abc123/sources" \
-H "Authorization: Bearer $RETAINDB_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Engineering Wiki",
"connectorType": "notion",
"config": {
"workspace_id": "ws_abc123",
"page_ids": ["page_id_1", "page_id_2"],
"database_ids": ["db_id_1"],
"include_children": true,
"sync_mode": "incremental"
}
}'Configuration Options
| Option | Type | Description | Default |
|---|---|---|---|
workspace_id | string | Notion workspace ID | Required |
page_ids | array | Specific pages to sync | All accessible |
database_ids | array | Notion databases to sync | All accessible |
include_children | boolean | Sync child pages recursively | true |
include_files | boolean | Include file attachments | true |
max_depth | number | Maximum page depth | 5 |
sync_mode | string | full or incremental | incremental |
Getting Notion IDs
Page ID — Found in the page URL:
https://notion.so/myworkspace/{page_id}?v=...
^^^^^^^^^^^^^^Database ID — Found in the database URL:
https://notion.so/myworkspace/{database_id}?v=...
^^^^^^^^^^^^^^Syncing
Trigger Sync
SOURCE_ID="src_xyz789"
curl -X POST "https://api.retaindb.com/v1/sources/$SOURCE_ID/sync" \
-H "Authorization: Bearer $RETAINDB_API_KEY"Response
{
"id": "job_abc123",
"source_id": "src_xyz789",
"status": "queued",
"created_at": "2026-03-07T12:00:00Z"
}Check Status
curl "https://api.retaindb.com/v1/sync-jobs/job_abc123" \
-H "Authorization: Bearer $RETAINDB_API_KEY"Response
{
"id": "job_abc123",
"source_id": "src_xyz789",
"status": "completed",
"progress": {
"pages_indexed": 250,
"databases_indexed": 15,
"blocks_processed": 5000
},
"started_at": "2026-03-07T12:00:00Z",
"completed_at": "2026-03-07T12:08:00Z"
}Incremental Sync
Notion connector tracks page changes automatically:
# Incremental sync (default)
curl -X POST "https://api.retaindb.com/v1/sources/src_xyz789/sync" \
-H "Authorization: Bearer $RETAINDB_API_KEY" \
-d '{"sync_mode": "incremental"}'Searching Synced Content
Search your Notion knowledge base:
curl -X POST "https://api.retaindb.com/v1/memory/search" \
-H "Authorization: Bearer $RETAINDB_API_KEY" \
-d '{
"user": "employee@example.com",
"query": "deployment process",
"filters": {
"source": "notion:engineering-wiki"
},
"topK": 10
}'Search Results
{
"results": [
{
"id": "mem_abc123",
"content": "# Deployment Process\n\n## Production Deployment\n\n1. Run tests locally\n2. Create PR to main\n3. Wait for CI approval\n4. Merge and deploy...",
"source": "notion:engineering-wiki",
"source_type": "page",
"notion_url": "https://notion.so/page-id",
"score": 0.91
}
]
}Filtering Results
By Notion Page
curl -X POST "https://api.retaindb.com/v1/memory/search" \
-H "Authorization: Bearer $RETAINDB_API_KEY" \
-d '{
"user": "employee@example.com",
"query": "API documentation",
"filters": {
"source": "notion",
"notion_page_id": "specific_page_id"
}
}'By Database Property
curl -X POST "https://api.retaindb.com/v1/memory/search" \
-H "Authorization: Bearer $RETAINDB_API_KEY" \
-d '{
"user": "employee@example.com",
"query": "status update",
"filters": {
"source": "notion:engineering-wiki",
"notion_database_status": "In Progress"
}
}'Handling Notion Blocks
Notion pages are converted to plain text. Here's how different blocks are handled:
| Block Type | Handling |
|---|---|
| Text | Direct content |
| Heading | Preserved with # markers |
| Code | Fenced code blocks |
| Image | Alt text only (no OCR) |
| Table | Tab-separated values |
| Callout | Preserved as quoted text |
| Embed | Link preserved |
Webhooks for Updates
Set up webhooks to auto-sync when Notion pages change:
curl -X POST "https://api.retaindb.com/v1/webhooks" \
-H "Authorization: Bearer $RETAINDB_API_KEY" \
-d '{
"url": "https://your-server.com/notion-webhook",
"events": ["notion.page_updated", "notion.page_created"],
"source_id": "src_xyz789"
}'Troubleshooting
"Page not found" Errors
Cause: Page wasn't shared with the integration
Solution:
- Open the page in Notion
- Click Share → Invite
- Search for your integration name
- Click Invite
Empty Search Results
Cause: Pages not indexed yet or sync failed
Solution:
- Check sync job status
- Verify pages are shared with integration
- Trigger a new sync
Rate Limiting
Cause: Too many pages or frequent syncs
Solution:
- Reduce sync frequency
- Limit
page_idsto essential pages - Use
max_depthto limit recursion
Stale Content
Cause: Incremental sync not working
Solution:
# Force full re-sync
curl -X POST "https://api.retaindb.com/v1/sources/src_xyz789/sync" \
-H "Authorization: Bearer $RETAINDB_API_KEY" \
-d '{"sync_mode": "full"}'Best Practices
1. Share Top-Level Pages Only
Instead of sharing every page, share parent pages with include_children: true:
{
"page_ids": ["engineering_wiki_root"],
"include_children": true
}2. Use Database Filters
Sync only relevant database entries:
{
"database_ids": ["projects_db"],
"database_filters": {
"Status": {"contains": "Active"},
"Type": {"equals": "Documentation"}
}
}3. Schedule Regular Syncs
Set up hourly or daily syncs:
# In your cron job
0 * * * * curl -X POST "https://api.retaindb.com/v1/sources/src_xyz789/sync" \
-H "Authorization: Bearer $RETAINDB_API_KEY"4. Monitor Index Health
curl "https://api.retaindb.com/v1/sources/src_xyz789" \
-H "Authorization: Bearer $RETAINDB_API_KEY"Next step
Was this page helpful?
Your feedback helps us prioritize docs improvements weekly.