How to Create a Notion Internal Integration Token for AI Scripts
Generate a Notion API token and share a database with it so your own AI scripts can read and write Notion programmatically.
If you are building your own AI workflow, you need a Notion integration token rather than a chat connector. The token lets a script authenticate to the Notion API and read or update a database directly. This guide walks through creating the integration, sharing a database with it, and making your first authenticated call.
- A Notion account that can create integrations
- A database you want to read or write
- curl or Node installed for the test call
- About 12 minutes
Step 1: Create the integration
Go to notion.so/my-integrations and click New integration. Give it a name, pick the workspace, and choose the capabilities it needs. Read content is enough for analysis; add Insert and Update content if your script will write back.
Step 2: Copy the secret token
After submitting you land on the integration page. Copy the Internal Integration Secret. It starts with ntn_ and acts like a password, so store it in a secrets manager or an environment variable, never in committed code.
NOTION_TOKEN=ntn_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
NOTION_DATABASE_ID=replace_with_your_database_idStep 3: Share the database with the integration
An integration sees nothing until you explicitly share content with it. Open the target database, click the three-dot menu, choose Connections, and add your integration by name. The database id is the 32-character string in the database URL.
Step 4: Make a test query
Call the query endpoint for your database. A 200 response with a results array means the token and the share both worked. The Notion-Version header is required; use the current dated value.
Example: feed the results array into your AI script and ask it to triage tasks or write a daily summary back into a page. The same token now powers any read or write your capabilities allow.
Watch related tutorials
20:00
07:00
18:20
25:00
18:00
60:00