Microsoft

Microsoft Graph: OneDrive and SharePoint files

Browse drives and folders, upload, download, copy, move and delete files, create sharing links, set permissions, track changes with delta and read thumbnails…

Productivity & workspace#openapi

Fork copies the collection into your workspace, without the publisher's secrets, so you can add your own key and send requests. Star saves it to your starred APIs (Account › Marketplace) and helps others find it.

Overview

Browse drives and folders, upload, download, copy, move and delete files, create sharing links, set permissions, track changes with delta and read thumbnails and versions.

This listing is one area of Microsoft Graph, the single REST API for Microsoft 365, Outlook, OneDrive, Teams and Microsoft Entra ID. It holds 129 of the area's requests, the most direct ones first, generated from Microsoft's own OpenAPI description of Graph v1.0. The other areas (mail, calendar, files, Teams, users and more) are listed separately on the Microsoft page.

Get an access token

  1. Sign in to the Microsoft Entra admin center and open App registrations > New registration. For a quick test, the Graph Explorer signs you in and shows a token without registering anything.
  2. Under API permissions, add the Microsoft Graph permissions this area needs, for example: Files.Read, Files.ReadWrite, Files.ReadWrite.All, Sites.Read.All. Delegated permissions act as the signed-in user; application permissions act as the app itself and need an administrator's consent.
  3. Under Certificates & secrets, create a client secret (keep it out of shared collections).
  4. Get a token from https://login.microsoftonline.com/ /oauth2/v2.0/token: the authorization-code flow for a user, or grant_type=client_credentials with scope=https://graph.microsoft.com/.default for an app. Send it as Authorization: Bearer .

Using these requests

  • Base URL: https://graph.microsoft.com/v1.0. /me/... paths act on the signed-in user; with an application token use /users/{id or userPrincipalName}/... instead.
  • Shape responses with OData query parameters: $select (fields), $filter, $orderby, $top, $expand and $search (some need the ConsistencyLevel: eventual header). Long lists are paged: follow @odata.nextLink.
  • Combine up to 20 requests in one call with POST /$batch.

Common errors

StatusCodeWhat to do
401InvalidAuthenticationTokenThe token is missing, expired or for another resource: get a new one for https://graph.microsoft.com.
403Authorization_RequestDenied / ErrorAccessDeniedAdd the permission listed in the request's docs and grant consent.
404ResourceNotFound / itemNotFoundCheck the id; ids from another user or tenant are not found.
429TooManyRequestsThrottled: wait the Retry-After seconds, then retry.

Docs: OneDrive and SharePoint files overview · Permissions reference · Throttling

Endpoints 129

Actions and more

  • GETGet drive/me/driveRetrieve the properties and relationships of a Drive resource. A Drive is the top-level container for a file system, such as OneDrive or SharePoint document…

Drives

  • GETList drives/drives
  • POSTCreate drive/drives
  • GETGet drive/drives/:drive-id
  • DELETEDelete drive/drives/:drive-id
  • PATCHUpdate drive/drives/:drive-id
  • GETRecent drive/drives/:drive-id/recent()Deprecated. List a set of items recently used by the signed-in user. This collection includes items that are in the user's drive and items they have access to…
  • GETShared with me (drive)/drives/:drive-id/sharedWithMe()Deprecated. Get a list of driveItem objects shared with the owner of a drive. The driveItems returned from the sharedWithMe method always include the…
  • GETGet drive/drives/:drive-id/search(q=':q')Search the hierarchy of items for items matching a query. You can search within a folder hierarchy, a whole drive, or files shared with the current user.
  • GETList drives/me/drivesRetrieve the list of Drive resources available for a target User, Group, or Site.
  • GETGet drive/me/drives/:drive-idA collection of drives available for this user. Read-only.

Drives: root

  • GETGet root/drives/:drive-id/rootThe root folder of the drive. Read-only.
  • GETDownload root content/drives/:drive-id/root/contentThe content stream, if the item represents a file.
  • PUTUpload root content/drives/:drive-id/root/contentThe content stream, if the item represents a file.
  • DELETEUpload root content/drives/:drive-id/root/contentThe content stream, if the item represents a file.

Drives: items

  • GETList items/drives/:drive-id/itemsGet a list of driveItem objects shared with the owner of a drive. The driveItems returned from the sharedWithMe method always include the remoteItem facet…
  • POSTCreate item/drives/:drive-id/items
  • GETGet item/drives/:drive-id/items/:driveItem-idAll items contained in the drive. Read-only. Nullable.
  • DELETEDelete item/drives/:drive-id/items/:driveItem-id
  • PATCHUpdate item/drives/:drive-id/items/:driveItem-id
  • POSTCopy item/drives/:drive-id/items/:driveItem-id/copy
  • POSTFollow item/drives/:drive-id/items/:driveItem-id/followFollow a driveItem.
  • POSTInvite item/drives/:drive-id/items/:driveItem-id/inviteSend a sharing invitation for a driveItem. A sharing invitation provides permissions to the recipients and, optionally, sends them an email to notify them…
  • POSTCheckin item/drives/:drive-id/items/:driveItem-id/checkinCheck in a checked out driveItem resource, which makes the version of the document available to others.
  • GETDownload item content/drives/:drive-id/items/:driveItem-id/contentThe content stream, if the item represents a file.
  • PUTUpload item content/drives/:drive-id/items/:driveItem-id/contentThe content stream, if the item represents a file.
  • DELETEUpload item content/drives/:drive-id/items/:driveItem-id/contentThe content stream, if the item represents a file.
  • GETTrack changes to items (delta)/drives/:drive-id/items/:driveItem-id/delta()Track changes in a driveItem and its children over time. Your app begins by calling delta without any parameters. The service starts enumerating the drive's…
  • POSTPreview item/drives/:drive-id/items/:driveItem-id/preview
  • POSTRestore item/drives/:drive-id/items/:driveItem-id/restoreRestore a deleted driveItem that is currently in the recycle bin.
  • POSTCheckout item/drives/:drive-id/items/:driveItem-id/checkoutCheck out a driveItem resource to prevent others from editing the document, and prevent your changes from being visible until the documented is checked in.
  • GETGet children/drives/:drive-id/items/:driveItem-id/childrenReturn a collection of DriveItems in the children relationship of a DriveItem. DriveItems with a non-null folder or package facet can have one or more child…
  • POSTCreate children/drives/:drive-id/items/:driveItem-id/children
  • POSTUnfollow item/drives/:drive-id/items/:driveItem-id/unfollowUnfollow a driveItem.
  • GETList versions/drives/:drive-id/items/:driveItem-id/versionsThe list of previous versions of the item. For more info, see getting previous versions. Read-only. Nullable.
  • POSTCreate version/drives/:drive-id/items/:driveItem-id/versions
  • GETList analytics/drives/:drive-id/items/:driveItem-id/analyticsAnalytics about the view activities that took place on this item.
  • DELETEDelete analytics/drives/:drive-id/items/:driveItem-id/analytics
  • PATCHUpdate analytics/drives/:drive-id/items/:driveItem-id/analytics
  • POSTCreate link (item)/drives/:drive-id/items/:driveItem-id/createLinkCreate a link to share a driveItem driveItem. The createLink action creates a new sharing link if the specified link type doesn't already exist for the…
  • GETList thumbnails/drives/:drive-id/items/:driveItem-id/thumbnailsCollection of thumbnailSet objects associated with the item. For more information, see getting thumbnails. Read-only. Nullable.
  • POSTCreate thumbnail/drives/:drive-id/items/:driveItem-id/thumbnails
  • GETList permissions/drives/:drive-id/items/:driveItem-id/permissionsThe set of permissions for the item. Read-only. Nullable.
  • POSTCreate permission/drives/:drive-id/items/:driveItem-id/permissions
  • GETList subscriptions/drives/:drive-id/items/:driveItem-id/subscriptionsThe set of subscriptions on the item. Only supported on the root of a drive.
  • POSTCreate subscription/drives/:drive-id/items/:driveItem-id/subscriptions
  • GETGet retention label/drives/:drive-id/items/:driveItem-id/retentionLabelGet metadata information for a retention label applied on a driveItem. For information about retention labels from an administrator's perspective, see Use…
  • DELETEDelete retention label/drives/:drive-id/items/:driveItem-id/retentionLabelRemove the retention label from a driveItem. This operation clears the retention label and all associated retention settings enforced on the item. For…
  • PATCHUpdate retention label/drives/:drive-id/items/:driveItem-id/retentionLabelLock or unlock a retention label on a driveItem that classifies content as records. For information about retention labels from an administrator's…
  • POSTCreate discard checkout/drives/:drive-id/items/:driveItem-id/discardCheckoutDiscard the check out of a driveItem. This action releases a driveItem resource that was previously checked out. Any changes made to the item while it was…
  • POSTPermanent delete (item)/drives/:drive-id/items/:driveItem-id/permanentDelete
  • GETGet item/drives/:drive-id/items/:driveItem-id/search(q=':q')Search the hierarchy of items for items matching a query. You can search within a folder hierarchy, a whole drive, or files shared with the current user.
  • POSTValidate permission (item)/drives/:drive-id/items/:driveItem-id/validatePermission
  • POSTCreate upload session (item)/drives/:drive-id/items/:driveItem-id/createUploadSession
  • POSTAssign sensitivity label (item)/drives/:drive-id/items/:driveItem-id/assignSensitivityLabelAsynchronously assign a sensitivity label to a driveItem. This API is part of the Microsoft SharePoint and OneDrive APIs that perform advanced premium…
  • GETGet item/drives/:drive-id/items/:driveItem-id/delta(token=':token')
  • POSTCreate extract sensitivity label/drives/:drive-id/items/:driveItem-id/extractSensitivityLabels
  • GETGet activities by interval (item)/drives/:drive-id/items/:driveItem-id/getActivitiesByInterval()Get a collection of itemActivityStats resources for the activities that took place on this resource within the specified time interval. Analytics aggregates…
  • GETGet item/drives/:drive-id/items/:driveItem-id/getActivitiesByInterval(startDateTime=':startDateTime',endDateTime=':endDateTime',interval=':interval')
  • GETGet all time/drives/:drive-id/items/:driveItem-id/analytics/allTimeGet itemAnalytics about the views that took place under this resource. The itemAnalytics resource is a convenient way to get activity stats for allTime and…
  • GETList last seven days/drives/:drive-id/items/:driveItem-id/analytics/lastSevenDays
  • GETGet children/drives/:drive-id/items/:driveItem-id/children/:driveItem-id1Collection containing Item objects for the immediate children of Item. Only items representing folders have children. Read-only. Nullable.
  • GETList item activity stats/drives/:drive-id/items/:driveItem-id/analytics/itemActivityStats
  • POSTCreate item activity stat/drives/:drive-id/items/:driveItem-id/analytics/itemActivityStats
  • GETGet permission/drives/:drive-id/items/:driveItem-id/permissions/:permission-idThe set of permissions for the item. Read-only. Nullable.
  • DELETEDelete permission/drives/:drive-id/items/:driveItem-id/permissions/:permission-id
  • PATCHUpdate permission/drives/:drive-id/items/:driveItem-id/permissions/:permission-id
  • GETGet thumbnail/drives/:drive-id/items/:driveItem-id/thumbnails/:thumbnailSet-idCollection of thumbnailSet objects associated with the item. For more information, see getting thumbnails. Read-only. Nullable.
  • DELETEDelete thumbnail/drives/:drive-id/items/:driveItem-id/thumbnails/:thumbnailSet-id
  • PATCHUpdate thumbnail/drives/:drive-id/items/:driveItem-id/thumbnails/:thumbnailSet-id
  • GETGet version/drives/:drive-id/items/:driveItem-id/versions/:driveItemVersion-idThe list of previous versions of the item. For more info, see getting previous versions. Read-only. Nullable.
  • DELETEDelete version/drives/:drive-id/items/:driveItem-id/versions/:driveItemVersion-id
  • PATCHUpdate version/drives/:drive-id/items/:driveItem-id/versions/:driveItemVersion-id
  • GETGet subscription/drives/:drive-id/items/:driveItem-id/subscriptions/:subscription-idThe set of subscriptions on the item. Only supported on the root of a drive.
  • DELETEDelete subscription/drives/:drive-id/items/:driveItem-id/subscriptions/:subscription-id
  • PATCHUpdate subscription/drives/:drive-id/items/:driveItem-id/subscriptions/:subscription-id
  • GETGet vapid public key (subscription)/drives/:drive-id/items/:driveItem-id/subscriptions/getVapidPublicKey()Get the public key information required to validate push notifications according to RFC 8292 specifications.
  • GETDownload children content/drives/:drive-id/items/:driveItem-id/children/:driveItem-id1/contentThe content stream, if the item represents a file.
  • PUTUpload children content/drives/:drive-id/items/:driveItem-id/children/:driveItem-id1/contentThe content stream, if the item represents a file.
  • DELETEUpload children content/drives/:drive-id/items/:driveItem-id/children/:driveItem-id1/contentThe content stream, if the item represents a file.
  • POSTGrant permission/drives/:drive-id/items/:driveItem-id/permissions/:permission-id/grantGrant users access to a link represented by a permission.
  • GETDownload version content/drives/:drive-id/items/:driveItem-id/versions/:driveItemVersion-id/contentThe content stream for this version of the item.
  • PUTUpload version content/drives/:drive-id/items/:driveItem-id/versions/:driveItemVersion-id/contentThe content stream for this version of the item.
  • DELETEUpload version content/drives/:drive-id/items/:driveItem-id/versions/:driveItemVersion-id/contentThe content stream for this version of the item.
  • POSTRevoke grants (permission)/drives/:drive-id/items/:driveItem-id/permissions/:permission-id/revokeGrantsRevoke access to a listItem or driveItem granted via a sharing link by removing the specified driveRecipient entries from the link. Recipients who already…
  • POSTCreate reauthorize/drives/:drive-id/items/:driveItem-id/subscriptions/:subscription-id/reauthorizeReauthorize a subscription when you receive a reauthorizationRequired challenge.
  • POSTRestore version (version)/drives/:drive-id/items/:driveItem-id/versions/:driveItemVersion-id/restoreVersionRestore a previous version of a driveItem to be the current version. This operation creates a new version with the contents of the previous version, and it…
  • GETGet item activity stat/drives/:drive-id/items/:driveItem-id/analytics/itemActivityStats/:itemActivityStat-id
  • DELETEDelete item activity stat/drives/:drive-id/items/:driveItem-id/analytics/itemActivityStats/:itemActivityStat-id
  • PATCHUpdate item activity stat/drives/:drive-id/items/:driveItem-id/analytics/itemActivityStats/:itemActivityStat-id

Drives: bundles

  • GETList bundles/drives/:drive-id/bundlesCollection of bundles (albums and multi-select-shared sets of items). Only in personal OneDrive.
  • POSTCreate bundle/drives/:drive-id/bundles
  • GETGet bundle/drives/:drive-id/bundles/:driveItem-idCollection of bundles (albums and multi-select-shared sets of items). Only in personal OneDrive.
  • GETDownload bundle content/drives/:drive-id/bundles/:driveItem-id/contentThe content stream, if the item represents a file.
  • PUTUpload bundle content/drives/:drive-id/bundles/:driveItem-id/contentThe content stream, if the item represents a file.
  • DELETEUpload bundle content/drives/:drive-id/bundles/:driveItem-id/contentThe content stream, if the item represents a file.

Drives: special

  • GETGet special/drives/:drive-id/specialCollection of common folders available in OneDrive. Read-only. Nullable.
  • GETGet special/drives/:drive-id/special/:driveItem-idCollection of common folders available in OneDrive. Read-only. Nullable.
  • GETDownload special content/drives/:drive-id/special/:driveItem-id/contentThe content stream, if the item represents a file.
  • PUTUpload special content/drives/:drive-id/special/:driveItem-id/contentThe content stream, if the item represents a file.
  • DELETEUpload special content/drives/:drive-id/special/:driveItem-id/contentThe content stream, if the item represents a file.

Drives: following

  • GETGet following/drives/:drive-id/followingThe list of items the user is following. Only in OneDrive for Business.
  • GETGet following/drives/:drive-id/following/:driveItem-idThe list of items the user is following. Only in OneDrive for Business.
  • GETDownload following content/drives/:drive-id/following/:driveItem-id/contentThe content stream, if the item represents a file.
  • PUTUpload following content/drives/:drive-id/following/:driveItem-id/contentThe content stream, if the item represents a file.
  • DELETEUpload following content/drives/:drive-id/following/:driveItem-id/contentThe content stream, if the item represents a file.

Shares

  • GETList shares/sharesAccess a shared DriveItem or a collection of shared items by using a shareId or sharing URL. To use a sharing URL with this API, your app needs to transform…
  • POSTCreate share/shares
  • GETGet share/shares/:sharedDriveItem-idAccess a shared DriveItem or a collection of shared items by using a shareId or sharing URL. To use a sharing URL with this API, your app needs to transform…
  • DELETEDelete share/shares/:sharedDriveItem-id
  • PATCHUpdate share/shares/:sharedDriveItem-id

Shares: root

  • GETGet root/shares/:sharedDriveItem-id/rootUsed to access the underlying driveItem. Deprecated -- use driveItem instead.
  • GETDownload root content/shares/:sharedDriveItem-id/root/contentThe content stream, if the item represents a file.
  • PUTUpload root content/shares/:sharedDriveItem-id/root/contentThe content stream, if the item represents a file.
  • DELETEUpload root content/shares/:sharedDriveItem-id/root/contentThe content stream, if the item represents a file.

Shares: items

  • GETList items/shares/:sharedDriveItem-id/itemsAll driveItems contained in the sharing root. This collection cannot be enumerated.
  • GETGet item/shares/:sharedDriveItem-id/items/:driveItem-idAll driveItems contained in the sharing root. This collection cannot be enumerated.
  • GETDownload item content/shares/:sharedDriveItem-id/items/:driveItem-id/contentThe content stream, if the item represents a file.
  • PUTUpload item content/shares/:sharedDriveItem-id/items/:driveItem-id/contentThe content stream, if the item represents a file.
  • DELETEUpload item content/shares/:sharedDriveItem-id/items/:driveItem-id/contentThe content stream, if the item represents a file.

Shares: drive item

  • GETGet drive item/shares/:sharedDriveItem-id/driveItemAccess a shared DriveItem or a collection of shared items by using a shareId or sharing URL. To use a sharing URL with this API, your app needs to transform…
  • GETDownload drive item content/shares/:sharedDriveItem-id/driveItem/contentThe content stream, if the item represents a file.
  • PUTUpload drive item content/shares/:sharedDriveItem-id/driveItem/contentThe content stream, if the item represents a file.
  • DELETEUpload drive item content/shares/:sharedDriveItem-id/driveItem/contentThe content stream, if the item represents a file.

Shares: permission

  • GETGet permission/shares/:sharedDriveItem-id/permissionUsed to access the permission representing the underlying sharing link
  • DELETEDelete permission/shares/:sharedDriveItem-id/permission
  • PATCHUpdate permission/shares/:sharedDriveItem-id/permission
  • POSTGrant permission/shares/:sharedDriveItem-id/permission/grantGrant users access to a link represented by a permission.
  • POSTRevoke grants (permission)/shares/:sharedDriveItem-id/permission/revokeGrantsRevoke access to a listItem or driveItem granted via a sharing link by removing the specified driveRecipient entries from the link. Recipients who already…

API details

Base URL
https://graph.microsoft.com/v1.0
Authentication
OAuth 2.0 (authorization code, client credentials flows)
Operations
129 operations on 77 pathsGET 56POST 31DELETE 21PATCH 11PUT 10
2 marked deprecated
Main resources
Drives: items 75Drives 10Drives: bundles 6Drives: following 5Drives: special 5Shares 5Shares: items 5Shares: permission 5Drives: root 4Shares: drive item 4
Description format
OpenAPI 3.0.4, API version v1.0

How to test the Microsoft Graph: OneDrive and SharePoint files in Swastik Codes

  1. Open the APISelect “Fork & run in Swastik Codes” on this page. Sign in or create a free account if asked.
  2. Fork it into your workspaceChoose a workspace. You get your own copy of the Microsoft Graph: OneDrive and SharePoint files collection, without the publisher's secrets.
  3. Add your credentialsThis API uses OAuth 2.0 (authorization code, client credentials flows). Add yours in the collection's variables or an environment; the requests already reference it.
  4. Send a requestPick an endpoint, for example “Get drive” (GET /me/drive), and press Send. Check the response, add tests and run the whole collection with the runner.

Frequently asked questions

What is the Microsoft Graph: OneDrive and SharePoint files?

Browse drives and folders, upload, download, copy, move and delete files, create sharing links, set permissions, track changes with delta and read thumbnails… It is listed under Productivity & workspace and has 129 endpoints.

Who publishes the Microsoft Graph: OneDrive and SharePoint files?

It is listed from Microsoft's public API description (an OpenAPI document), not published by Microsoft on Swastik Codes. Anyone who controls microsoft.com can claim the profile by adding a DNS TXT record.

What is the base URL of the Microsoft Graph: OneDrive and SharePoint files?

Requests go to https://graph.microsoft.com/v1.0. Endpoint paths are added to this base URL.

How do I authenticate with the Microsoft Graph: OneDrive and SharePoint files?

With OAuth 2.0 (authorization code, client credentials flows).

How many endpoints does the Microsoft Graph: OneDrive and SharePoint files have?

129 operations on 77 paths (56 GET, 31 POST, 21 DELETE, 11 PATCH, 10 PUT). The largest groups are Drives: items, Drives, Drives: bundles, Drives: following.

Is forking the Microsoft Graph: OneDrive and SharePoint files free?

Yes. Forking copies the collection into your workspace for free. It has been starred 0 times and forked 0 times.

Suggest an API

Tell us which public API is missing. We check it, then add it here with its endpoints when it has an OpenAPI (Swagger) description.