Setu Recipes: reusable workflows across every app.Browse templates

Integrations / OneDrive

OneDrive

Browse, search, organise and share files in OneDrive through Microsoft Graph.

9 actions OAuth 2 5 read3 write1 destructive Calls graph.microsoft.com

Connect

TypeScript
const conn = await setu.connections.initiate({ userId: "user_1", toolkit: "onedrive" });
console.log(conn.connectUrl); // show this to your user
await conn.waitUntilActive();

Permissions requested

ScopeWhy it is requested
Files.ReadRead the files in your OneDrive
Files.ReadWriteCreate folders, rename, delete and share files in your OneDrive
User.ReadIdentify which Microsoft account you connected
offline_accessStay connected without asking you to sign in again

Actions

Create folderwriteonedrive.create_folderCreate a new folder inside a OneDrive folder. By default a name clash gets a numbered name.

Needs scope: Files.ReadWrite

InputTypeDescription
parent_idstringRequiredParent folder item ID, for example from get_drive_root
namestringRequiredName of the new folder
conflict_behaviorstringOptionalWhat to do if the name exists (default rename)
TypeScript
await setu.execute({
  userId: "user_1",
  action: "onedrive.create_folder",
  input: {
    "parent_id": "<parent_id>",
    "name": "<name>"
  },
});
Delete file or folderdestructiveonedrive.delete_itemDelete a OneDrive file or folder (it goes to the recycle bin). A folder is deleted with everything inside it.

Needs scope: Files.ReadWrite

InputTypeDescription
item_idstringRequiredItem ID from a listing or search
TypeScript
await setu.execute({
  userId: "user_1",
  action: "onedrive.delete_item",
  input: {
    "item_id": "<item_id>"
  },
  confirm: true,
});
Get OneDrive root folderreadonedrive.get_drive_rootGet the root folder of the user's OneDrive, including its ID, which other actions need as a parent folder.

Needs scope: Files.Read

No input.

TypeScript
await setu.execute({
  userId: "user_1",
  action: "onedrive.get_drive_root",
  input: {},
});
Get file or folderreadonedrive.get_itemGet the details of one OneDrive file or folder: name, size, type, last modified time and its web link.

Needs scope: Files.Read

InputTypeDescription
item_idstringRequiredItem ID from a listing or search
TypeScript
await setu.execute({
  userId: "user_1",
  action: "onedrive.get_item",
  input: {
    "item_id": "<item_id>"
  },
});
List files in a folderreadonedrive.list_folder_childrenList the files and folders inside one OneDrive folder, given the folder's item ID.

Needs scope: Files.Read

InputTypeDescription
item_idstringRequiredFolder item ID from a listing, search or get_drive_root
topintegerOptionalMaximum number of items to return
TypeScript
await setu.execute({
  userId: "user_1",
  action: "onedrive.list_folder_children",
  input: {
    "item_id": "<item_id>"
  },
});
List files in OneDrive rootreadonedrive.list_root_filesList the files and folders at the top level of the user's OneDrive.

Needs scope: Files.Read

InputTypeDescription
topintegerOptionalMaximum number of items to return
TypeScript
await setu.execute({
  userId: "user_1",
  action: "onedrive.list_root_files",
  input: {},
});
Rename file or folderwriteonedrive.rename_itemRename a OneDrive file or folder without changing its content or location.

Needs scope: Files.ReadWrite

InputTypeDescription
item_idstringRequiredItem ID from a listing or search
namestringRequiredThe new name, including the file extension
TypeScript
await setu.execute({
  userId: "user_1",
  action: "onedrive.rename_item",
  input: {
    "item_id": "<item_id>",
    "name": "<name>"
  },
});
Search filesreadonedrive.search_filesSearch the user's OneDrive by file name, metadata and content. Avoid apostrophes in the search text.

Needs scope: Files.Read

InputTypeDescription
qstringRequiredSearch text, for example: Contoso Project (no apostrophes)
topintegerOptionalMaximum number of items to return
TypeScript
await setu.execute({
  userId: "user_1",
  action: "onedrive.search_files",
  input: {
    "q": "<q>"
  },
});