1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
|
---
title: "Notion Connector"
description: "Sync Notion pages, databases, and blocks with real-time webhooks and workspace integration"
icon: "notion"
---
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.
## Quick Setup
### 1. Create Notion Connection
<Tabs>
<Tab title="TypeScript">
```typescript
import Supermemory from 'supermemory';
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;
```
</Tab>
<Tab title="Python">
```python
from supermemory import Supermemory
import os
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}')
```
</Tab>
<Tab title="cURL">
```bash
curl -X POST "https://api.supermemory.ai/v3/connections/notion" \
-H "Authorization: Bearer $SUPERMEMORY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"redirectUrl": "https://yourapp.com/auth/notion/callback",
"containerTags": ["user-123", "notion-workspace"],
"documentLimit": 2000,
"metadata": {
"source": "notion",
"workspaceType": "team",
"department": "product"
}
}'
```
</Tab>
</Tabs>
### 2. Handle OAuth Flow
After user grants workspace access, Notion redirects to your callback URL. The connection is automatically established.
### 3. Monitor Sync Progress
<Tabs>
<Tab title="TypeScript">
```typescript
// Check connection details
const connection = await client.connections.getByTags('notion', {
containerTags: ['user-123', 'notion-workspace']
});
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']
});
```
</Tab>
<Tab title="Python">
```python
# Check connection details
connection = client.connections.get_by_tags(
'notion',
container_tags=['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']
)
```
</Tab>
<Tab title="cURL">
```bash
# Get connection details by provider and tags
curl -X POST "https://api.supermemory.ai/v3/connections/notion/connection" \
-H "Authorization: Bearer $SUPERMEMORY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"containerTags": ["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"}
# ]
```
</Tab>
</Tabs>
## Supported Content Types
### Notion Pages
- **Rich text blocks** with formatting preserved
- **Nested pages** and hierarchical structure
- **Embedded content** (images, videos, files)
- **Code blocks** with syntax highlighting
- **Callouts and quotes** converted to markdown
### Notion Databases
- **Database entries** synced as individual documents
- **Properties** included in metadata
- **Relations** between database entries
- **Formulas and rollups** calculated values
- **Multi-select and select** properties
### Block Types
| 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 | `| Col 1 | Col 2 |\n|-------|-------|` |
| **Image** | Referenced with metadata | `` |
| **Embed** | Link with context | `[Embedded Content](url)` |
## Delete Connection
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');
```
</Tab>
<Tab title="Python">
```python
# Delete by connection ID
result = client.connections.delete('connection_id_123')
print(f'Deleted connection: {result.id}')
# Delete by provider and container tags
provider_result = client.connections.delete_by_provider(
'notion',
container_tags=['user-123']
)
print('Deleted Notion connection for user')
```
</Tab>
<Tab title="cURL">
```bash
# Delete by connection ID
curl -X DELETE "https://api.supermemory.ai/v3/connections/connection_id_123" \
-H "Authorization: Bearer $SUPERMEMORY_API_KEY"
# 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"]}'
```
</Tab>
</Tabs>
<Note>
Deleting a connection will:
- Stop all future syncs from Notion
- Remove the OAuth authorization
- Keep existing synced documents in Supermemory (they won't be deleted)
</Note>
## Advanced Configuration
### Custom Notion Integration
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 }
});
```
</Tab>
<Tab title="Python">
```python
# First, update organization settings with your Notion app credentials
client.settings.update(
notion_custom_key_enabled=True,
notion_client_id='your-notion-client-id',
notion_client_secret='your-notion-client-secret'
)
# 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}
)
```
</Tab>
<Tab title="cURL">
```bash
# Update organization settings
curl -X PATCH "https://api.supermemory.ai/v3/settings" \
-H "Authorization: Bearer $SUPERMEMORY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"notionCustomKeyEnabled": true,
"notionClientId": "your-notion-client-id",
"notionClientSecret": "your-notion-client-secret"
}'
```
</Tab>
</Tabs>
### Content Filtering
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"
# }
```
</Tab>
</Tabs>
## Workspace Permissions
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 |
## Database Integration
### Database Properties
Notion database properties are mapped to metadata:
```typescript
// 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 }
]
})
});
```
### Optimization Strategies
1. **Set appropriate document limits** based on workspace size
2. **Use targeted container tags** for efficient organization
3. **Monitor database sync performance** for large datasets
4. **Implement content filtering** to sync only relevant pages
5. **Handle webhook delays** gracefully in your application
<Callout type="info">
**Notion-Specific Benefits:**
- Real-time sync via webhooks for instant updates
- Rich formatting and block structure preserved
- Database properties become searchable metadata
- Hierarchical page structure maintained
- Collaborative workspace support
</Callout>
<Warning>
**Important Limitations:**
- Complex block formatting may be simplified in markdown conversion
- Large databases can take significant time to sync initially
- Workspace permissions affect which content is accessible
- Notion API rate limits may affect sync speed for large workspaces
- Embedded files and images are referenced, not stored directly
</Warning>
|