> For the complete documentation index, see [llms.txt](https://docs.stackai.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.stackai.com/integrations/catalog/onedrive.md).

# OneDrive

Connect to OneDrive for cloud storage, file management, and Excel operations.

* Knowledge base source
* Federated Search

### Connectors

Choose the connector that matches your authentication method. The options below use the names shown in StackAI.

| Connector           | Authentication |
| ------------------- | -------------- |
| OneDrive (App-Only) | Credentials    |
| OneDrive            | OAuth sign-in  |

#### OneDrive (App-Only)

Connect to OneDrive using client credentials for app-only authentication. Ideal for background services and automation.

**Set up in OneDrive**

1. In the Azure portal, go to **Microsoft Entra ID → App registrations → New registration** and register an application.
2. Under **API permissions**, add the Microsoft Graph **application** permissions the app needs (for example Files.ReadWrite.All) and grant admin consent.
3. Under **Certificates & secrets → New client secret**, create a secret and copy its value immediately (it is shown only once).
4. Copy the **Application (client) ID** and **Directory (tenant) ID** from the app overview.

**Set up in StackAI**

1. Open **Settings → Connections**, add a connection, and select **OneDrive (App-Only)**.
2. Enter the credentials and connection details in the fields below.
3. Save the connection and check its connection status. Select this saved connection when configuring an action or feature that uses it.

**Connection fields**

| StackAI field       | Required | What to enter                                                                                                                                           |
| ------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Client ID           | Yes      | Azure AD application client ID. [Provider instructions](https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredApps).     |
| Client Secret       | Yes      | Azure AD application client secret. [Provider instructions](https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredApps). |
| Tenant ID           | Yes      | Azure AD tenant ID where the app is registered.                                                                                                         |
| User Principal Name | Yes      | The user principal name (UPN) of the OneDrive user to access.                                                                                           |

**Provider documentation:** [Setup reference](https://learn.microsoft.com/en-us/graph/auth-register-app-v2).

#### OneDrive

Connect to Microsoft OneDrive using OAuth2 authentication. Supports file operations and content access.

**Set up in OneDrive**

1. Sign in with your Microsoft account.
2. Review and authorize the requested file-access permissions.

**Set up in StackAI**

1. Open **Settings → Connections**, add a connection, and select **OneDrive**.
2. Select **Connect**, sign in to the provider account, and review the requested access. Complete authorization to return to StackAI.
3. Save the connection and check its connection status. Select this saved connection when configuring an action or feature that uses it.

StackAI obtains the OAuth credentials during sign-in. You do not need to paste an access token or refresh token.

**Provider documentation:** [Setup reference](https://learn.microsoft.com/en-us/onedrive/developer/rest-api/).

#### Verify the connection

Check that the connection is healthy. Then run a read operation against a resource the connected account can access. A successful connection check confirms authentication; it does not guarantee permission for every action.

If access is denied, check the credential or OAuth permissions, the selected account or environment, and access to the specific resource. Update expired credentials or reconnect after permissions change.

#### Detailed setup guides

* [Connect OneDrive](https://docs.stackai.com/integrations/catalog/onedrive/connect-onedrive.md)
* [Allow StackAI in Microsoft Entra](https://docs.stackai.com/integrations/catalog/microsoft-entra/allow-stackai-in-microsoft-entra.md)

## Use an action

1. Add the required **OneDrive** action to the workflow.
2. Select a connection when the action requests one.
3. Complete the required fields. Use the reference picker when a value comes from another workflow step.
4. Run the workflow and inspect the action’s output. Check the result before using it in a later step.

### Actions

#### Get File

Download a file from OneDrive and extract its content.

**Inputs**

| Field       | Type         | Required | Description                                                                                                                                 |
| ----------- | ------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| File        | file\_picker | Yes      | Browse your OneDrive to select a file, or enter a file ID manually.                                                                         |
| Parse Files | boolean      | No       | Whether to download and parse the file contents. When disabled, only the signed download URL and file metadata are returned. Default: true. |

**Outputs**

| Field            | Type   | Description                                                                  |
| ---------------- | ------ | ---------------------------------------------------------------------------- |
| File ID          | string | The unique identifier of the file.                                           |
| File Name        | string | The name of the file.                                                        |
| OneDrive URL     | string | The web URL to the file in OneDrive.                                         |
| File Content     | string | The extracted text content of the file (no OCR).                             |
| Download URL     | string | Pre-authenticated URL to download the file (temporary, expires in \~1 hour). |
| Modified Date    | string | When the file was last modified in OneDrive (ISO 8601, UTC).                 |
| Created Date     | string | When the file was created in OneDrive (ISO 8601, UTC).                       |
| Size (bytes)     | number | Size of the file in bytes.                                                   |
| Last Modified By | string | Display name of the user who last modified the file.                         |

#### List Files

List files in a OneDrive folder, optionally including all subfolders.

**Inputs**

| Field            | Type         | Required | Description                                                                                                                                                                                                |
| ---------------- | ------------ | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Parent Folder    | file\_picker | No       | Folder whose files should be listed. You can provide a folder ID or a root-relative path like /Reports/2025. Defaults to root.                                                                             |
| Recursive        | boolean      | No       | When enabled, lists files from all subfolders recursively. When disabled, only lists direct child files. Default: false.                                                                                   |
| Max Results      | integer      | No       | Maximum number of files to return (1-20000). Defaults to 20000; reduce for smaller listings. Minimum: 1. Maximum: 20000. Default: 20000.                                                                   |
| Max Folder Depth | integer      | No       | Only applies when Recursive is on. Cap the nested folder levels traversed below the selected Parent Folder (1-20). Defaults to 20; reduce to scope a recursive walk. Minimum: 1. Maximum: 20. Default: 20. |

**Outputs**

| Field       | Type          | Description                                      |
| ----------- | ------------- | ------------------------------------------------ |
| Files       | object\_array | Files found in the selected folder.              |
| Total Count | number        | Number of files returned.                        |
| Has More    | boolean       | True when the listing was capped by Max Results. |

#### List Folders

List folders in a OneDrive folder.

**Inputs**

| Field         | Type         | Required | Description                                                                                                                                   |
| ------------- | ------------ | -------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| Parent Folder | file\_picker | No       | Folder whose direct child folders should be listed. You can provide a folder ID or a root-relative path like /Reports/2025. Defaults to root. |
| Max Results   | integer      | No       | Maximum number of folders to return. Defaults to 1000. Minimum: 1. Default: 1000.                                                             |

**Outputs**

| Field       | Type          | Description                           |
| ----------- | ------------- | ------------------------------------- |
| Folders     | object\_array | Folders found in the selected folder. |
| Total Count | number        | Number of folders returned.           |

#### Search Files

Search for files and documents in OneDrive

**Inputs**

| Field        | Type                      | Required | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ------------ | ------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Search Query | string                    | Yes      | Search query to find files in OneDrive.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| Folder       | file\_picker              | No       | Folder to restrict the search to, including its subfolders. You can provide a folder ID or a root-relative path like /Reports/2025. Leave empty to search the whole drive.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| File Types   | multiple\_select (string) | No       | Filter results by specific file types. Available values: PDF, Word Document (.docx), Excel Spreadsheet (.xlsx), PowerPoint (.pptx), Text File (.txt), CSV File (.csv), Word Document (.doc), Excel Spreadsheet (.xls), PowerPoint (.ppt), JPEG Image (.jpg), JPEG Image (.jpeg), HTML Document (.html), HTML Document (.htm), Outlook Message (.msg), Email Message (.eml), Excel Macro-Enabled (.xlsm), Word Macro-Enabled (.docm), PowerPoint Macro-Enabled (.pptm), Excel Binary (.xlsb), Visio Drawing (.vsdx), Visio Drawing (.vsd), Publisher Document (.pub), ZIP Archive (.zip), XML Document (.xml), Rich Text Format (.rtf), OpenDocument Text (.odt), OpenDocument Spreadsheet (.ods), OpenDocument Presentation (.odp), Web Archive (.mhtml). Default: \[]. |
| Max Results  | integer                   | No       | Maximum number of results to return (minimum: 1, default: 20). Minimum: 1. Default: 20.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |

**Outputs**

| Field       | Type          | Description                  |
| ----------- | ------------- | ---------------------------- |
| Files       | object\_array | List of found files.         |
| Total Count | number        | Total number of files found. |

#### Delete File

Delete a file from OneDrive (moves to recycle bin).

**Inputs**

| Field | Type         | Required | Description                                                                                                                                                |
| ----- | ------------ | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| File  | file\_picker | Yes      | Browse your OneDrive to select a file, or enter a file ID manually. The file will be moved to the recycle bin and can be restored from OneDrive if needed. |

**Outputs**

| Field     | Type   | Description                   |
| --------- | ------ | ----------------------------- |
| File ID   | string | The ID of the deleted file.   |
| File Name | string | The name of the deleted file. |
| Result    | string | Result message.               |

#### Create Folder

Create a new folder in OneDrive.

**Inputs**

| Field         | Type         | Required | Description                                                  |
| ------------- | ------------ | -------- | ------------------------------------------------------------ |
| Folder Name   | string       | Yes      | Name for the new folder.                                     |
| Parent Folder | file\_picker | No       | Parent folder to create the new folder in. Defaults to root. |

**Outputs**

| Field       | Type   | Description                     |
| ----------- | ------ | ------------------------------- |
| Folder ID   | string | The ID of the created folder.   |
| Folder Name | string | The name of the created folder. |
| Web URL     | string | URL to the folder in OneDrive.  |
| Result      | string | Result message.                 |

#### Create File

Upload a new file to OneDrive.

**Inputs**

| Field          | Type            | Required | Description                                                                                                                                  |
| -------------- | --------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| File Name      | string          | Yes      | Name for the new file (include extension).                                                                                                   |
| Content Source | select (string) | No       | How to provide file content. Text source supports .txt, .md, .docx, and .pptx only — use URL for other formats. Available values: Text, URL. |
| File Content   | textarea        | No       | Text content for the file.                                                                                                                   |
| File URL       | string          | No       | URL to download file content from.                                                                                                           |
| Parent Folder  | file\_picker    | No       | Folder to upload the file into. Defaults to root.                                                                                            |

**Outputs**

| Field     | Type   | Description                       |
| --------- | ------ | --------------------------------- |
| File ID   | string | The ID of the created file.       |
| File Name | string | The name of the created file.     |
| Web URL   | string | URL to view the file in OneDrive. |
| File Size | number | File size in bytes.               |
| Result    | string | Result message.                   |

#### Update File

Update a file's content and/or name in OneDrive.

**Inputs**

| Field          | Type            | Required | Description                                                                                                                                                                     |
| -------------- | --------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| File           | file\_picker    | Yes      | Browse your OneDrive to select a file, or enter a file ID manually. Note: updating content replaces the entire file, it does not append.                                        |
| New File Name  | string          | No       | New name for the file (include extension). Leave empty to keep current name.                                                                                                    |
| Content Source | select (string) | No       | How to provide replacement content. Text source supports .txt, .md, .docx, and .pptx only — use URL for other formats. Leave empty to only rename. Available values: Text, URL. |
| File Content   | textarea        | No       | Text content to overwrite the file with.                                                                                                                                        |
| File URL       | string          | No       | URL to download replacement content from.                                                                                                                                       |

**Outputs**

| Field     | Type   | Description                       |
| --------- | ------ | --------------------------------- |
| File ID   | string | The ID of the updated file.       |
| File Name | string | The name of the updated file.     |
| Web URL   | string | URL to view the file in OneDrive. |
| File Size | number | File size in bytes.               |
| Result    | string | Result message.                   |

#### Move File

Move a file or folder to a different location in OneDrive.

**Inputs**

| Field               | Type            | Required | Description                                                                                                                                                               |
| ------------------- | --------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Source File/Folder  | file\_picker    | Yes      | Browse your OneDrive to select a file or folder to move, or enter an item ID manually.                                                                                    |
| Destination Folder  | file\_picker    | Yes      | Browse your OneDrive to select the destination folder, or enter a folder ID manually. Enter 'root' to move to the drive root.                                             |
| New Name (Optional) | string          | No       | Optionally rename the item at the destination. For files, enter the base name only (e.g. 'Q1 Report') — the original file extension is preserved automatically.           |
| If Name Conflict    | select (string) | No       | What to do when an item with the same name already exists at the destination. Default: Fail. Available values: Fail, Replace, Rename (append copy number). Default: fail. |

**Outputs**

| Field   | Type   | Description                                                      |
| ------- | ------ | ---------------------------------------------------------------- |
| Item ID | string | The ID of the moved item.                                        |
| Name    | string | The full name of the moved item (including extension for files). |
| Web URL | string | URL to view the item in OneDrive.                                |
| Path    | string | The new path of the item in the drive.                           |
| Result  | string | Result message.                                                  |

#### List Workbooks

List all Excel workbooks from a SharePoint site

**Inputs**

| Field | Type            | Required | Description                                                                                                         |
| ----- | --------------- | -------- | ------------------------------------------------------------------------------------------------------------------- |
| Site  | select (string) | Yes      | Select the site (SharePoint or OneDrive), or enter the site ID manually. Options load from the selected connection. |

**Outputs**

| Field          | Type     | Description                  |
| -------------- | -------- | ---------------------------- |
| Status         | string   | Status of the operation.     |
| Workbooks      | textarea | The workbooks data as JSON.  |
| Workbook Count | number   | Number of workbooks found.   |
| Message        | string   | Message about the operation. |

#### List Sheets

List all worksheets in an Excel workbook

**Inputs**

| Field    | Type            | Required | Description                                                                                                         |
| -------- | --------------- | -------- | ------------------------------------------------------------------------------------------------------------------- |
| Site     | select (string) | Yes      | Select the site (SharePoint or OneDrive), or enter the site ID manually. Options load from the selected connection. |
| Workbook | select (string) | Yes      | Select the Excel workbook, or enter the workbook URL manually. Options load from the selected connection.           |

**Outputs**

| Field       | Type     | Description                       |
| ----------- | -------- | --------------------------------- |
| Status      | string   | Status of the operation.          |
| Sheets      | textarea | The sheets data as JSON.          |
| Sheet Count | number   | Number of sheets in the workbook. |
| Message     | string   | Message about the operation.      |

#### Read from Sheet

Read data from an Excel sheet

**Inputs**

| Field                    | Type            | Required | Description                                                                                                         |
| ------------------------ | --------------- | -------- | ------------------------------------------------------------------------------------------------------------------- |
| Site                     | select (string) | Yes      | Select the site (SharePoint or OneDrive), or enter the site ID manually. Options load from the selected connection. |
| Workbook                 | select (string) | Yes      | Select the Excel workbook, or enter the workbook URL manually. Options load from the selected connection.           |
| Sheet                    | select (string) | Yes      | Select the worksheet to get rows from, or enter the sheet name manually. Options load from the selected connection. |
| Range Address (Optional) | string          | No       | Specific range to get rows from (leave empty to get all used rows).                                                 |

**Outputs**

| Field         | Type     | Description                      |
| ------------- | -------- | -------------------------------- |
| Status        | string   | Status of the operation.         |
| Rows          | textarea | The retrieved rows data as JSON. |
| Row Count     | number   | Number of rows retrieved.        |
| Range Address | string   | The range that was read.         |
| Message       | string   | Message about the operation.     |

#### Create Sheet

Create a new sheet in an Excel workbook

**Inputs**

| Field    | Type            | Required | Description                                                                                                                    |
| -------- | --------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------ |
| Site     | select (string) | Yes      | Select the site (SharePoint or OneDrive), or enter the site ID manually. Options load from the selected connection.            |
| Workbook | select (string) | Yes      | Select the Excel workbook to create a sheet in, or enter the workbook URL manually. Options load from the selected connection. |
| Sheet    | string          | Yes      | Enter the name for the new sheet.                                                                                              |

**Outputs**

| Field      | Type   | Description                    |
| ---------- | ------ | ------------------------------ |
| Status     | string | Status of the operation.       |
| Sheet ID   | string | The ID of the created sheet.   |
| Sheet Name | string | The name of the created sheet. |
| Message    | string | Message about the operation.   |

#### Create Table

Create a table in an Excel sheet

**Inputs**

| Field                  | Type            | Required | Description                                                                                                                                                                              |
| ---------------------- | --------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Site                   | select (string) | Yes      | Select the site (SharePoint or OneDrive), or enter the site ID manually. Options load from the selected connection.                                                                      |
| Workbook               | select (string) | Yes      | Select the Excel workbook, or enter the workbook URL manually. Options load from the selected connection.                                                                                |
| Sheet                  | select (string) | Yes      | Select the worksheet or enter the sheet name. Options load from the selected connection.                                                                                                 |
| Values                 | textarea        | Yes      | Enter the values to create the table with (JSON)Example: \[{"col1": "val1", "col2": 2}, {"col1": "val2", "col2": 3}] or \[\["val1", 2], \["val2", 3]] or {"col1": "val1", "col2": 2}.    |
| Starting Cell          | string          | Yes      | The top-left cell where the table will start (used when table range is not specified). Default: A1.                                                                                      |
| Table Range (Optional) | string          | No       | The Excel range where the table will be created (e.g., A1:D10, B2:F20). If not provided, the range will be calculated automatically from the data size starting from the specified cell. |

**Outputs**

| Field      | Type   | Description                      |
| ---------- | ------ | -------------------------------- |
| Status     | string | Status of the operation.         |
| Message    | string | Message about the operation.     |
| Table Name | string | Name of the created Excel table. |

#### Clear Sheet

Clear data from an Excel sheet in SharePoint

**Inputs**

| Field                    | Type            | Required | Description                                                                                                                             |
| ------------------------ | --------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| Site                     | select (string) | Yes      | Select the site (SharePoint or OneDrive), or enter the site ID manually. Options load from the selected connection.                     |
| Workbook                 | select (string) | Yes      | Select the Excel workbook containing the sheet to clear, or enter the workbook URL manually. Options load from the selected connection. |
| Sheet                    | select (string) | Yes      | Enter the name of the worksheet to clear. Options load from the selected connection.                                                    |
| Range Address (Optional) | string          | No       | Optional: Specific range to clear (e.g., A1:D10). Leave empty to clear entire sheet.                                                    |

**Outputs**

| Field         | Type   | Description                  |
| ------------- | ------ | ---------------------------- |
| Status        | string | Status of the operation.     |
| Cleared Range | string | The range that was cleared.  |
| Message       | string | Message about the operation. |

#### Delete Sheet

Delete a sheet from an Excel workbook in SharePoint

**Inputs**

| Field    | Type            | Required | Description                                                                                                                              |
| -------- | --------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| Site     | select (string) | Yes      | Select the site (SharePoint or OneDrive), or enter the site ID manually. Options load from the selected connection.                      |
| Workbook | select (string) | Yes      | Select the Excel workbook containing the sheet to delete, or enter the workbook URL manually. Options load from the selected connection. |
| Sheet    | select (string) | Yes      | Select the worksheet to delete, or enter the sheet name manually. Options load from the selected connection.                             |

**Outputs**

| Field   | Type   | Description                  |
| ------- | ------ | ---------------------------- |
| Status  | string | Status of the operation.     |
| Message | string | Message about the operation. |

### Important behavior

If an operation is denied, check the connection’s granted permissions and the account’s access in the provider. Reauthorize the connection when it needs additional permissions.

Actions that create, update, send, or delete data can change the connected service. Review their inputs before running them. A retry can repeat an operation; consider this when configuring retries for actions that change data.

The catalog lists the fields and capabilities available in the supplied provider definition. Availability can also depend on your deployment and organization’s Feature Access settings.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.stackai.com/integrations/catalog/onedrive.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
