> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mixpeek.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# SharePoint

> Connect SharePoint sites and OneDrive for Business document libraries to a Mixpeek bucket.

> [!NOTE]
>
> Mixpeek reads document libraries through the Microsoft Graph API. Each file becomes a bucket object.

## Overview

SharePoint nests four levels: tenant, site, drive (document library), item. A connection pins the first three, and the sync path selects the folder.

| Field | Selects |
| - | - |
| `site_id` | The SharePoint site |
| `drive_id` | A document library inside that site |
| `folder_path` | A folder inside that library |

## Prerequisites

* An Azure AD application registration.
* Microsoft Graph permissions `Sites.Read.All` and `Files.Read.All`.
* Admin consent, for the client-credentials flow.

## Authentication

Two flows, chosen by the `type` field on `credentials`.

**`client_credentials`** — app-only access with no user in the loop. Use this in production.

| Field | Required |
| - | - |
| `tenant_id` | Yes |
| `client_id` | Yes |
| `client_secret` | Yes |

**`delegated`** — acts as a user, limited to that user's permissions. Needs refresh-token upkeep.

| Field | Required |
| - | - |
| `tenant_id` | Yes, or `common` for a multi-tenant app |
| `client_id` | Yes |
| `client_secret` | Yes |
| `refresh_token` | Yes |

> [!WARNING]
>
> `client_secret` and `refresh_token` are encrypted at rest and never returned in a response.

## Configuration

### Connection-level fields

| Field | Required | Description |
| - | - | - |
| `credentials` | Yes | One of the two flows above |
| `site_id` | No | Omit for personal OneDrive |
| `drive_id` | No | Omit to use the site's default document library |
| `folder_path` | No | Omit to sync from the drive root |

### Sync-level fields

| Field | Required | Description |
| - | - | - |
| `source_path` | Yes | For example `/sites/SiteName/Shared Documents/folder` |
| `polling_interval_seconds` | No | Defaults to `300` |

## Setup

**1. Register the Azure AD application**

1. Open **Azure Portal → App registrations → New registration**.
2. Copy the **Application (client) ID** and **Directory (tenant) ID**.
3. Under **Certificates & secrets**, create a client secret and copy its value.
4. Under **API permissions**, add `Sites.Read.All` and `Files.Read.All`, then grant admin consent.

**2. Find your site and drive IDs**

```bash cURL theme={null}
curl -H "Authorization: Bearer YOUR_GRAPH_TOKEN" \
  "https://graph.microsoft.com/v1.0/sites/contoso.sharepoint.com:/sites/Marketing"

curl -H "Authorization: Bearer YOUR_GRAPH_TOKEN" \
  "https://graph.microsoft.com/v1.0/sites/SITE_ID/drives"
```

A site ID looks like `contoso.sharepoint.com,guid1,guid2`. A drive ID starts with `b!`.

**3. Create the storage connection**

```python Python theme={null}
from mixpeek import Mixpeek

client = Mixpeek(api_key="your-mixpeek-api-key")

connection = client.organizations.connections.create(
    name="Marketing SharePoint",
    provider_type="sharepoint",
    provider_config={
        "credentials": {
            "type": "client_credentials",
            "tenant_id": "your-tenant-id",
            "client_id": "your-client-id",
            "client_secret": "your-client-secret",
        },
        "site_id": "contoso.sharepoint.com,guid1,guid2",
        "drive_id": "b!your-drive-id",
        "folder_path": "/Shared Documents/Marketing",
    },
)
print(f"Created connection: {connection['connection_id']}")
```

```javascript JavaScript theme={null}
import { Mixpeek } from 'mixpeek-sdk'

const client = new Mixpeek({ apiKey: 'your-mixpeek-api-key' })

const connection = await client.organizations.connections.create({
  name: 'Marketing SharePoint',
  provider_type: 'sharepoint',
  provider_config: {
    credentials: {
      type: 'client_credentials',
      tenant_id: 'your-tenant-id',
      client_id: 'your-client-id',
      client_secret: 'your-client-secret',
    },
    site_id: 'contoso.sharepoint.com,guid1,guid2',
    drive_id: 'b!your-drive-id',
    folder_path: '/Shared Documents/Marketing',
  },
})
console.log('Created connection:', connection.connection_id)
```

```bash cURL theme={null}
curl -X POST https://api.mixpeek.com/v1/organizations/connections \
  -H "Authorization: Bearer YOUR_MIXPEEK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Marketing SharePoint",
    "provider_type": "sharepoint",
    "provider_config": {
      "credentials": {
        "type": "client_credentials",
        "tenant_id": "your-tenant-id",
        "client_id": "your-client-id",
        "client_secret": "your-client-secret"
      },
      "site_id": "contoso.sharepoint.com,guid1,guid2",
      "drive_id": "b!your-drive-id",
      "folder_path": "/Shared Documents/Marketing"
    }
  }'
```

**4. Browse folders before creating a sync**

```bash cURL theme={null}
curl "https://api.mixpeek.com/v1/organizations/connections/conn_your_connection_id/folders" \
  -H "Authorization: Bearer YOUR_MIXPEEK_API_KEY"
```

**5. Create the sync**

```bash cURL theme={null}
curl -X POST https://api.mixpeek.com/v1/buckets/bkt_your_bucket_id/syncs \
  -H "Authorization: Bearer YOUR_MIXPEEK_API_KEY" \
  -H "X-Namespace: ns_your_namespace_id" \
  -H "Content-Type: application/json" \
  -d '{
    "connection_id": "conn_your_connection_id",
    "source_path": "/sites/Marketing/Shared Documents/Campaigns",
    "polling_interval_seconds": 1800
  }'
```

## Related

> [card] [Google Drive](https://docs.mixpeek.com/docs/integrations/object-storage/google-drive.md)
>
> The same file-library pattern on Google Workspace.

> [card] [Box](https://docs.mixpeek.com/docs/integrations/object-storage/box.md)
>
> Enterprise content management connector.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.