apps/docs/connectors/notion.mdx
Connect Notion workspaces to automatically sync pages, databases, and content blocks into your Supermemory knowledge base. Supports real-time updates, rich formatting, and database properties.
const client = new Supermemory({
apiKey: process.env.SUPERMEMORY_API_KEY!
});
const connection = await client.connections.create('notion', {
redirectUrl: 'https://yourapp.com/auth/notion/callback',
containerTags: ['user-123', 'notion-workspace'],
documentLimit: 2000,
metadata: {
source: 'notion',
workspaceType: 'team',
department: 'product'
}
});
// Redirect user to Notion OAuth
window.location.href = connection.authLink;
```
client = Supermemory(api_key=os.environ.get("SUPERMEMORY_API_KEY"))
connection = client.connections.create(
'notion',
redirect_url='https://yourapp.com/auth/notion/callback',
container_tags=['user-123', 'notion-workspace'],
document_limit=2000,
metadata={
'source': 'notion',
'workspaceType': 'team',
'department': 'product'
}
)
# Redirect user to Notion OAuth
print(f'Redirect to: {connection.auth_link}')
```
After user grants workspace access, Notion redirects to your callback URL. The connection is automatically established.
console.log('Connected workspace:', connection.email);
console.log('Connection created:', connection.createdAt);
// List synced pages and databases
const documents = await client.connections.listDocuments('notion', {
containerTags: ['user-123', 'notion-workspace']
});
```
print(f'Connected workspace: {connection.email}')
print(f'Connection created: {connection.created_at}')
# List synced pages and databases
documents = client.connections.list_documents(
'notion',
container_tags=['user-123', 'notion-workspace']
)
```
# Response includes connection details:
# {
# "id": "conn_abc123",
# "provider": "notion",
# "email": "[email protected]",
# "createdAt": "2024-01-15T10:00:00Z",
# "documentLimit": 2000,
# "metadata": {...}
# }
# List synced documents
curl -X POST "https://api.supermemory.ai/v3/connections/notion/documents" \
-H "Authorization: Bearer $SUPERMEMORY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"containerTags": ["user-123", "notion-workspace"]}'
# Response: Array of document objects with sync status
# [
# {"title": "Product Roadmap", "type": "notion_database", "status": "done"},
# {"title": "Meeting Notes", "type": "notion_page", "status": "done"}
# ]
```
| Block Type | Processing | Markdown Output |
|---|---|---|
| Text | Formatting preserved | **bold**, *italic*, ~~strikethrough~~ |
| Heading | Hierarchy maintained | # H1, ## H2, ### H3 |
| Code | Language detected | python\ncode here\n |
| Quote | Blockquote format | > quoted text |
| Callout | Custom formatting | > 💡 **Note:** callout text |
| List | Structure preserved | - item 1\n - nested item |
| Table | Markdown tables | ` |
| Image | Referenced with metadata |  |
| Embed | Link with context | [Embedded Content](url) |
Remove a Notion connection when no longer needed:
<Tabs> <Tab title="TypeScript"> ```typescript // Delete by connection ID const result = await client.connections.delete('connection_id_123'); console.log('Deleted connection:', result.id);// Delete by provider and container tags
const providerResult = await client.connections.deleteByProvider('notion', {
containerTags: ['user-123']
});
console.log('Deleted Notion connection for user');
```
# Delete by provider and container tags
provider_result = client.connections.delete_by_provider(
'notion',
container_tags=['user-123']
)
print('Deleted Notion connection for user')
```
# Delete by provider and container tags
curl -X DELETE "https://api.supermemory.ai/v3/connections/notion" \
-H "Authorization: Bearer $SUPERMEMORY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"containerTags": ["user-123"]}'
```
For production deployments, create your own Notion integration:
<Tabs> <Tab title="TypeScript"> ```typescript // First, update organization settings with your Notion app credentials await client.settings.update({ notionCustomKeyEnabled: true, notionClientId: 'your-notion-client-id', notionClientSecret: 'your-notion-client-secret' });// Then create connections using your custom integration
const connection = await client.connections.create('notion', {
redirectUrl: 'https://yourapp.com/callback',
containerTags: ['org-456', 'user-789'],
metadata: { customIntegration: true }
});
```
# Then create connections using your custom integration
connection = client.connections.create(
'notion',
redirect_url='https://yourapp.com/callback',
container_tags=['org-456', 'user-789'],
metadata={'customIntegration': True}
)
```
Control which Notion content gets synced:
<Tabs> <Tab title="TypeScript"> ```typescript // Configure intelligent filtering for Notion content await client.settings.update({ shouldLLMFilter: true, includeItems: { pageTypes: ['page', 'database'], titlePatterns: ['*Spec*', '*Documentation*', '*Meeting Notes*'], databases: ['Project Tracker', 'Knowledge Base', 'Team Wiki'] }, excludeItems: { titlePatterns: ['*Draft*', '*Personal*', '*Archive*'], databases: ['Personal Tasks', 'Scratchpad'] }, filterPrompt: "Sync professional documentation, project specs, meeting notes, and team knowledge. Skip personal notes, drafts, and archived content." }); ``` </Tab> <Tab title="Python"> ```python # Configure intelligent filtering for Notion content client.settings.update( should_llm_filter=True, include_items={ 'pageTypes': ['page', 'database'], 'titlePatterns': ['*Spec*', '*Documentation*', '*Meeting Notes*'], 'databases': ['Project Tracker', 'Knowledge Base', 'Team Wiki'] }, exclude_items={ 'titlePatterns': ['*Draft*', '*Personal*', '*Archive*'], 'databases': ['Personal Tasks', 'Scratchpad'] }, filter_prompt="Sync professional documentation, project specs, meeting notes, and team knowledge. Skip personal notes, drafts, and archived content." ) ``` </Tab> <Tab title="cURL"> ```bash # Configure intelligent filtering for Notion content curl -X PATCH "https://api.supermemory.ai/v3/settings" \ -H "Authorization: Bearer $SUPERMEMORY_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "shouldLLMFilter": true, "includeItems": { "pageTypes": ["page", "database"], "titlePatterns": ["*Spec*", "*Documentation*", "*Meeting Notes*"], "databases": ["Project Tracker", "Knowledge Base", "Team Wiki"] }, "excludeItems": { "titlePatterns": ["*Draft*", "*Personal*", "*Archive*"], "databases": ["Personal Tasks", "Scratchpad"] }, "filterPrompt": "Sync professional documentation, project specs, meeting notes, and team knowledge. Skip personal notes, drafts, and archived content." }'# Response:
# {
# "success": true,
# "message": "Settings updated successfully"
# }
```
Notion connector respects workspace permissions:
| Permission Level | Sync Behavior |
|---|---|
| Admin | Full workspace access |
| Member | Pages with read access |
| Guest | Only shared pages |
| No Access | Removed from index |
Notion database properties are mapped to metadata:
// Example: Project database with properties
const documents = await client.connections.listDocuments('notion', {
containerTags: ['user-123']
});
// Find database entries
const projectEntries = documents.filter(doc =>
doc.metadata?.database === 'Projects'
);
// Database properties become searchable metadata
const projectWithStatus = await client.search.documents({
q: "machine learning project",
containerTags: ['user-123'],
filters: JSON.stringify({
AND: [
{ key: "status", value: "In Progress", negate: false },
{ key: "priority", value: "High", negate: false }
]
})
});