# Connections ## Create connection `client.connections.create("notion" | "google-drive" | "onedrive" | 4 moreprovider, ConnectionCreateParamsbody, RequestOptionsoptions?): ConnectionCreateResponse` **post** `/v3/connections/{provider}` Initialize connection and get authorization URL ### Parameters - `provider: "notion" | "google-drive" | "onedrive" | 4 more` - `"notion"` - `"google-drive"` - `"onedrive"` - `"gmail"` - `"github"` - `"web-crawler"` - `"s3"` - `body: ConnectionCreateParams` - `containerTag?: string` - `containerTags?: Array` - `documentLimit?: number` - `metadata?: Record | null` - `string` - `number` - `boolean` - `redirectUrl?: string` ### Returns - `ConnectionCreateResponse` - `id: string` - `authLink: string` - `expiresIn: string` - `redirectsTo?: string` ### Example ```typescript import Supermemory from 'supermemory'; const client = new Supermemory({ apiKey: process.env['SUPERMEMORY_API_KEY'], // This is the default and can be omitted }); const connection = await client.connections.create('notion'); console.log(connection.id); ``` #### Response ```json { "id": "id", "authLink": "authLink", "expiresIn": "expiresIn", "redirectsTo": "redirectsTo" } ``` ## Get connection (by id) `client.connections.getByID(stringconnectionID, RequestOptionsoptions?): ConnectionGetByIDResponse` **get** `/v3/connections/{connectionId}` Get connection details with id ### Parameters - `connectionID: string` ### Returns - `ConnectionGetByIDResponse` - `id: string` - `createdAt: string` - `provider: string` - `containerTags?: Array` - `documentLimit?: number` - `email?: string` - `expiresAt?: string` - `metadata?: Record` ### Example ```typescript import Supermemory from 'supermemory'; const client = new Supermemory({ apiKey: process.env['SUPERMEMORY_API_KEY'], // This is the default and can be omitted }); const response = await client.connections.getByID('connectionId'); console.log(response.id); ``` #### Response ```json { "id": "id", "createdAt": "createdAt", "provider": "provider", "containerTags": [ "string" ], "documentLimit": 0, "email": "email", "expiresAt": "expiresAt", "metadata": { "foo": "bar" } } ``` ## Get connection (by provider) `client.connections.getByTag("notion" | "google-drive" | "onedrive" | 4 moreprovider, ConnectionGetByTagParamsbody, RequestOptionsoptions?): ConnectionGetByTagResponse` **post** `/v3/connections/{provider}/connection` Get connection details with provider and container tags ### Parameters - `provider: "notion" | "google-drive" | "onedrive" | 4 more` - `"notion"` - `"google-drive"` - `"onedrive"` - `"gmail"` - `"github"` - `"web-crawler"` - `"s3"` - `body: ConnectionGetByTagParams` - `containerTags: Array` Comma-separated list of container tags to filter connection by ### Returns - `ConnectionGetByTagResponse` - `id: string` - `createdAt: string` - `provider: string` - `containerTags?: Array` - `documentLimit?: number` - `email?: string` - `expiresAt?: string` - `metadata?: Record` ### Example ```typescript import Supermemory from 'supermemory'; const client = new Supermemory({ apiKey: process.env['SUPERMEMORY_API_KEY'], // This is the default and can be omitted }); const response = await client.connections.getByTag('notion', { containerTags: ['user_123', 'project_123'], }); console.log(response.id); ``` #### Response ```json { "id": "id", "createdAt": "createdAt", "provider": "provider", "containerTags": [ "string" ], "documentLimit": 0, "email": "email", "expiresAt": "expiresAt", "metadata": { "foo": "bar" } } ``` ## Delete connection by ID `client.connections.deleteByID(stringconnectionID, ConnectionDeleteByIDParamsparams?, RequestOptionsoptions?): ConnectionDeleteByIDResponse` **delete** `/v3/connections/{connectionId}` Delete a specific connection by ID ### Parameters - `connectionID: string` - `params: ConnectionDeleteByIDParams` - `deleteDocuments?: string` Whether to also delete documents imported by this connection. Defaults to true. ### Returns - `ConnectionDeleteByIDResponse` - `id: string` - `provider: string` ### Example ```typescript import Supermemory from 'supermemory'; const client = new Supermemory({ apiKey: process.env['SUPERMEMORY_API_KEY'], // This is the default and can be omitted }); const response = await client.connections.deleteByID('connectionId'); console.log(response.id); ``` #### Response ```json { "id": "id", "provider": "provider" } ``` ## Delete connection `client.connections.deleteByProvider("notion" | "google-drive" | "onedrive" | 4 moreprovider, ConnectionDeleteByProviderParamsbody, RequestOptionsoptions?): ConnectionDeleteByProviderResponse` **delete** `/v3/connections/{provider}` Delete connection for a specific provider and container tags ### Parameters - `provider: "notion" | "google-drive" | "onedrive" | 4 more` - `"notion"` - `"google-drive"` - `"onedrive"` - `"gmail"` - `"github"` - `"web-crawler"` - `"s3"` - `body: ConnectionDeleteByProviderParams` - `containerTags: Array` Optional comma-separated list of container tags to filter connections by ### Returns - `ConnectionDeleteByProviderResponse` - `id: string` - `provider: string` ### Example ```typescript import Supermemory from 'supermemory'; const client = new Supermemory({ apiKey: process.env['SUPERMEMORY_API_KEY'], // This is the default and can be omitted }); const response = await client.connections.deleteByProvider('notion', { containerTags: ['user_123', 'project_123'], }); console.log(response.id); ``` #### Response ```json { "id": "id", "provider": "provider" } ``` ## Sync connection `client.connections.import("notion" | "google-drive" | "onedrive" | 4 moreprovider, ConnectionImportParamsbody, RequestOptionsoptions?): ConnectionImportResponse` **post** `/v3/connections/{provider}/import` Initiate a manual sync of connections ### Parameters - `provider: "notion" | "google-drive" | "onedrive" | 4 more` - `"notion"` - `"google-drive"` - `"onedrive"` - `"gmail"` - `"github"` - `"web-crawler"` - `"s3"` - `body: ConnectionImportParams` - `containerTags?: Array` Optional comma-separated list of container tags to filter connections by ### Returns - `ConnectionImportResponse = string` ### Example ```typescript import Supermemory from 'supermemory'; const client = new Supermemory({ apiKey: process.env['SUPERMEMORY_API_KEY'], // This is the default and can be omitted }); const response = await client.connections.import('notion'); console.log(response); ``` ## List connections `client.connections.list(ConnectionListParamsbody, RequestOptionsoptions?): ConnectionListResponse` **post** `/v3/connections/list` List all connections ### Parameters - `body: ConnectionListParams` - `containerTags?: Array` Optional comma-separated list of container tags to filter documents by ### Returns - `ConnectionListResponse = Array` - `id: string` - `createdAt: string` - `provider: string` - `containerTags?: Array` - `documentLimit?: number` - `email?: string` - `expiresAt?: string` - `metadata?: Record` ### Example ```typescript import Supermemory from 'supermemory'; const client = new Supermemory({ apiKey: process.env['SUPERMEMORY_API_KEY'], // This is the default and can be omitted }); const connections = await client.connections.list(); console.log(connections); ``` #### Response ```json [ { "id": "id", "createdAt": "createdAt", "provider": "provider", "containerTags": [ "string" ], "documentLimit": 0, "email": "email", "expiresAt": "expiresAt", "metadata": { "foo": "bar" } } ] ``` ## List documents `client.connections.listDocuments("notion" | "google-drive" | "onedrive" | 4 moreprovider, ConnectionListDocumentsParamsbody, RequestOptionsoptions?): ConnectionListDocumentsResponse` **post** `/v3/connections/{provider}/documents` List documents indexed for a provider and container tags ### Parameters - `provider: "notion" | "google-drive" | "onedrive" | 4 more` - `"notion"` - `"google-drive"` - `"onedrive"` - `"gmail"` - `"github"` - `"web-crawler"` - `"s3"` - `body: ConnectionListDocumentsParams` - `containerTags?: Array` Optional comma-separated list of container tags to filter documents by ### Returns - `ConnectionListDocumentsResponse = Array` - `id: string` - `createdAt: string` - `status: string` - `summary: string | null` - `title: string | null` - `type: string` - `updatedAt: string` ### Example ```typescript import Supermemory from 'supermemory'; const client = new Supermemory({ apiKey: process.env['SUPERMEMORY_API_KEY'], // This is the default and can be omitted }); const response = await client.connections.listDocuments('notion'); console.log(response); ``` #### Response ```json [ { "id": "id", "createdAt": "createdAt", "status": "status", "summary": "summary", "title": "title", "type": "type", "updatedAt": "updatedAt" } ] ``` ## Configure connection `client.connections.configure(stringconnectionID, ConnectionConfigureParamsbody, RequestOptionsoptions?): ConnectionConfigureResponse` **post** `/v3/connections/{connectionId}/configure` Configure resources for a connection (supported providers: GitHub for now) ### Parameters - `connectionID: string` - `body: ConnectionConfigureParams` - `resources: Array>` ### Returns - `ConnectionConfigureResponse` - `message: string` - `success: boolean` - `webhooksRegistered?: number` ### Example ```typescript import Supermemory from 'supermemory'; const client = new Supermemory({ apiKey: process.env['SUPERMEMORY_API_KEY'], // This is the default and can be omitted }); const response = await client.connections.configure('connectionId', { resources: [{ foo: 'bar' }], }); console.log(response.message); ``` #### Response ```json { "message": "message", "success": true, "webhooksRegistered": 0 } ``` ## Fetch resources `client.connections.resources(stringconnectionID, ConnectionResourcesParamsquery?, RequestOptionsoptions?): ConnectionResourcesResponse` **get** `/v3/connections/{connectionId}/resources` Fetch resources for a connection (supported providers: GitHub for now) ### Parameters - `connectionID: string` - `query: ConnectionResourcesParams` - `page?: number` - `parent_id?: string` - `per_page?: number` ### Returns - `ConnectionResourcesResponse` - `resources: Array>` - `total_count?: number` ### Example ```typescript import Supermemory from 'supermemory'; const client = new Supermemory({ apiKey: process.env['SUPERMEMORY_API_KEY'], // This is the default and can be omitted }); const response = await client.connections.resources('connectionId'); console.log(response.resources); ``` #### Response ```json { "resources": [ { "foo": "bar" } ], "total_count": 0 } ``` ## Domain Types ### Connection Create Response - `ConnectionCreateResponse` - `id: string` - `authLink: string` - `expiresIn: string` - `redirectsTo?: string` ### Connection Get By ID Response - `ConnectionGetByIDResponse` - `id: string` - `createdAt: string` - `provider: string` - `containerTags?: Array` - `documentLimit?: number` - `email?: string` - `expiresAt?: string` - `metadata?: Record` ### Connection Get By Tag Response - `ConnectionGetByTagResponse` - `id: string` - `createdAt: string` - `provider: string` - `containerTags?: Array` - `documentLimit?: number` - `email?: string` - `expiresAt?: string` - `metadata?: Record` ### Connection Delete By ID Response - `ConnectionDeleteByIDResponse` - `id: string` - `provider: string` ### Connection Delete By Provider Response - `ConnectionDeleteByProviderResponse` - `id: string` - `provider: string` ### Connection Import Response - `ConnectionImportResponse = string` ### Connection List Response - `ConnectionListResponse = Array` - `id: string` - `createdAt: string` - `provider: string` - `containerTags?: Array` - `documentLimit?: number` - `email?: string` - `expiresAt?: string` - `metadata?: Record` ### Connection List Documents Response - `ConnectionListDocumentsResponse = Array` - `id: string` - `createdAt: string` - `status: string` - `summary: string | null` - `title: string | null` - `type: string` - `updatedAt: string` ### Connection Configure Response - `ConnectionConfigureResponse` - `message: string` - `success: boolean` - `webhooksRegistered?: number` ### Connection Resources Response - `ConnectionResourcesResponse` - `resources: Array>` - `total_count?: number`