Every capability’sDocumentation Index
Fetch the complete documentation index at: https://developers.notion.com/llms.txt
Use this file to discover all available pages before exploring further.
execute function receives a Notion API client as context.notion. This is the official @notionhq/client SDK (the same one you’d use outside of Workers):
Authentication
How the client is authenticated depends on how the capability runs:| Context | How it works |
|---|---|
| Tool called by a Custom Agent | The platform sets NOTION_API_TOKEN automatically. The client has the same permissions as the Custom Agent. No setup needed. |
Syncs, local testing, ntn workers exec | You must provide a token yourself. |
- Personal access token: acts as you, with access to everything your user has access to. Simpler to set up since you don’t need to manually connect it to each page.
- Internal integration token: acts as a bot, with access limited to pages explicitly connected via the Connections menu.
Create a token
Create a personal access token or an internal integration and copy the token.
.env file so the token is available when running ntn workers exec:
Common operations
The examples below use{ notion } destructured from the second argument to execute. They work the same way in tools and syncs:
Query a database
Retrieve a page
Create a page
Update page properties
Search
Read page content (blocks)
Permissions
What the client can access depends on the token type:- Custom Agent tools: the client has the same permissions as the Custom Agent.
- Personal access token: the client can access everything you can access in Notion.
- Internal integration token: the client can only access pages and databases that the integration has been explicitly connected to via the Connections menu.
Next steps
Syncs
Sync external data into Notion databases.
Agent tools
Build custom tools for Notion AI.
OAuth
Connect to third-party APIs with user authorization.
Secrets
Store API keys and credentials securely.