Microsoft 365

Microsoft Graph API: From Users to SharePoint and Teams

Explore practical Microsoft Graph API scenarios for users, SharePoint, OneDrive, Outlook and Teams, with examples and permission guidance.

Ramesh Girniganti
Published
Reading time
6 min read

Quick answer

Microsoft Graph provides a common API for supported Microsoft 365 resources. Authenticate with Microsoft Entra ID, choose the permissions required for each operation and call the relevant endpoint.

A developer laptop connecting modular web components and an integration hub.

Before you start

Is this guide for you?

Best entry point
Microsoft 365
Time investment
6 min read
Prerequisite knowledge
Basic knowledge of REST APIs, JSON and Microsoft Entra ID authentication.

What you’ll learn

  • Graph connects applications to supported Microsoft 365 resources through a common API.
  • Delegated access acts for a signed-in user; application permissions support approved app-only scenarios.
  • Each endpoint has its own permission and capability requirements.
  • Handle paging, throttling and failures before using an integration at scale.

Before you start

Prerequisite knowledge
Basic knowledge of REST APIs, JSON and Microsoft Entra ID authentication.

Microsoft Graph brings many Microsoft 365 services together behind a common API. An application can use supported endpoints to work with users, SharePoint content, OneDrive files, Outlook mail and calendars, Teams and more.

This guide expands Ramesh Girniganti's overview of common Graph scenarios with example requests, authentication choices and practical checks. The examples show the v1.0 API and use placeholder IDs; confirm each operation's permissions and supported account types in its Microsoft documentation before implementing it.

How a Graph request works

  1. Register or configure an application in Microsoft Entra ID and choose whether it will act for a signed-in user or as an application.
  2. Request the least privileged Graph permissions for the operations you need and obtain the appropriate consent.
  3. Acquire a token for Microsoft Graph using a supported authentication library.
  4. Send an HTTPS request to the appropriate Graph endpoint with the token in the Authorization header.
  5. Handle the response, errors, paging and throttling according to the operation.

For example, an interactive application with a signed-in user can request that user's profile using GET https://graph.microsoft.com/v1.0/me. The token must represent a user; /me is not available in an app-only context. Graph Explorer is useful for testing supported requests with an appropriate test account and consent.

1. Users and organizational relationships

  • GET /me retrieves the signed-in user's profile in a delegated scenario.
  • GET /users lists users that the app is permitted to read. Use supported query options to request only the properties needed.
  • GET /users/{user-id}/manager retrieves a user's manager when the relationship exists and the request is authorized.
  • GET /users/{user-id}/memberOf retrieves direct memberships. Check the API documentation when you need transitive membership or additional object details.

A user directory or approval-routing app can use these operations, but a manager may not be configured. Provide a fallback instead of assuming every user has one. See Get user and list direct memberships for supported permissions and behavior.

2. Microsoft 365 groups

Graph can read supported groups and their members or owners, and manage groups when the operation and permissions allow it. For example, GET /groups/{group-id}/members lists direct members. Use the group ID returned by Graph rather than assuming a display name is unique.

Group management can affect access to collaboration resources. Confirm the group type, ownership, approval process and least privileged operation before creating or changing membership. See the members API.

3. SharePoint sites and lists

Graph represents a SharePoint site as a site, with lists and list items below it. One common pattern is to find the site, identify the list and then read its items:

GET /sites/{site-id}/lists
GET /sites/{site-id}/lists/{list-id}/items?expand=fields

The first request returns lists in the selected site. The second returns list items and their fields. Use the actual IDs from your environment and inspect the list's column names and types before creating or updating items. The relevant operations are documented in list lists and list items.

To write a record, use the documented create or update operation with the required permission and a valid fields payload. Test against a non-production list, and check the result before retrying an uncertain write.

4. SharePoint and OneDrive files

Graph exposes document libraries and OneDrive storage through drives and drive items. A site can have more than one document library, so identify the intended drive before browsing files.

GET /sites/{site-id}/drives
GET /drives/{drive-id}/root/children
GET /drives/{drive-id}/items/{item-id}/content

The first call discovers drives; the second lists the root folder's children. The /content operation retrieves file content, rather than just its metadata, and may return a redirect to a short-lived download URL. See Microsoft's download content documentation. For uploads, select the documented upload method appropriate to the file and scenario.

5. Outlook mail and calendars

  • GET /me/messages retrieves messages available to the signed-in user, subject to the granted permissions.
  • POST /me/sendMail submits a message from the signed-in user's mailbox with an appropriate message payload and permission.
  • GET /me/events lists events; creating an event is a separate write operation with its own requirements.

Use $select and other supported query options to avoid retrieving unnecessary data. Restrict access to mail and calendar information to the intended purpose. A successful sendMail response means the request was accepted for processing; it does not guarantee delivery. See sendMail and list messages.

For scheduling, Graph offers APIs for availability and meeting suggestions. Confirm the supported permission type, time zone and actual availability response before presenting a time as free; availability can change before a meeting is booked.

6. Microsoft Teams

Teams APIs support scenarios such as listing a user's joined teams, reading channels and managing supported team resources:

GET /me/joinedTeams
GET /teams/{team-id}/channels

Each operation has its own permissions and supported access modes. Graph also supports Teams messages, but don't assume every message operation works with an app-only token. For the send chatMessage API, application permissions are supported for migration only. Choose an appropriate supported approach for ordinary automated notifications.

7. Planner and Microsoft 365 reports

Planner APIs can work with supported plans, buckets and tasks. Reports APIs can provide selected Microsoft 365 usage data for an authorized reporting solution. Review each endpoint's access mode, supported scenarios, permissions and data freshness; a dashboard should explain what its numbers actually measure.

Start with the Planner API overview and the reports API overview.

Delegated or application permissions?

Delegated permissions are used when an application acts on behalf of a signed-in user. What the app can do depends on both its granted permissions and the user's access. Application permissions are used when an application acts without a signed-in user, where the particular API supports them; they generally require administrator consent.

Choose the least privileged permission for each operation, review consent and protect credentials. Some resources offer more targeted permission models, so check the operation rather than granting broad tenant-wide access by default. Microsoft's permissions overview explains the two access types.

Build a reliable integration

  • Use pagination: Follow the complete @odata.nextLink returned by Graph until no next page remains. Do not assume the first page contains every result.
  • Handle throttling: For HTTP 429 responses, respect Retry-After when provided; use an appropriate backoff strategy otherwise. See Graph throttling guidance.
  • Minimize data: Request only needed fields with supported query options, and avoid exposing tokens, message bodies or personal data in logs.
  • Handle failures: Distinguish authentication, authorization, missing resources and transient service errors. Check the actual outcome before retrying a write.
  • Track changes carefully: Where supported, use delta queries or change notifications instead of repeatedly scanning entire collections. Review subscription and renewal requirements.
  • Prefer stable APIs: Use v1.0 for production where the required feature is available, and review beta limitations before relying on preview capabilities.

Example: a project workspace dashboard

  1. A user signs in and the app requests only the delegated permissions needed for the approved scenarios.
  2. The app reads the user's profile, then displays the specific SharePoint list and document library the user is authorized to access.
  3. It shows a link to the relevant Teams workspace and, where the required access is granted, retrieves supported team or channel information.
  4. The app handles missing access, follows pages and reports useful errors rather than silently showing incomplete results.
  5. Before rollout, the team tests with users who have different permissions and checks that no private data is exposed in the dashboard or logs.

Start with one read-only scenario in a test tenant. Once its permissions and results are understood, add write operations deliberately and test their failure and recovery paths. Microsoft's Graph best practices provide a useful production checklist.

Share this

Tagged

Microsoft Graph · Integrations · Security

Frequently asked questions

What is Microsoft Graph?

Microsoft Graph is an API for accessing supported data and capabilities across Microsoft 365 and other Microsoft cloud services.

Can I use /me with an app-only token?

No. The /me endpoint requires a signed-in user and delegated access. App-only scenarios address a supported resource explicitly.

Does one Graph permission grant access to all Microsoft 365 data?

No. Permissions depend on the operation and resource. Request the least privileged permissions documented for each API and obtain the required consent.

Can an app use application permissions to send ordinary Teams channel messages?

The Graph chatMessage send API supports application permissions for migration only. Review the API documentation and use an appropriate supported approach for other scenarios.

Have a Microsoft 365 topic idea?

Share article suggestions, community session ideas, corrections, or real-world scenarios for future nextM365 learning notes.

Discuss your project requirements

Keep learning Microsoft 365

Explore more practical guides for SharePoint, Power Platform, Copilot Studio, migration, automation, governance, and security.

Continue learning

Next action

What to do next

Browse all tutorials →