Notion KB Integration

Notion KB Integration

Index your Notion workspace or specific databases into TR-AI's knowledge base using an Internal Integration Token.

Note:TR-AI uses a Notion Internal Integration Token (starts with ntn_ or secret_). The integration must be shared with each page or database you want to index.

Credentials required

FieldWhere to find it
Integration Tokenhttps://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

  1. 1
    Open Integrations
    Go to https://www.notion.so/my-integrations and click New integration.
  2. 2
    Configure capabilities
    Set the following capabilities:
    • Read content — required to fetch page blocks.
    • No user information — TR-AI does not need user data.
  3. 3
    Copy the token
    Go 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:

  1. 1
    Open the page
    Open the Notion page or database you want TR-AI to index.
  2. 2
    Share with integration
    Click the ••• menu → Add connections → search for your integration name → click Confirm.
Tip:Sharing a top-level page automatically grants access to all child pages. Share your root knowledge base page to index the entire tree.

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:

Database ID in 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/search with page_size=1 to 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/search with filter.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/3
  • bulleted_list_item, numbered_list_item, to_do, toggle
  • quote, callout, code
  • table_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

ErrorCauseFix
401 UnauthorizedInvalid or expired tokenRegenerate the token at notion.so/my-integrations
403 ForbiddenIntegration not shared with any pageShare at least one page or database with the integration
No pages foundIntegration has access but no pages matchShare the root page or specify correct Database IDs

Notion API version

TR-AI sends Notion-Version: 2022-06-28 on all API calls.