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

# Export to SharePoint

SQL Editor can upload exports straight into a SharePoint document library instead of downloading them to a user's machine. Your SharePoint administrators control who can read those files and how long to keep them.

> [!NOTE]
>
> Available only for:
>
> * **Enterprise** plan
> * Self-hosted Bytebase

Microsoft and Bytebase administrators split the setup:

| Step | Done by |
| - | - |
| [Register an Entra application](#register-a-microsoft-entra-application) and [grant it access to each library](#grant-the-application-access-to-a-library) | Microsoft Entra and SharePoint administrators |
| [Configure SharePoint in Bytebase](#configure-sharepoint-in-bytebase) | **Workspace Admin** or **Workspace DBA** |
| [Set a project's SharePoint folder](#set-a-projects-sharepoint-folder) | **Project Owner**, **Workspace Admin**, or **Workspace DBA** |
| [Turn off downloads](https://docs.bytebase.com/security/database-permission/export.md#turn-off-downloads) (optional) | **Workspace Admin** or **Workspace DBA** |

## Register a Microsoft Entra application

Bytebase authenticates to Microsoft Graph with the `Lists.SelectedOperations.Selected` application permission. That permission grants no access on its own; the application can reach only the libraries you grant it in the [next step](#grant-the-application-access-to-a-library).

1. In the [Microsoft Entra admin center](https://entra.microsoft.com), go to **App registrations** and click **New registration**.
2. Enter a name such as `Bytebase Export`, keep **Accounts in this organizational directory only**, and click **Register**. Leave **Redirect URI** blank.
3. On the application's **Overview** page, copy the **Application (client) ID** and the **Directory (tenant) ID**.
4. Go to **API permissions**, click **Add a permission** > **Microsoft Graph** > **Application permissions**, select `Lists.SelectedOperations.Selected`, and click **Add permissions**.
5. Click **Grant admin consent** for your tenant.
6. Go to **Certificates & secrets** > **Client secrets**, click **New client secret**, choose an expiration, and click **Add**. Copy the secret's **Value** right away; Entra shows it only once.

## Grant the application access to a library

Grant the application the `write` role on each document library that projects will export to. Microsoft documents the grant in [Overview of Selected permissions in OneDrive and SharePoint](https://learn.microsoft.com/en-us/graph/permissions-selected-overview) and [Create permission on a list](https://learn.microsoft.com/en-us/graph/api/list-post-permissions?view=graph-rest-1.0).

Make these Microsoft Graph requests as a SharePoint administrator, for example in [Graph Explorer](https://developer.microsoft.com/graph/graph-explorer).

1. Look up the site ID. Open the library in SharePoint and check its URL. The site path is everything before the library name. In `https://contoso.sharepoint.com/sites/Finance/Shared%20Documents/Forms/AllItems.aspx`, the site is `/sites/Finance` and the library is `Shared Documents`. Request the site, using `/teams/` instead of `/sites/` for a team site:

   ```http theme={null}
   GET https://graph.microsoft.com/v1.0/sites/<tenant>.sharepoint.com:/sites/<site_name>
   ```

   The `id` in the response is the site ID.

2. Look up the library's list ID:

   ```http theme={null}
   GET https://graph.microsoft.com/v1.0/sites/<site_id>/lists?$select=id,displayName,webUrl
   ```

   Find the library by its `webUrl`.

3. Create the permission:

   ```http theme={null}
   POST https://graph.microsoft.com/v1.0/sites/<site_id>/lists/<list_id>/permissions
   Content-Type: application/json

   {
     "grantedToV2": {
       "application": {
         "id": "<client_id>",
         "displayName": "Bytebase Export"
       }
     },
     "roles": ["write"]
   }
   ```

## Configure SharePoint in Bytebase

1. Go to **Integration** > **Export Destinations** and click **Configure** on the **SharePoint** row.

   ![Export Destinations page](https://mintcdn.com/dbx/yopqlrSt_SIRwoGt/content/docs/security/database-permission/export/sharepoint/export-destinations.webp?fit=max\&auto=format\&n=yopqlrSt_SIRwoGt\&q=85\&s=c102a5b6cd0f60812e860accca40b006)

2. Enter the **Tenant ID**, **Client ID**, and **Client secret**, then click **Save**.

   ![SharePoint configuration](https://mintcdn.com/dbx/yopqlrSt_SIRwoGt/content/docs/security/database-permission/export/sharepoint/sharepoint-sheet.webp?fit=max\&auto=format\&n=yopqlrSt_SIRwoGt\&q=85\&s=4ab37a70347cd6f276c9e4aeec273c89)

## Set a project's SharePoint folder

Each project can point to one SharePoint library root or folder.

1. Open the project and go to **Settings**.

2. Under **Security & Policy** > **Export destinations**, paste the SharePoint URL of the library or folder into the **SharePoint** field.

   ![Project export destination](https://mintcdn.com/dbx/yopqlrSt_SIRwoGt/content/docs/security/database-permission/export/sharepoint/project-export-destination.webp?fit=max\&auto=format\&n=yopqlrSt_SIRwoGt\&q=85\&s=2e116fa71ac3c636e4524e8be5ca5b5c)

3. Click **Update**.

## Export query results to SharePoint

1. Run a query in SQL Editor and click **Export** on the result.

2. The **Export Data** drawer selects **SharePoint** by default. Switch **Destination** to **Download** if you want a local file and your workspace allows it.

   ![Export Data drawer](https://mintcdn.com/dbx/yopqlrSt_SIRwoGt/content/docs/security/database-permission/export/sharepoint/export-drawer.webp?fit=max\&auto=format\&n=yopqlrSt_SIRwoGt\&q=85\&s=4ef2b5491492fc05fa4e04a88d8e9d38)

3. Choose **Export rows** and **Export format**, then click **Confirm**.

Bytebase runs the statement again, uploads the files, and opens **Exported to SharePoint**. Click **Open in SharePoint** to go to the export's folder.

![Exported to SharePoint](https://mintcdn.com/dbx/yopqlrSt_SIRwoGt/content/docs/security/database-permission/export/sharepoint/export-result.webp?fit=max\&auto=format\&n=yopqlrSt_SIRwoGt\&q=85\&s=d5917224d987fb838d746f8e54b71434)

Each export creates its own folder under the project's SharePoint folder, named after the UTC export time, the exporter's email, the database, and a random export ID:

```text theme={null}
20261102T072108Z-demo@example.com-hr_test-479c51fc/
  statement-1.sql
  statement-1.result.csv
  statement-2.sql
  statement-2.result.csv
```

In a [batch query](https://docs.bytebase.com/sql-editor/run-queries.md#batch-mode), each database gets its own folder. SharePoint exports follow the same row limits, formats, and [masking](https://docs.bytebase.com/sql-editor/mask-data.md) as downloads.


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