Notion KB Integration
Index your Notion workspace or specific databases into TR-AI's knowledge base using an Internal Integration Token.
ntn_ or secret_). The integration must be shared with each page or database you want to index.Credentials required
| Field | Where to find it |
|---|---|
| Integration Token | https://www.notion.so/my-integrations → Your integration → Internal Integration Token |
| Database IDs (optional) | Notion database URL: notion.so/{workspace}/{DATABASE_ID}?v=... — the 32-character hex ID |
Step 1 — Create an Internal Integration
- 1Open IntegrationsGo to https://www.notion.so/my-integrations and click New integration.
- 2Configure capabilitiesSet the following capabilities:
- Read content — required to fetch page blocks.
- No user information — TR-AI does not need user data.
- 3Copy the tokenGo to the Secrets tab and copy the Internal Integration Token.
Step 2 — Share pages with the integration
The integration only has access to pages you explicitly share with it. For each page or database you want indexed:
- 1Open the pageOpen the Notion page or database you want TR-AI to index.
- 2Share with integrationClick the ••• menu → Add connections → search for your integration name → click Confirm.
Step 3 — Find your Database IDs (optional)
If you want to index specific databases only (rather than the entire workspace), find each database ID in the URL:
https://www.notion.so/myworkspace/My-KB-a1b2c3d4e5f6...?v=...
^^^^^^^^^^^^^^^^^^^^^^^^
This is the Database ID (32 hex chars, no dashes)Enter multiple database IDs as a comma-separated list in TR-AI. Leave blank to index all pages the integration can access.
Step 4 — Enter credentials in TR-AI
In your TR-AI Dashboard, open the Knowledge Base section and select Notion. Enter your Integration Token and optionally your Database IDs. Click Verify & Index. TR-AI will:
- Call
POST /v1/searchwithpage_size=1to verify the token. - If Database IDs are provided: query each database via
POST /v1/databases/{id}/query. - If no Database IDs: search the entire workspace via
POST /v1/searchwithfilter.value=page. - Fetch block content for each page recursively (depth up to 5 levels).
How TR-AI extracts content
Block types supported
TR-AI walks the block tree recursively and extracts text from:
paragraph,heading_1/2/3bulleted_list_item,numbered_list_item,to_do,togglequote,callout,codetable_row— cells joined with|child_page— recursed into (up to depth 5)
Blocks with has_children=true are recursed automatically. Image, video, file, embed, and divider blocks are skipped.
Pagination
Block children are fetched with page_size=100 and follow next_cursor until has_more=false. Page discovery also paginates exhaustively — no hard cap.
Concurrency
Page content is fetched with concurrency 6 to stay within Notion's rate limits.
Credential verification errors
| Error | Cause | Fix |
|---|---|---|
| 401 Unauthorized | Invalid or expired token | Regenerate the token at notion.so/my-integrations |
| 403 Forbidden | Integration not shared with any page | Share at least one page or database with the integration |
| No pages found | Integration has access but no pages match | Share the root page or specify correct Database IDs |
Notion API version
TR-AI sends Notion-Version: 2022-06-28 on all API calls.