Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

Use Microsoft Graph’s DriveItem thumbnails collection to retrieve a static document thumbnail. If you need an interactive viewer instead, call the DriveItem preview action; it returns a temporary, caller-scoped embed URL.

Choose the output you actually need

“Thumbnail” and “preview” are different SharePoint Online operations. Select the one that matches your interface before writing code.

Need Graph operation What you receive Important limitation
Small image in a card, grid or file list GET /drives/{drive-id}/items/{item-id}/thumbnails A ThumbnailSet collection with available image sizes and URLs A file can have zero or more thumbnail sets, and available sizes vary.
Open or embed a live document viewer POST /drives/{driveId}/items/{itemId}/preview Temporary GET or POST embed details The URL is short-lived and runs with the caller’s permissions.
Convert a supported source file before another workflow GET /drive/items/{item-id}/content?format=pdf PDF content Only documented source extensions are supported; conversion is not thumbnail retrieval.

Microsoft describes these as service-generated representations. Your application requests the representation; it does not need to install a local thumbnail generator.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Prepare the SharePoint and Graph request

Identify the drive and item

A SharePoint document library is exposed through Microsoft Graph as a drive. Obtain the target drive-id and the file’s item-id from your existing SharePoint or Graph listing flow. You can also address an item through a site drive, for example /sites/{site-id}/drive/items/{item-id}/thumbnails. Equivalent routes exist for group, user and current-user drives.

Acquire an access token

Send a bearer token for the identity that is allowed to read the file. For work or school delegated access, Microsoft lists Files.Read as the least-privileged permission for thumbnails. For application access, the least-privileged permission listed is Files.Read.All. SharePoint Embedded containers add their own requirements, including FileStorageContainer.Selected and the relevant container-type permissions.

Keep the authorization boundary narrow

Request only the permission level your application needs. A token that can read an entire tenant can expose far more files than a thumbnail component requires. Store tokens on a server or other protected component rather than in page source.

Retrieve a static document thumbnail

1. Call the thumbnails collection

The v1.0 collection endpoint is:

GET https://graph.microsoft.com/v1.0/drives/{drive-id}/items/{item-id}/thumbnails
Authorization: Bearer {token}

The response contains a value array. Each entry is a thumbnail set; a set can expose small, medium and large image objects. Those objects include dimensions and a URL. Do not assume that every file returns a set or that every set contains all three sizes.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

2. Select an available size and URL

Read the size you actually need and use the URL returned by Graph. A typical selection algorithm is to try the requested size, then fall back to another size that exists, and finally show a file-type icon when no set is returned.

3. Retrieve image bytes when you need a response body

For a selected set and size, Graph documents a content route in this form:

GET https://graph.microsoft.com/v1.0/drives/{drive-id}/items/{item-id}/thumbnails/{thumb-id}/{size}/content
Authorization: Bearer {token}

The content request redirects to the thumbnail URL. Your HTTP client must follow redirects, or you must use the URL supplied in the thumbnail object directly.

4. Request a custom bounding box

When standard sizes do not fit your card, the API reference documents custom names such as c300x400 (fit inside a 300-by-400 box while preserving aspect ratio) and c300x400_crop (fill the box and crop). The returned image may not equal the requested pixel dimensions exactly, so size the UI from the response or use CSS that tolerates small differences.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

5. Expand thumbnails while listing files

For a library grid, Microsoft documents requesting thumbnails alongside DriveItems with $expand=thumbnails. This can avoid one thumbnail call per row. Follow the supported listing syntax in the API reference; some nested expand forms are not accepted for SharePoint and OneDrive routes.

Working examples in cURL, Python and Node.js

cURL: read thumbnail metadata

curl --fail-with-body 
  -H "Authorization: Bearer $GRAPH_TOKEN" 
  "https://graph.microsoft.com/v1.0/drives/$DRIVE_ID/items/$ITEM_ID/thumbnails"

Parse the JSON response, choose an existing size such as medium, and use its returned URL. Keep the token out of browser-visible links and logs.

Python: choose a size and download it

import os
import requests

TOKEN = os.environ["GRAPH_TOKEN"]
DRIVE_ID = os.environ["DRIVE_ID"]
ITEM_ID = os.environ["ITEM_ID"]

headers = {"Authorization": f"Bearer {TOKEN}"}
endpoint = f"https://graph.microsoft.com/v1.0/drives/{DRIVE_ID}/items/{ITEM_ID}/thumbnails"
r = requests.get(endpoint, headers=headers, timeout=30)
r.raise_for_status()
sets = r.json().get("value", [])

if not sets:
    raise RuntimeError("This item has no thumbnail set")

thumb_set = sets[0]
thumb = thumb_set.get("medium") or thumb_set.get("small") or thumb_set.get("large")
if not thumb or not thumb.get("url"):
    raise RuntimeError("No usable thumbnail size was returned")

image = requests.get(thumb["url"], timeout=30)
image.raise_for_status()
with open("document-thumb.jpg", "wb") as f:
    f.write(image.content)

Node.js: request metadata

const token = process.env.GRAPH_TOKEN;
const driveId = process.env.DRIVE_ID;
const itemId = process.env.ITEM_ID;

const endpoint = `https://graph.microsoft.com/v1.0/drives/${driveId}/items/${itemId}/thumbnails`;
const res = await fetch(endpoint, {
  headers: { Authorization: `Bearer ${token}` }
});
if (!res.ok) {
  throw new Error(`Graph returned ${res.status}: ${await res.text()}`);
}

const body = await res.json();
const set = body.value?.[0];
const thumb = set?.medium ?? set?.small ?? set?.large;
if (!thumb?.url) throw new Error("No thumbnail was returned");
console.log({ url: thumb.url, width: thumb.width, height: thumb.height });

Use an interactive preview instead of an image

Call the preview action

Send a POST request to:

POST https://graph.microsoft.com/v1.0/drives/{driveId}/items/{itemId}/preview
Authorization: Bearer {token}
Content-Type: application/json

{}

The request body can include page and zoom when the relevant preview application supports those options. The response may contain getUrl, postUrl and postParameters. Which fields appear depends on the item, preview support and requested options.

Render the returned form or URL

For a GET response, place the returned URL in an iframe or open it in a new page. For a POST response, submit a form to postUrl with the returned form-encoded postParameters. Treat this as a session-like handoff, not as a permanent share link.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Protect the caller’s permissions

Microsoft warns that preview URLs are temporary, intended for the caller’s own use and evaluated with the calling identity’s permissions. Do not put one in a public cache or send it to an unrelated visitor. If a backend has broader write access than the person viewing the page, consider a read-only application identity for preview generation and restrict access to the surrounding page.

Permissions and account boundaries

Scenario Least-privileged permission stated by Microsoft Boundary
Work or school delegated thumbnail access Files.Read The signed-in user must be able to read the item.
Work or school application thumbnail access Files.Read.All The app acts without a user and must protect its credential.
Work or school delegated preview access Files.Read Preview runs in the caller’s authorization context.
Application preview access Files.Read.All Use a deliberately restricted identity when embedding for other users.
SharePoint Embedded FileStorageContainer.Selected plus container-type permissions Container permissions are separate from ordinary SharePoint drive access.

The preview reference does not support delegated personal Microsoft accounts. The thumbnail and preview guidance here targets SharePoint Online and OneDrive for Business work or school scenarios.

Format support and safe fallbacks

Microsoft 365 previews many common document, image, video and PDF formats, but support varies with service capability, tenant policy and client experience. Microsoft’s guidance is to handle preview failures gracefully; there is no universal guarantee for every extension or tenant.

  • Show a file-type icon when the thumbnail collection is empty.
  • Offer a link that opens the document in SharePoint when preview creation fails.
  • Log the Graph status code and item identifier, but never log bearer tokens or temporary preview URLs.
  • Test the exact formats and policies used by your tenant instead of publishing an assumed support list.

If you need a PDF for a separate pipeline, use the documented conversion endpoint only for source extensions it supports. A PDF conversion response is not evidence that a thumbnail exists for the original item.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Troubleshooting common failures

401 Unauthorized

The token is missing, expired or issued for the wrong audience. Acquire a Microsoft Graph token and send it as Authorization: Bearer ...; do not pass it as a URL parameter.

403 Forbidden

The identity lacks the required Graph permission or the user cannot read the library item. Confirm consent, tenant policy, drive selection and (for SharePoint Embedded) container permissions.

200 response with an empty value array

A DriveItem can legitimately have no thumbnail set. Use a file icon or an open-document link rather than retrying indefinitely.

A size such as large is missing

Size availability is not uniform. Select the best available object and use a custom size only when your client can accept the documented aspect-ratio behavior.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Image download fails after metadata succeeded

Follow redirects and use the URL promptly. Thumbnail URLs can change when the item changes and should not be treated as permanent identifiers.

Preview opens for the wrong person or stops working

The URL is caller-scoped and temporary. Generate it for the viewing identity, avoid sharing it across users, and create a fresh preview when it expires.

Preview fails for a particular extension

Check the current Microsoft file-support matrix for your tenant and handle the failure with an icon or SharePoint link. Do not assume that a format supported in one client is supported in every preview experience.

Site and item IDs point to different storage

Verify that the item belongs to the drive you call. A valid token and valid-looking IDs still produce errors when the drive, site and item do not match.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Performance, caching and cost considerations

Reduce round trips in grids

Use $expand=thumbnails in a supported DriveItem listing when you need thumbnails for many rows. For individual items, request only the collection and selected size rather than downloading multiple variants.

Cache metadata carefully

You may cache your own card data, but refresh thumbnail URLs when an item changes. Because URLs can be replaced after an update, store the item identity and selected size as your durable key, not the URL itself.

Expect partial availability

Design the UI so a missing image does not block the file list. A thumbnail is an enhancement; the document name, type and open action should still work when generation or preview is unavailable.

Understand the operation cost

Microsoft Graph permissions and your tenant’s service limits govern these calls. The material available here does not establish a universal per-thumbnail price or a guaranteed response time, so measure latency and apply your normal retry and backoff policy without retrying permanent authorization errors.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Or skip the browser setup

If what you need is a clean screenshot of a reachable web page or rendered document URL rather than SharePoint’s native thumbnail metadata, ScreenshotNeo provides a website screenshot API and MCP server. It accepts a URL and returns PNG, JPEG, WebP or PDF output. It is separate from Microsoft Graph, so use Graph when you need SharePoint’s item-aware thumbnail and permission model.

One request is enough:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the parameter reference and options in the ScreenshotNeo documentation. Before capture, it can accept the cookie or consent banner and remove more than 60 known consent platforms, newsletter popups and chat widgets; each cleanup step can be disabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed as clean shots, and the response identifies the result with X-Page-Verdict and X-Billed headers. An MCP server exposes take_screenshot, get_page_info and capture_pdf to Claude, Cursor and other MCP clients.

The service includes 1,000 screenshots per month free with no card. Paid plans start at $5 for 3,000 shots; every feature is on every plan. Create a free ScreenshotNeo account to try it.

FAQ

Does Graph generate a thumbnail on my application server?

No. Graph returns a service-generated representation or a URL to it; your application decides whether to display, proxy or cache the image.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Are SharePoint Server 2016 thumbnails covered by this method?

No. Microsoft’s thumbnail reference explicitly says thumbnails are not supported on SharePoint Server 2016. This article addresses SharePoint Online and does not generalize that statement to every other Server release.

Can I make an interactive preview URL a permanent public link?

No. The preview response is temporary and caller-scoped. Use SharePoint’s normal sharing mechanisms when you need a durable, independently permissioned link.

Frequently Asked Questions

Does Graph generate a thumbnail on my application server?

No. Graph returns a service-generated representation or a URL to it; your application decides whether to display, proxy or cache the image.

Are SharePoint Server 2016 thumbnails covered by this method?

No. Microsoft’s thumbnail reference explicitly says thumbnails are not supported on SharePoint Server 2016.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Can I make an interactive preview URL a permanent public link?

No. Preview URLs are temporary and caller-scoped; use SharePoint’s normal sharing mechanisms for durable links.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.