Overview

The OneDrive API (part of Microsoft Graph) lets you read, upload, and manage files in a user's OneDrive storage using OAuth 2.0. It supports resumable uploads for large files, real-time webhooks for file change notifications, and sharing link creation for both personal and business accounts. It is particularly useful for apps targeting Microsoft 365 enterprise users who already have OneDrive through their organization.

Beginner Tip

Register your app in the Azure Active Directory portal (portal.azure.com) to get a client ID and secret. Use the Microsoft identity platform OAuth flow to get an access token with Files.ReadWrite scope before making any Drive API calls.

Available Data

Use case: Integrate file sharing and storage data into web and mobile applications
OneDrive data via REST API

Example Response

JSON Response
{
  "file_id": "f_abc123",
  "filename": "document.pdf",
  "size_bytes": 1048576,
  "mime_type": "application/pdf",
  "download_url": "https://example.com/files/f_abc123",
  "created_at": "2025-01-15T10:00:00Z"
}

Field Reference

id Unique item identifier within OneDrive, used for all file operations like download and delete
name File or folder name as displayed in OneDrive
size Total size of the item in bytes; for folders this reflects the combined size of all contents
lastModifiedDateTime ISO 8601 timestamp of the last time the item was modified
webUrl URL to open and view this item in OneDrive in a browser
file.mimeType MIME type of the file, present only on file items and not on folder items

Implementation Example

Request
const url = "https://developer.microsoft.com/onedrive";
// Replace headers or query params with the values required by this API.
const response = await fetch(url, {
  headers: {
  "Authorization": "Bearer YOUR_API_KEY"
  }
});
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = await response.json();
console.log(data);

What Can You Build?

Note: These code examples are AI-generated and unverified. Always refer to the official API documentation for accurate usage.

Common Errors & Troubleshooting

401 InvalidAuthenticationToken The Bearer token has expired or does not have the correct scopes
Refresh the access token using your refresh token and ensure the Files.ReadWrite or Files.Read scope was granted during consent
403 accessDenied The user has not granted the application permission to access their files
Ensure the OAuth consent screen was completed by the user and that admin consent is not required for your tenant
409 nameAlreadyExists A file with the same name already exists in the target folder
Use the @microsoft.graph.conflictBehavior=replace query parameter in your upload URL to overwrite, or rename your file

Metadata Score Breakdown

Estimated from metadata — endpoint not independently tested

This score is estimated from observable metadata — HTTPS support, authentication model, declared CORS, and documentation reachability — because the API requires authentication or exposes no publicly testable endpoint. The five-signal breakdown is only shown for live-tested APIs.

Metadata estimate · endpoint not independently tested

Technical Specifications

Auth OAuth
HTTPS REQUIRED
CORS UNKNOWN
Difficulty Advanced
Verified: 2026-04-07

Similar APIs

View All →