# Microsoft OneDrive

> Store, move, and share files with Microsoft OneDrive.

App · File Storage · 9 actions. Web page: https://docs.lodol.com/docs/integrations/microsoft-onedrive

## Actions

### Create folder

Create a new folder in OneDrive.

**Inputs**

- Folder name (`folder_name`, text, required): Name for the new folder.
- Parent item ID (`parent_item_id`, text): ID of the folder to create the new folder inside.
- Drive ID (`drive_id`, text, required): ID of the drive to use. You can find drive IDs with the List drives action.

**Outputs**

- `id` (text): Created folder item ID. Use as parent_item_id, destination_parent_id, or item_id in other OneDrive actions.
- `name` (text): Folder name.

**Example output**

```json
{
  "id": "folder123",
  "name": "NewFolder"
}
```

### Create share link

Create a sharing link for a file or folder.

**Inputs**

- Item ID (`item_id`, text, required): ID of the file or folder to share.
- Link type (`link_type`, text, required): Type of link to create (view or edit).
- Drive ID (`drive_id`, text, required): ID of the drive to use. You can find drive IDs with the List drives action.

**Outputs**

- `link` (object)

**Example output**

```json
{
  "link": {
    "webUrl": "https://..."
  }
}
```

### Create workbook

Create a new blank Excel workbook (.xlsx) in OneDrive.

**Inputs**

- Workbook name (`workbook_name`, text, required): Name for the new workbook (e.g. 'Q3 Sales'). .xlsx extension added automatically if missing.
- Parent item ID (`parent_item_id`, text): ID of the folder to create the workbook in.
- Drive ID (`drive_id`, text, required): ID of the drive to use. You can find drive IDs with the List drives action.

**Outputs**

- `id` (text): Created workbook item ID. Use as item_id in Microsoft Excel actions.
- `name` (text): Workbook filename.
- `webUrl` (text): Web URL to open the workbook.

**Example output**

```json
{
  "id": "workbook123",
  "name": "Q3 Sales.xlsx",
  "webUrl": "https://..."
}
```

### Delete file or folder

Delete a file or folder from OneDrive.

**Inputs**

- Item ID (`item_id`, text, required): ID of the file or folder to delete.
- Drive ID (`drive_id`, text, required): ID of the drive to use. You can find drive IDs with the List drives action.

**Outputs**

- `deleted` (true/false): Whether deletion succeeded.

**Example output**

```json
{
  "deleted": true
}
```

### List drives

List the drives available on a SharePoint site (uses the main site unless you specify one).

**Inputs**

- Site ID (`site_id`, text): SharePoint site ID. Leave blank to use the main site (defaults to 'root').

**Outputs**

- `value` (list): List of drives.

**Example output**

```json
{
  "value": [
    {
      "driveType": "documentLibrary",
      "id": "drive1",
      "name": "Documents"
    }
  ]
}
```

### List folder contents

List the contents of a folder in OneDrive.

**Inputs**

- Parent item ID (`parent_item_id`, text): ID of the folder to list.
- Drive ID (`drive_id`, text, required): ID of the drive to use. You can find drive IDs with the List drives action.

**Outputs**

- `value` (list): List of files and folders.

**Example output**

```json
{
  "value": [
    {
      "id": "item1",
      "name": "file1.txt"
    }
  ]
}
```

### Look up share link

Look up a Microsoft sharing link to get the drive ID and item ID of the shared file or folder.

**Inputs**

- Share URL (`share_url`, text, required): Microsoft sharing URL (e.g., from SharePoint or OneDrive).

**Outputs**

- `drive_id` (text): Drive ID. Use as drive_id in Microsoft Excel actions or other OneDrive actions.
- `item_id` (text): Item ID. Use as item_id in Microsoft Excel actions or other OneDrive actions.
- `name` (text): File or folder name.
- `web_url` (text): Web URL for the item.

**Example output**

```json
{
  "drive_id": "drive456",
  "item_id": "item123",
  "name": "Project Tracker.xlsx",
  "web_url": "https://..."
}
```

### Move file or folder

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

**Inputs**

- Item ID (`item_id`, text, required): ID of the file or folder to move.
- Destination parent ID (`destination_parent_id`, text, required): ID of the folder to move it into.
- Drive ID (`drive_id`, text, required): ID of the drive to use. You can find drive IDs with the List drives action.

**Outputs**

- `id` (text): Moved item ID. Use as item_id in delete_item or create_share_link.
- `name` (text): Item name.

**Example output**

```json
{
  "id": "item123",
  "name": "movedItem"
}
```

### Upload file

Upload a file to OneDrive.

**Inputs**

- File to upload (`file_path`, text, required): The file to upload to OneDrive.
- Parent item ID (`parent_item_id`, text): ID of the folder to upload the file into.
- Drive ID (`drive_id`, text, required): ID of the drive to use. You can find drive IDs with the List drives action.
- Conflict behavior (`conflict_behavior`, text): What to do if a file with the same name already exists: rename, replace, or fail.

**Outputs**

- `id` (text): Uploaded file item ID. Use as item_id in move_item, delete_item, or create_share_link.
- `name` (text): File name.
- `webUrl` (text): Web URL for the uploaded file.

**Example output**

```json
{
  "id": "item123",
  "name": "file.txt",
  "webUrl": "https://..."
}
```
