Skip to main content
Currently Available for GitHub: Resource management endpoints are currently only available for the GitHub connector. These endpoints allow you to select which repositories to sync before syncing begins.
Some connectors require you to select which resources (e.g., repositories) to sync before syncing begins. Use these generic endpoints to list and configure resources for connections that support resource management.

Get Resources

GET /v3/connections/:connectionId/resources Get available resources (e.g., repositories, folders) for a connection using stored credentials.
import Supermemory from 'supermemory';

const client = new Supermemory({
  apiKey: process.env['SUPERMEMORY_API_KEY'],
});

// Get resources with pagination
const response = await fetch(
  `https://api.supermemory.ai/v3/connections/${connectionId}/resources?page=1&per_page=30`,
  {
    headers: {
      'Authorization': `Bearer ${process.env.SUPERMEMORY_API_KEY}`,
    },
  }
);

const data = await response.json();
console.log('Resources:', data.resources);
console.log('Total count:', data.total_count);

Query Parameters

  • page: Optional. Page number for pagination. Default: 1
  • per_page: Optional. Number of resources per page. Default: 30

Response

{
  "resources": [
    {
      "id": 123456789,
      "name": "your-org/documentation",
      "full_name": "your-org/documentation",
      "description": "Documentation repository",
      "private": false,
      "default_branch": "main",
      "updated_at": "2024-01-15T10:00:00Z"
    }
  ],
  "total_count": 45
}

Error Responses

  • 400: Connection missing refresh token
  • 401: Unauthorized
  • 404: Connection not found
  • 501: Provider does not support resource fetching
Provider Support: Not all providers support resource fetching. This endpoint is only available for providers that implement the fetchResources() method (e.g., GitHub). For providers that don’t support this, you’ll receive a 501 Not Implemented response.

Configure Connection

POST /v3/connections/:connectionId/configure Configure selected resources (e.g., repositories) for a connection and set up webhooks/subscriptions.
import Supermemory from 'supermemory';

const client = new Supermemory({
  apiKey: process.env['SUPERMEMORY_API_KEY'],
});

// Configure connection
const response = await fetch(
  `https://api.supermemory.ai/v3/connections/${connectionId}/configure`,
  {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.SUPERMEMORY_API_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      resources: [
        {
          id: 123456789,
          name: 'your-org/documentation',
          defaultBranch: 'main',
        },
        {
          id: 987654321,
          name: 'your-org/api-docs',
          defaultBranch: 'main',
        },
      ],
    }),
  }
);

const data = await response.json();
console.log('Success:', data.success);
console.log('Message:', data.message);
console.log('Webhooks registered:', data.webhooksRegistered);

Request Body

{
  "resources": [
    {
      "id": 123456789,
      "name": "your-org/documentation",
      "defaultBranch": "main"
    }
  ]
}
The structure of each resource object depends on the provider. For GitHub, resources include:
  • id: Repository ID (number)
  • name: Repository full name (string)
  • defaultBranch: Default branch name (string)

Response

{
  "success": true,
  "message": "Resources configured successfully",
  "webhooksRegistered": 2
}

Error Responses

  • 400: Connection missing refresh token
  • 401: Unauthorized
  • 404: Connection not found
  • 501: Provider does not support resource configuration
Automatic Sync: After successfully configuring resources, an initial sync is automatically triggered for the connection. You don’t need to manually trigger a sync after configuration.
Provider Support: Not all providers support resource configuration. This endpoint is only available for providers that implement the configureConnection() method (e.g., GitHub). For providers that don’t support this, you’ll receive a 501 Not Implemented response.

Example: GitHub Repository Selection

Here’s a complete example for GitHub:
// 1. Create connection (see creating-connection.mdx)
const connection = await client.connections.create('github', {
  redirectUrl: 'https://yourapp.com/callback',
});

// 2. After OAuth callback, fetch available repositories
const resourcesResponse = await fetch(
  `https://api.supermemory.ai/v3/connections/${connection.id}/resources?page=1&per_page=100`,
  {
    headers: {
      'Authorization': `Bearer ${process.env.SUPERMEMORY_API_KEY}`,
    },
  }
);
const { resources } = await resourcesResponse.json();

// 3. Display repositories to user and let them select
// (Build your UI here)

// 4. Configure selected repositories
const configureResponse = await fetch(
  `https://api.supermemory.ai/v3/connections/${connection.id}/configure`,
  {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.SUPERMEMORY_API_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      resources: selectedRepositories, // User's selection
    }),
  }
);
const result = await configureResponse.json();
console.log('Sync initiated:', result.success);