apps/docs/memory-api/connectors/creating-connection.mdx
To create a connection, just make a POST request to /v3/connections/{provider}
const client = new Supermemory({ apiKey: process.env['SUPERMEMORY_API_KEY'], // This is the default and can be omitted });
// For OAuth providers (notion, google-drive, onedrive) const connection = await client.connections.create('notion'); console.debug(connection.authLink);
// For web-crawler (no OAuth required) const webCrawlerConnection = await client.connections.create('web-crawler', { metadata: { startUrl: 'https://docs.example.com' } }); console.debug(webCrawlerConnection.id); // authLink will be null
```python Python
import requests
url = "https://api.supermemory.ai/v3/connections/{provider}"
payload = {
"redirectUrl": "<string>",
"containerTags": ["<string>"],
"metadata": {},
"documentLimit": 5000
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.request("POST", url, json=payload, headers=headers)
print(response.text)
curl --request POST \
--url https://api.supermemory.ai/v3/connections/{provider} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"redirectUrl": "<string>",
"containerTags": [
"<string>"
],
"metadata": {},
"documentLimit": 5000
}'
provider: The provider to connect to. Currently supported providers are notion, google-drive, onedrive, web-crawlerredirectUrl: The URL to redirect to after the connection is created (your app URL)
web-crawler, this is optional as no OAuth flow is requiredcontainerTags: Optional. For partitioning users, organizations, etc. in your app.
["user_123", "project_alpha"]metadata: Optional. Any metadata you want to associate with the connection.
web-crawler, must include startUrl in metadata: {"startUrl": "https://example.com"}documentLimit: Optional. The maximum number of documents to sync from this connection.
supermemory sends a response with the following schema:
{
"id": "<string>",
"authLink": "<string>",
"expiresIn": "<string>",
"redirectsTo": "<string>"
}
For most providers (notion, google-drive, onedrive), you can use the authLink to redirect the user to the provider's login page.
Next up, managing connections.