# OneDrive (/integrations/onedrive)

Use cases and templates: [OneDrive integration for AI agents](https://www.sim.ai/integrations/onedrive)





<BlockInfoCard type="onedrive" color="#FFFFFF" />

{/* MANUAL-CONTENT-START:intro */}

Use [OneDrive](https://onedrive.live.com) to upload, download, search, and organize files and folders. The actions below also cover metadata, copying or moving items, sharing links, and deletion.

{/* MANUAL-CONTENT-END */}

## OAuth scopes [#oauth-scopes]

Sim requests these scopes when someone connects an OneDrive account. For a self-hosted deployment, register your own app with the provider using the settings below. See [Integrations and OAuth](/platform/self-hosting/integrations-oauth) for setup.

| Setting | Value |
| - | - |
| Redirect URI | `<NEXT_PUBLIC_APP_URL>/api/auth/oauth2/callback/onedrive` |
| Environment variables | `MICROSOFT_CLIENT_ID`, `MICROSOFT_CLIENT_SECRET` |

| Scope | Description |
| - | - |
| `openid` | Standard authentication |
| `profile` | Access profile information |
| `email` | Access email address |
| `Files.Read` | Read OneDrive files |
| `Files.ReadWrite` | Read and write OneDrive files |
| `offline_access` | Access account when not using the application |

## Use the block [#usage-instructions]

Create text and Excel files, upload files, download files, list and search files, move or rename files, copy files, create sharing links, and delete files or folders.

## Actions [#actions]

### Upload to OneDrive [#upload-to-onedrive]

Upload a file to OneDrive

#### Input [#input]

| Parameter | Type | Required | Description |
| - | - | - | - |
| `fileName` | string | Yes | The name of the file to upload (e.g., "report.pdf", "data.xlsx") |
| `file` | file | No | The file to upload (binary) |
| `content` | string | No | The text content to upload (if no file is provided) |
| `mimeType` | string | No | The MIME type of the file to create (e.g., text/plain for .txt, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet for .xlsx) |
| `folderId` | string | No | Folder ID to upload the file to (e.g., "01BYE5RZ6QN3ZWBTUFOFD3GSPGOHDJD36M") |

#### Output [#output]

| Parameter | Type | Description |
| - | - | - |
| `success` | boolean | Whether the file was uploaded successfully |
| `file` | object | The uploaded file object with metadata including id, name, webViewLink, webContentLink, and timestamps |

### Create Folder in OneDrive [#create-folder-in-onedrive]

Create a new folder in OneDrive

#### Input [#input-1]

| Parameter | Type | Required | Description |
| - | - | - | - |
| `folderName` | string | Yes | Name of the folder to create (e.g., "My Documents", "Project Files") |
| `folderId` | string | No | Parent folder ID to create the folder in (e.g., "01BYE5RZ6QN3ZWBTUFOFD3GSPGOHDJD36M") |

#### Output [#output-1]

| Parameter | Type | Description |
| - | - | - |
| `success` | boolean | Whether the folder was created successfully |
| `file` | object | The created folder object with metadata including id, name, webViewLink, and timestamps |

### Download File from OneDrive [#download-file-from-onedrive]

Download a file from OneDrive

#### Input [#input-2]

| Parameter | Type | Required | Description |
| - | - | - | - |
| `fileId` | string | Yes | The ID of the file to download (e.g., "01BYE5RZ6QN3ZWBTUFOFD3GSPGOHDJD36M") |
| `fileName` | string | No | Optional filename override (e.g., "report.pdf", "data.xlsx") |

#### Output [#output-2]

| Parameter | Type | Description |
| - | - | - |
| `file` | file | Downloaded file stored in execution files |

### List OneDrive Files [#list-onedrive-files]

List files and folders in OneDrive

#### Input [#input-3]

| Parameter | Type | Required | Description |
| - | - | - | - |
| `folderId` | string | No | Folder ID to list files from (e.g., "01BYE5RZ6QN3ZWBTUFOFD3GSPGOHDJD36M") |
| `query` | string | No | Filter files by name prefix (e.g., "report", "invoice\_2024") |
| `pageSize` | number | No | Maximum number of files to return (e.g., 10, 50, 100) |
| `pageToken` | string | No | Continuation URL from a previous response's nextPageToken, used to fetch the next page |

#### Output [#output-3]

| Parameter | Type | Description |
| - | - | - |
| `success` | boolean | Whether files were listed successfully |
| `files` | array | Array of file and folder objects with metadata |
| `nextPageToken` | string | Token for retrieving the next page of results (optional) |

### Search OneDrive Files [#search-onedrive-files]

Search for files and folders across OneDrive by name, metadata, or content (recursive)

#### Input [#input-4]

| Parameter | Type | Required | Description |
| - | - | - | - |
| `query` | string | No | Search text matched against file name, metadata, and content. Not required when paginating with pageToken |
| `pageSize` | number | No | Maximum number of results to return (e.g., 10, 50, 100) |
| `pageToken` | string | No | Continuation URL from a previous response's nextPageToken, used to fetch the next page |

#### Output [#output-4]

| Parameter | Type | Description |
| - | - | - |
| `success` | boolean | Whether the search completed successfully |
| `files` | array | Array of file and folder objects matching the search query |
| `nextPageToken` | string | Token for retrieving the next page of results (optional) |

### Get OneDrive Item Metadata [#get-onedrive-item-metadata]

Get metadata for a specific OneDrive file or folder by ID, or the drive root

#### Input [#input-5]

| Parameter | Type | Required | Description |
| - | - | - | - |
| `fileId` | string | No | The ID of the file or folder to retrieve (e.g., "01BYE5RZ6QN3ZWBTUFOFD3GSPGOHDJD36M"). Leave empty to get the drive root folder |

#### Output [#output-5]

| Parameter | Type | Description |
| - | - | - |
| `success` | boolean | Whether the item metadata was retrieved |
| `file` | object | The file or folder metadata, including id, name, webViewLink, size, and timestamps |

### Get OneDrive Info [#get-onedrive-info]

Get information about the OneDrive drive, including storage quota

#### Input [#input-6]

| Parameter | Type | Required | Description |
| - | - | - | - |

#### Output [#output-6]

| Parameter | Type | Description |
| - | - | - |
| `success` | boolean | Whether the drive info was retrieved |
| `driveId` | string | The ID of the drive |
| `driveType` | string | The type of drive (e.g., "personal", "business") |
| `webUrl` | string | URL to the drive in the browser |
| `owner` | string | Display name of the drive owner |
| `quota` | object | Storage quota information in bytes (total, used, remaining, deleted, state) |

### Move or Rename OneDrive File [#move-or-rename-onedrive-file]

Move a file or folder to a new parent folder, rename it, or both

#### Input [#input-7]

| Parameter | Type | Required | Description |
| - | - | - | - |
| `fileId` | string | Yes | The ID of the file or folder to move or rename |
| `destinationFolderId` | string | No | The ID of the destination parent folder (omit to only rename in place) |
| `newName` | string | No | The new name for the file or folder (omit to only move) |

#### Output [#output-7]

| Parameter | Type | Description |
| - | - | - |
| `success` | boolean | Whether the move or rename was successful |
| `file` | object | The updated file object with its new name and/or parent folder |

### Copy OneDrive File [#copy-onedrive-file]

Copy a file or folder to another location within OneDrive

#### Input [#input-8]

| Parameter | Type | Required | Description |
| - | - | - | - |
| `fileId` | string | Yes | The ID of the file or folder to copy |
| `destinationFolderId` | string | Yes | The ID of the destination parent folder |
| `destinationFileName` | string | No | Optional new name for the copy (defaults to the original name) |

#### Output [#output-8]

| Parameter | Type | Description |
| - | - | - |
| `success` | boolean | Whether the copy request was accepted |
| `sourceFileId` | string | The ID of the file or folder that was copied |
| `name` | string | The requested name for the copy, if provided |
| `monitorUrl` | string | URL to poll for the status of the asynchronous copy operation (copy completes in the background) |

### Create OneDrive Sharing Link [#create-onedrive-sharing-link]

Create a view or edit sharing link for a OneDrive file or folder

#### Input [#input-9]

| Parameter | Type | Required | Description |
| - | - | - | - |
| `fileId` | string | Yes | The ID of the file or folder to share |
| `linkType` | string | No | Type of link to create: "view" (read-only), "edit" (read-write), or "embed" |
| `linkScope` | string | No | Who can use the link: "anonymous" (anyone), "organization" (tenant members), or "users" (specific people) |

#### Output [#output-9]

| Parameter | Type | Description |
| - | - | - |
| `success` | boolean | Whether the sharing link was created successfully |
| `link` | object | The created sharing link, including its type, scope, and URL |

### Delete File from OneDrive [#delete-file-from-onedrive]

Delete a file or folder from OneDrive

#### Input [#input-10]

| Parameter | Type | Required | Description |
| - | - | - | - |
| `fileId` | string | Yes | The ID of the file or folder to delete (e.g., "01BYE5RZ6QN3ZWBTUFOFD3GSPGOHDJD36M") |

#### Output [#output-10]

| Parameter | Type | Description |
| - | - | - |
| `success` | boolean | Whether the file was deleted successfully |
| `deleted` | boolean | Confirmation that the file was deleted |
| `fileId` | string | The ID of the deleted file |
