This API is in public beta
Prerequisites
A Custom Agent to chat with You need an existing Custom Agent because it’s the Agent you’ll chat with in this quickstart. In step 1, you’ll use the API to choose the Agent, then use its ID to start a chat in step 2. The API works with Custom Agents that already exist in the Notion app; it does not create them. To create a new Custom Agent, see Build a Custom Agent. A personal access token to authenticate requests This quickstart sends API requests on your behalf, so each request needs a personal access token (PAT). It lets you authenticate as yourself without setting up OAuth and carries your own access, so it can reach exactly the Custom Agents you can reach in Notion.1
Open Personal access tokens in the Developer portal.
2
Select New token.
3
Enter a name, select the Notion API capability, and then select Create token. That capability covers the Agents API — there is nothing else to enable.
4
Copy the token and save it somewhere secure. You won’t be able to see it again.
Step 1: Pick a Custom Agent
Pick the Custom Agent you want to chat with. It can be the Custom Agent you created for this quickstart or an existing Custom Agent in your workspace that you can access. Use Query agents to find it. The example below narrows results to Custom Agents you created. Remove thecreated_by filter to choose another Custom Agent you can access.
curl
Response
id of the Custom Agent you chose — that’s what you’ll chat with. Save it as an environment variable too:
Step 2: Start a new Agent chat
Send your agent a message by creating a session with Create or update a session. A session is one conversation: you create it with the first message, then keep sending to the samesession_id to continue.
curl
Response
Step 3: Read the Agent reply
The agent works asynchronously, so the session comes back asqueued. Poll Retrieve a session until the status leaves queued and in_progress:
curl
Accept: text/event-stream. See Create or update a session.
Once the status is completed, read the Agent reply from the session’s event history with Query session events:
curl
agent.message event:
Response
Common questions
I don't see the option to create a token
I don't see the option to create a token
On Business and Enterprise plans, PAT creation is restricted by default. Ask a workspace owner to enable it in Settings → Connections.See Who can create PATs.
How do I use the examples in PowerShell?
How do I use the examples in PowerShell?
The
curl examples are written for a Unix shell. In PowerShell, refer to the variables as $env:NOTION_API_KEY, $env:AGENT_ID, and $env:SESSION_ID.How else can I find a Custom Agent?
How else can I find a Custom Agent?
Query agents also takes a free-text
query that matches names and descriptions, along with filters on fields like id, agent_type, created_time, and connections. Sorting is available on created_time and last_run_at.Next steps
You’ve found a Custom Agent through the API and started a chat. From here you can:- Keep the conversation going. Send another message to the same
session_idfor a follow-up, or submit an action the agent is waiting on. - Track what your agents cost. Read agent insights for credits used and runs completed per agent to build a usage dashboard.
- Set guardrails. Give an agent a credit limit, or disable it when something looks wrong.
- Batch manage agent. Apply status, credit-limit, and delete operations in a single asynchronous batch.