Notion

Learn how to use Notion with Composio

Overview

SLUG: NOTION

Description

Notion centralizes notes, docs, wikis, and tasks in a unified workspace, letting teams build custom workflows for collaboration and knowledge management

Authentication Details

client_id
stringRequired
client_secret
stringRequired
oauth_redirect_uri
stringDefaults to https://backend.composio.dev/api/v1/auth-apps/add
scopes
string
bearer_token
string
generic_api_key
stringRequired

Connecting to Notion

Create an auth config

Use the dashboard to create an auth config for the Notion toolkit. This allows you to connect multiple Notion accounts to Composio for agents to use.

1

Select App

Navigate to the Notion toolkit page and click “Setup Integration”.

2

Configure Auth Config Settings

Select among the supported auth schemes of and configure them here.

3

Create and Get auth config ID

Click “Create Integration”. After creation, copy the displayed ID starting with ac_. This is your auth config ID. This is not a sensitive ID — you can save it in environment variables or a database. This ID will be used to create connections to the toolkit for a given user.

Connect Your Account

Using OAuth2

1from composio import Composio
2from composio.types import auth_scheme
3
4# Replace these with your actual values
5notion_auth_config_id = "ac_YOUR_NOTION_CONFIG_ID" # Auth config ID created above
6user_id = "0000-0000-0000" # UUID from database/application
7
8composio = Composio()
9
10
11def authenticate_toolkit(user_id: str, auth_config_id: str):
12 connection_request = composio.connected_accounts.initiate(
13 user_id=user_id,
14 auth_config_id=auth_config_id,
15 )
16
17 print(
18 f"Visit this URL to authenticate Notion: {connection_request.redirect_url}"
19 )
20
21 # This will wait for the auth flow to be completed
22 connection_request.wait_for_connection(timeout=15)
23 return connection_request.id
24
25
26connection_id = authenticate_toolkit(user_id, notion_auth_config_id)
27
28# You can also verify the connection status using:
29connected_account = composio.connected_accounts.get(connection_id)
30print(f"Connected account: {connected_account}")

Using API Key

1from composio import Composio
2from composio.types import auth_scheme
3
4# Replace these with your actual values
5notion_auth_config_id = "ac_YOUR_NOTION_CONFIG_ID" # Auth config ID created above
6user_id = "0000-0000-0000" # UUID from database/app
7
8composio = Composio()
9
10def authenticate_toolkit(user_id: str, auth_config_id: str):
11 # Replace this with a method to retrieve an API key from the user.
12 # Or supply your own.
13 user_api_key = input("[!] Enter API key")
14
15 connection_request = composio.connected_accounts.initiate(
16 user_id=user_id,
17 auth_config_id=auth_config_id,
18 config={"auth_scheme": "API_KEY", "val": user_api_key}
19 )
20
21 # API Key authentication is immediate - no redirect needed
22 print(f"Successfully connected Notion for user {user_id}")
23 print(f"Connection status: {connection_request.status}")
24
25 return connection_request.id
26
27
28connection_id = authenticate_toolkit(user_id, notion_auth_config_id)
29
30# You can verify the connection using:
31connected_account = composio.connected_accounts.get(connection_id)
32print(f"Connected account: {connected_account}")

Tools

Executing tools

To prototype you can execute some tools to see the responses and working on the Notion toolkit’s playground

Python
1from composio import Composio
2from openai import OpenAI
3import json
4
5openai = OpenAI()
6composio = Composio()
7
8# User ID must be a valid UUID format
9user_id = "0000-0000-0000" # Replace with actual user UUID from your database
10
11tools = composio.tools.get(user_id=user_id, toolkits=["NOTION"])
12
13print("[!] Tools:")
14print(json.dumps(tools))
15
16def invoke_llm(task = "What can you do?"):
17 completion = openai.chat.completions.create(
18 model="gpt-4o",
19 messages=[
20 {
21 "role": "user",
22 "content": task, # Your task here!
23 },
24 ],
25 tools=tools,
26 )
27
28 # Handle Result from tool call
29 result = composio.provider.handle_tool_calls(user_id=user_id, response=completion)
30 print(f"[!] Completion: {completion}")
31 print(f"[!] Tool call result: {result}")
32
33invoke_llm()

Tool List

Tool Name: Add content to Notion page

Description

Appends a single content block to a notion page or a parent block (must be page, toggle, to-do, bulleted/numbered list, callout, or quote); invoke repeatedly to add multiple blocks.

Action Parameters

after
string
content_block
objectRequired
parent_block_id
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Create comment

Description

Adds a comment to a notion page (via `parent page id`) or to an existing discussion thread (via `discussion id`); cannot create new discussion threads on specific blocks (inline comments).

Action Parameters

comment
objectRequired
discussion_id
string
parent_page_id
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Create Notion Database

Description

Creates a new notion database as a subpage under a specified parent page with a defined properties schema; use this action exclusively for creating new databases.

Action Parameters

parent_id
stringRequired
properties
arrayRequired
title
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Create Notion page

Description

Creates a new page in a notion workspace.

Action Parameters

cover
string
icon
string
parent_id
stringRequired
title
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Delete a block

Description

Archives a notion block, page, or database using its id, which sets its 'archived' property to true (like moving to "trash" in the ui) and allows it to be restored later.

Action Parameters

block_id
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Fetch comments

Description

Fetches unresolved comments for a specified notion block or page id.

Action Parameters

block_id
stringRequired
page_size
integerDefaults to 100
start_cursor
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Fetch Notion Data

Description

Simplifies the retrieval of notion items by abstracting the native notion api's complexity.

Action Parameters

get_all
boolean
get_databases
boolean
get_pages
boolean
page_size
integerDefaults to 100
query
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Fetch Database

Description

Fetches a notion database's structural metadata (properties, title, etc.) via its `database id`, not the data entries; `database id` must reference an existing database.

Action Parameters

database_id
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Fetch database row

Description

Retrieves a notion database row's properties and metadata; use a different action for page content blocks.

Action Parameters

page_id
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get About Me

Description

Retrieves the user object for the bot associated with the current notion integration token, typically to obtain the bot's user id for other api operations.

Action Parameters

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get about user

Description

Retrieves detailed information about a specific notion user, such as their name, avatar, and email, based on their unique user id.

Action Parameters

user_id
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Insert row database

Description

Creates a new page (row) in a specified notion database.

Action Parameters

child_blocks
array
cover
string
database_id
stringRequired
icon
string
properties
array

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: List users

Description

Retrieves a paginated list of users (excluding guests) from the notion workspace; the number of users returned per page may be less than the requested `page size`.

Action Parameters

page_size
integerDefaults to 30
start_cursor
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Query database

Description

Queries a notion database for pages (rows), where rows are pages and columns are properties; ensure sort property names correspond to existing database properties.

Action Parameters

database_id
stringRequired
page_size
integerDefaults to 2
sorts
array
start_cursor
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Retrieve Comment

Description

Tool to retrieve a specific comment by its id. use when you have a comment id and need to fetch its details.

Action Parameters

comment_id
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Retrieve Database Property

Description

Tool to retrieve a specific property object of a notion database. use when you need to get details about a single database column/property.

Action Parameters

database_id
stringRequired
property_id
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Update Page

Description

Tool to update the properties, icon, cover, or archive status of a page. use when you need to modify existing page attributes.

Action Parameters

archived
boolean
cover
object
icon
object
page_id
stringRequired
properties
object

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Update row database

Description

Updates or archives an existing notion database row (page) using its `row id`, allowing modification of its icon, cover, and/or properties; ensure the target page is accessible and property details (names/ids and values) align with the database schema and specified formats.

Action Parameters

cover
string
delete_row
boolean
icon
string
properties
array
row_id
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Update database schema

Description

Updates an existing notion database's title, description, and/or properties; at least one of these attributes must be provided to effect a change.

Action Parameters

database_id
stringRequired
description
string
properties
array
title
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Append block children

Description

Appends new child blocks to a specified parent block or page in notion, ideal for adding content within an existing structure (e.g., list items, toggle content) rather than creating new pages; the parent must be able to accept children.

Action Parameters

after
string
block_id
stringRequired
children
arrayRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Archive Notion Page

Description

Archives (moves to trash) or unarchives (restores from trash) a specified notion page.

Action Parameters

archive
booleanDefaults to True
page_id
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Duplicate page

Description

Duplicates a notion page, including all its content, properties, and nested blocks, under a specified parent page or workspace.

Action Parameters

page_id
stringRequired
parent_id
stringRequired
title
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Fetch Notion block

Description

Retrieves a notion block (or page, as pages are blocks) using its valid uuid; if the block has children, use a separate action to fetch them.

Action Parameters

block_id
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Fetch Notion Block Children

Description

Retrieves a paginated list of direct, first-level child block objects for a given parent notion block or page id; use block ids from the response for subsequent calls to access deeply nested content.

Action Parameters

block_id
stringRequired
page_size
integer
start_cursor
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get page property

Description

Call this to get a specific property from a notion page when you have a valid `page id` and `property id`; handles pagination for properties returning multiple items.

Action Parameters

page_id
stringRequired
page_size
integer
property_id
stringRequired
start_cursor
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Update block

Description

Updates an existing notion block's textual content or type-specific properties (e.g., 'checked' status, 'color'), using its `block id` and the specified `block type`.

Action Parameters

additional_properties
object
block_id
stringRequired
block_type
stringRequired
content
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Search Notion page

Description

Searches notion pages and databases by title; an empty query lists all accessible items, useful for discovering ids or as a fallback when a specific query yields no results.

Action Parameters

direction
string
filter_property
stringDefaults to object
filter_value
stringDefaults to page
page_size
integerDefaults to 2
query
string
start_cursor
string
timestamp
string

Action Response

data
objectRequired
error
string
successful
booleanRequired