Connectors

Browse docs

Connectors

Tap to expand

Contribute

ConnectorsUpdated 2026-03-18

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

  1. Notion Integration Token

  2. Share Pages with Integration

    • Open each Notion page you want to sync
    • Click ShareInvite
    • Search for your integration name

Configuration

Creating a Notion Source

bash
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

OptionTypeDescriptionDefault
workspace_idstringNotion workspace IDRequired
page_idsarraySpecific pages to syncAll accessible
database_idsarrayNotion databases to syncAll accessible
include_childrenbooleanSync child pages recursivelytrue
include_filesbooleanInclude file attachmentstrue
max_depthnumberMaximum page depth5
sync_modestringfull or incrementalincremental

Getting Notion IDs

Page ID — Found in the page URL:

code
https://notion.so/myworkspace/{page_id}?v=...
                       ^^^^^^^^^^^^^^

Database ID — Found in the database URL:

code
https://notion.so/myworkspace/{database_id}?v=...
                         ^^^^^^^^^^^^^^

Syncing

Trigger Sync

bash
SOURCE_ID="src_xyz789"

curl -X POST "https://api.retaindb.com/v1/sources/$SOURCE_ID/sync" \
  -H "Authorization: Bearer $RETAINDB_API_KEY"

Response

json
{
  "id": "job_abc123",
  "source_id": "src_xyz789",
  "status": "queued",
  "created_at": "2026-03-07T12:00:00Z"
}

Check Status

bash
curl "https://api.retaindb.com/v1/sync-jobs/job_abc123" \
  -H "Authorization: Bearer $RETAINDB_API_KEY"

Response

json
{
  "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:

bash
# 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"}'
Info
Incremental sync only processes pages modified since the last sync, making it much faster.

Searching Synced Content

Search your Notion knowledge base:

bash
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

json
{
  "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

bash
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

bash
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 TypeHandling
TextDirect content
HeadingPreserved with # markers
CodeFenced code blocks
ImageAlt text only (no OCR)
TableTab-separated values
CalloutPreserved as quoted text
EmbedLink preserved

Webhooks for Updates

Set up webhooks to auto-sync when Notion pages change:

bash
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"
  }'
Info
For webhooks to work, your server must be publicly accessible and accept POST requests from RetainDB.

Troubleshooting

"Page not found" Errors

Cause: Page wasn't shared with the integration

Solution:

  1. Open the page in Notion
  2. Click ShareInvite
  3. Search for your integration name
  4. Click Invite

Empty Search Results

Cause: Pages not indexed yet or sync failed

Solution:

  1. Check sync job status
  2. Verify pages are shared with integration
  3. Trigger a new sync

Rate Limiting

Cause: Too many pages or frequent syncs

Solution:

  1. Reduce sync frequency
  2. Limit page_ids to essential pages
  3. Use max_depth to limit recursion

Stale Content

Cause: Incremental sync not working

Solution:

bash
# 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:

json
{
  "page_ids": ["engineering_wiki_root"],
  "include_children": true
}

2. Use Database Filters

Sync only relevant database entries:

json
{
  "database_ids": ["projects_db"],
  "database_filters": {
    "Status": {"contains": "Active"},
    "Type": {"equals": "Documentation"}
  }
}

3. Schedule Regular Syncs

Set up hourly or daily syncs:

bash
# 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

bash
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.