This page was recently updated. What do you think about it? Let us know!.

Connect SharePoint to your preprocessing pipeline, and use the Unstructured Ingest CLI or the Unstructured Ingest Python library to batch process all your documents and store structured outputs locally on your filesystem.

The requirements are as follows.

If you are setting up the SharePoint connector for the first time, you can skip past this note.

Previous versions of the SharePoint connector relied on SharePoint app principals for authentication. Current versions of the SharePoint connector no longer support these SharePoint app principals. Microsoft deprecated support for Share Point app principals on November 27, 2023. SharePoint app principals will no longer work for SharePoint tenants that were created on or after November 1, 2024, and they will stop working for all SharePoint tenants as of April 2, 2026. Learn more.

Current versions of the SharePoint connector now rely on Microsoft Entra ID app registrations for authentication.

To migrate from SharePoint app princpals to Entra ID app regisrations, replace the following settings in your existing SharePoint connector, as listed in the requirements following this note:

  • Replace the deprecated SharePoint app principal’s application client ID value with your replacement Entra ID app registration’s Application (client) ID value.
  • Replace the deprecated SharePoint app principal’s client secret value with your replacement Entra ID app registration’s Client secret value.
  • Add your replacement Entra ID app registration’s Directory (tenant) ID value, token authority URL value, and the correct set of Microsoft Graph access permissions for SharePoint Online.

If you need migration help, get assistance from our Slack community or contact us directly.

  • A SharePoint Online plan, or a Microsoft 365 or Office 365 Business or enterprise plan that includes SharePoint Online. Learn more. Shop for business plans. Shop for enterprise plans.

  • A OneDrive for business plan, or a Microsoft 365 or Office 365 Business or enterprise plan that includes OneDrive. (Even if you only plan to use SharePoint Online, you still need a plan that includes OneDrive, because the SharePoint connector is built on OneDrive technology.) Learn more. Shop for business plans. Shop for enterprise plans. OneDrive personal accounts, and Microsoft 365 Free, Basic, Personal, and Family plans are not supported.

  • The SharePoint Online and OneDrive plans must share the same Microsoft Entra ID tenant. Learn more.

  • The User Principal Name (UPN) for the OneDrive account in the Microsoft Entra ID tenant. This is typically the OneDrive account user’s email address. To find a UPN:

    1. Depending on your plan, sign in to your Microsoft 365 admin center (typically https://admin.microsoft.com) using your administrator credentials, or sign in to your Office 365 portal (typically https://portal.office.com) using your credentials.
    2. In the Users section, click Active users.
    3. Locate the user account in the list of active users.
    4. The UPN is displayed in the Username column.

    The following video shows how to get a UPN:

  • The SharePoint Online site URL.

    • Site collection-level URLs typically have the format https://<tenant>.sharepoint.com/sites/<site-collection-name>.
    • Root site collection-level URLs typically have the format https://<tenant>.sharepoint.com.
    • To process all sites within a SharePoint tenant, use a site URL of https://<tenant>-admin.sharepoint.com.

    Learn more.

  • The path in the SharePoint Online site from which to start parsing files, for example "Shared Documents". If the SharePoint connector is to process all sites within the tenant, this filter will be applied to all site document libraries.

    The following video shows how to get the site URL and a path within the site:

  • The Application (client) ID, Directory (tenant) ID, and Client secret for the Microsoft Entra ID app registration with the correct set of Microsoft Graph access permissions. These permissions include:

    • Sites.ReadWrite.All (if both reading and writing are needed)

    • User.Read.All Learn more.

    1. Create an Entra ID app registration.
    2. Add Graph access permissions to an app registration.
    3. Grant consent for the added Graph permissions.

    The following video shows how to create an Entra ID app registration:

    The following video shows how to add the correct set of Graph access permissions to the Entra ID app registration:

  • The token authority URL for your Microsoft Entra ID app registration. This is typically https://login.microsoftonline.com

The SharePoint connector dependencies:

CLI, Python
pip install "unstructured-ingest[sharepoint]"

You might also need to install additional dependencies, depending on your needs. Learn more.

The following environment variables:

  • ENTRA_ID_USER_PRINCIPAL_NAME - The User Principal Name (UPN) for the target OneDrive account in the Microsoft Entra ID tenant.
  • SHAREPOINT_SITE_URL - The SharePoint site URL, represented by --site (CLI) or site (Python).
  • SHAREPOINT_SITE_PATH - The path in the SharePoint site from which to start parsing files, represented by --path (CLI) or path (Python).
  • ENTRA_ID_APP_CLIENT_ID - The Application (client) ID value for the Microsoft Entra ID app registration, represented by --client-id (CLI) or client_id (Python).
  • ENTRA_ID_APP_TENANT_ID - The Directory (tenant) ID value for the Entra ID app registration, represented by --client-id (CLI) or client_id (Python).
  • ENTRA_ID_APP_CLIENT_SECRET - The Client secret value for the Entra ID app registration, represented by --client-cred (CLI) or client_cred (Python).
  • ENTRA_ID_TOKEN_AUTHORITY_URL - The token authority URL for the Entra ID app registration (which is typically https://login.microsoftonline.com), represented by --authority-url (CLI) or authority_url (Python).

Now call the Unstructured Ingest CLI or the Unstructured Ingest Python library. The destination connector can be any of the ones supported. This example uses the local destination connector.

This example sends data to Unstructured for processing by default. To process data locally instead, see the instructions at the end of this page.

#!/usr/bin/env bash

unstructured-ingest \
  sharepoint \
    --client-cred $ENTRA_ID_APP_CLIENT_SECRET \
    --client-id $ENTRA_ID_APP_CLIENT_ID \
    --user-pname $ENTRA_ID_USER_PRINCIPAL_NAME \
    --tenant $ENTRA_ID_APP_TENANT_ID \
    --authority-url $ENTRA_ID_TOKEN_AUTHORITY_URL \
    --site $SHAREPOINT_SITE_URL \
    --path $SHAREPOINT_SITE_PATH \
    --recursive \
    --download-dir $LOCAL_FILE_DOWNLOAD_DIR\
    --partition-by-api \
    --api-key $UNSTRUCTURED_API_KEY \
    --partition-endpoint $UNSTRUCTURED_API_URL \
    --strategy hi_res \
    --output-dir $LOCAL_FILE_OUTPUT_DIR \
    --additional-partition-args="{\"split_pdf_page\":\"true\", \"split_pdf_allow_failed\":\"true\", \"split_pdf_concurrency_level\": 15}"

For the Unstructured Ingest CLI and the Unstructured Ingest Python library, you can use the --partition-by-api option (CLI) or partition_by_api (Python) parameter to specify where files are processed:

  • To do local file processing, omit --partition-by-api (CLI) or partition_by_api (Python), or explicitly specify partition_by_api=False (Python).

    Local file processing does not use an Unstructured API key or API URL, so you can also omit the following, if they appear:

    • --api-key $UNSTRUCTURED_API_KEY (CLI) or api_key=os.getenv("UNSTRUCTURED_API_KEY") (Python)
    • --partition-endpoint $UNSTRUCTURED_API_URL (CLI) or partition_endpoint=os.getenv("UNSTRUCTURED_API_URL") (Python)
    • The environment variables UNSTRUCTURED_API_KEY and UNSTRUCTURED_API_URL
  • To send files to the Unstructured Platform Partition Endpoint for processing, specify --partition-by-api (CLI) or partition_by_api=True (Python).

    Unstructured also requires an Unstructured API key and API URL, by adding the following:

    • --api-key $UNSTRUCTURED_API_KEY (CLI) or api_key=os.getenv("UNSTRUCTURED_API_KEY") (Python)
    • --partition-endpoint $UNSTRUCTURED_API_URL (CLI) or partition_endpoint=os.getenv("UNSTRUCTURED_API_URL") (Python)
    • The environment variables UNSTRUCTURED_API_KEY and UNSTRUCTURED_API_URL, representing your API key and API URL, respectively.

    Get an API key and API URL.