Skip to main content

Design Microsoft 365 Automation That Survives Microsoft Graph Throttling: Retry-After, Batching and Safe Writes

Read Retry-After on every Graph 429, retry only throttled batch items, use delta query and keep writes safe to repeat.

Laptop displaying data analytics graph in a modern office setting, symbolizing growth and technology.

Underlined words are defined in the KBY Lexicon. Tap or click one to see what it means.

When Microsoft Graph throttles an automation job, it returns 429 Too Many Requests with a Retry-After header. The fastest way to recover is to wait that many seconds and retry the same request. Retrying immediately makes things worse, because every request, including a refused one, counts against the app’s usage limits. Inside a batch the rule is the same but the plumbing differs: the batch returns 200, and each throttled item carries its own 429 and its own delay.

A job that survives throttling does four things. It reads the delay from the response, retries only the requests that were refused, keeps every write safe to repeat, and uses delta query instead of rescanning data it already holds. The limits quoted below were current in Microsoft’s documentation on 28 November 2026, and Microsoft states that they are subject to change.

#Why it matters: one tenant, many scripts, one budget

Throttling limits the number of concurrent calls to a service to prevent overuse of resources. When a threshold is exceeded, Microsoft Graph limits further requests from that client app for some time, returns 429, and suggests a wait in the response header. Thresholds depend on the type and number of requests, so writes can be throttled while reads still succeed.

Microsoft names two common causes: a large number of requests across all applications in a tenant, and a large number from one application across all tenants. The first matters most for in-house automation. A job that works in a quiet test tenant can therefore fail in production without any change to its code.

Large extractions are a different problem: Microsoft says to use Microsoft Graph Data Connect rather than the for them, because it is not subject to the same throttling limits. If any of your mailbox automation still depends on Exchange Web Services, check the Exchange Web Services retirement deadline; a replacement built on Graph runs under these rules.

#How it works: the limits behind a 429

Graph applies two categories of limit at the same time: global limits for all services, and service-specific limits for individual services. A request can be evaluated against several limits, by scope and request type, and the first one reached triggers throttling. The global limit is 130,000 requests per 10 seconds per app across all tenants; the service limits are the ones a job usually meets.

Users, groups, devices, service principals, licence details and other directory resources share the identity and access limits. These use a token bucket: each request has a cost in resource units, the costs are summed, and the sum is compared with the limits. The table shows the limits for one app in one tenant, and for the app and the tenant as a whole.

Identity and access throttling limits, as documented on 28 November 2026
Limit typeResource unit quotaWrite quota
Application and tenant pair3,500 (tenants under 50 users), 5,000 (50 to 500 users) or 8,000 (above 500 users) per 10 seconds3,000 requests per 2 minutes 30 seconds
Application150,000 per 20 seconds35,000 requests per 5 minutes
TenantNot applicable18,000 requests per 5 minutes

Any request not listed in Microsoft’s cost table costs 1 unit. Listing the members of a group costs 3 and the transitive members of a group costs 5. Using $select reduces the cost by 1, $expand adds 1, and $top with a value below 20 reduces it by 1, though no request costs less than 1. Fewer properties and fewer expansions therefore buy real headroom.

Outlook resources follow different rules. The limits apply to each app and mailbox pair: 10,000 requests in a 10-minute period, four concurrent requests, and 150 MB of uploads in a 5-minute period. Exceeding them for one mailbox does not affect the app’s access to another. Microsoft also notes that a 429 can arrive before any listed limit is reached when the service is under heavy load or because of the data volume in a tenant.

Graph tells you how close you are. When an app has used more than 80 percent of its identity limit, responses carry x-ms-throttle-limit-percentage: 0.8 means 80 percent, 1.0 means throttling starts, and 1.2 means 20 percent of incoming requests are being throttled. A throttled response adds x-ms-throttle-scope, which names the scope (Tenant_Application, Tenant or Application) and whether reads, writes or both are limited. x-ms-throttle-information gives a reason such as WriteLimitExceeded.

Not every resource sends a delay. Microsoft lists identity protection and conditional access resources (limited to one request per second per tenant), data policy operations and OneNote among those that do not return Retry-After on a 429. For those, the documented fallback is an exponential backoff policy.

#Step by step: a retry loop that obeys Retry-After

  1. Generate a new GUID for every request, send it in the client-request-id header and write it to your log. It lets Microsoft investigate an error if you need to report one.
  2. Treat 429 as the throttling signal. Read Retry-After, wait that many seconds, then send the same request again.
  3. If it fails with 429 again, you are still throttled. Keep honouring the delay in each new response until the request succeeds.
  4. If there is no Retry-After, use exponential backoff. Do the same for 503, and make the retry on a new HTTP connection.
  5. Never retry immediately. Retrying while throttled only adds to the usage that is being counted against you.

Following along? Tap a step’s number to tick it off.

The Microsoft Graph SDKs already include handlers that use Retry-After or fall back to exponential backoff, so prefer the SDK for plain calls over writing your own loop. Those handlers do not cover requests that were throttled inside a JSON batch.

Loading diagram...

This loop has no ceiling, and neither does Microsoft’s guidance. Add one yourself: after a set number of attempts or a total wait that exceeds your job window, stop retrying, record the item as parked and move on, as the recovery section describes.

Close-up of a tablet displaying stock market analysis with colorful graphs.
Photo by Burak The Weekender on Pexels

#
Batching without losing the throttled requests

A JSON batch carries up to 20 requests in one POST https://graph.microsoft.com/v1.0/$batch. Each item needs a unique id, or the whole batch fails with 400. Responses can arrive in a different order, so match them to requests by id. A 200 on the batch means only that the batch was parseable. Every item in responses has its own status, and any of them can be 403, 404 or 429.

Items in a batch are evaluated against throttling limits individually. A throttled item fails with its own 429 and a retry-after value in that item’s headers, and several can be throttled in one batch. Retry only those items, using each item’s own delay, or collect them into a new batch and send it after the longest delay. Resending the whole batch repeats work that already succeeded, which for writes is the wrong answer.

With dependsOn, a request runs only after the request it names. If that request fails, its dependants fail with 424 Failed Dependency. A throttled request counts as failed, so retry it and its dependants together, in order. Microsoft’s advice is that a batch should be either fully sequential or fully parallel. For Outlook, Graph sends at most four items from an unordered batch at a time, and one at a time when dependsOn orders them.

#
Delta query instead of rescans

Polling a resource and rescanning collections to spot changes is the pattern most likely to be throttled. Delta query returns only what changed. Call GET https://graph.microsoft.com/v1.0/users/delta, follow @odata.nextLink until the response carries an @odata.deltaLink, store that link, and call it on the next run. Treat the tokens as opaque and reuse the URL exactly as returned, because it already encodes the query parameters of the first request.

For users and groups, $expand, $top and $orderby are not supported on delta requests. If you only want future changes, add $deltatoken=latest to skip the initial full read. Microsoft recommends using change notifications as the trigger for delta calls, with a backstop poll in case no notification arrives.

#
Writes that are safe to repeat

Microsoft’s guidance does not say whether a write that timed out or returned 503 was applied, so design each write so that sending it twice is harmless. Describe the desired end state rather than an increment, read the current value first, skip the call when it already matches, and log the value you read so a rollback is possible. KBY’s walkthrough of setting a group naming policy through Graph PowerShell shows why a change should start from the existing settings.

For PUT and PATCH where you do not need the response body, Microsoft documents the Prefer: return=minimal header. Do not use it on creation, because you need the new object’s id back.

#Verifying that throttled requests are retried correctly

Test the retry behaviour in a non-production tenant, with read-only calls, before the job gets write permissions. Throttling is hard to trigger on demand, so verify the parts you can see.

  • Check the log of any real 429: the next attempt for that client-request-id should start no earlier than the Retry-After seconds after the refusal.
  • Count batch ids. Every id sent must end with a final status. An id with no final status was lost in a retry.
  • Watch for x-ms-throttle-limit-percentage on successful responses. Microsoft returns it only above 0.8, so seeing it at all means the job is close to the limit before it has failed.
  • Run the delta baseline once and confirm the second run returns only changes.

Two read-only requests cover the last two checks: GET https://graph.microsoft.com/v1.0/users/delta?$deltatoken=latest should return an @odata.deltaLink and no user data, and a $batch of two GET items should return 200 with a responses array holding one entry per id.

Tablet with business task management app in front of stock chart monitors.
Photo by Jakub Zerdzicki on Pexels

#What goes wrong when the retry loop fights the limit

  • Tight loops. A retry without waiting is still counted, so the job stays throttled longer than it needed to.
  • Treating a batch 200 as success. Throttled items fail silently and the data is never changed.
  • Assuming the SDK retried batch items. It does not for throttled requests inside a batch, so your code must.
  • Expecting Retry-After everywhere. Conditional access and named location calls allow one request per second per tenant and send no delay, so pace them yourself.
  • Parallel workers on one mailbox. More than four concurrent requests for the same app and mailbox is itself a throttling condition.
  • One app registration shared by every job. The limits are per app per tenant, so a heavy report can throttle a small, urgent job running under the same app.

#Permissions and least privilege for a background job

Grant the app only the lowest-privileged permission it needs, and use application permissions only when no signed-in user is present. Microsoft warns that application permissions used for interactive scenarios can put an app at compliance and security risk by bypassing policies an administrator has set.

Do not register extra apps to get more headroom. The tenant write limit of 18,000 requests per 5 minutes covers all apps together, so extra registrations add credentials to guard without lifting it. A better lever for a background job is the x-ms-throttle-priority header on identity and access calls. Low-priority requests are throttled first and their throttling does not cause user-visible failures, while high priority should be kept for requests a user initiated. The header does not change the limits.

Microsoft asks for the full request and response to be logged for support cases. Redact the Authorization header and any personal data in bodies before the log leaves the job’s host, because a bearer token in a log file is a credential.

#Recovery when a run stops halfway

Assume the job will be interrupted, and make the next run resume cleanly.

  1. Keep a work list with one row per target object: its id, its last known status and the last client-request-id. A rerun processes only rows that are not done.
  2. Before any write, store the value you read. To undo a run, write the stored values back for the rows marked changed, using the same retry loop.
  3. Park an item that exceeds your retry ceiling and report it, rather than blocking the rest of the run.
  4. Store the latest @odata.deltaLink only after the changes it covers have been processed, so an interruption repeats work instead of skipping it.

If a run deleted users or groups by mistake, Microsoft notes that some deleted resources, including users, groups and applications, can be restored within 30 days of deletion. That is a last resort, not a plan, so the job should not delete without a recorded precondition.

#Readiness checks before the job goes on a schedule

Before the job runs unattended, confirm that it logs the delay and outcome of every 429, that it alerts when x-ms-throttle-limit-percentage first appears, and that its run time avoids windows when other tenant automation runs. Then promote it in stages. Run a read-only pass, then a small write pass on a handful of objects with the stored-value rollback tested, then the full run.

About this page

Credited to

Dates

Published

Sources

This page lists no external sources.

Corrections

No corrections are listed for this page. Some review sweeps corrected pages without naming each one; those are in the corrections log.

Found this useful? Follow KBY for more like it.

Reader Interaction

Comments

Add a thoughtful note on Design Microsoft 365 Automation That Survives Microsoft Graph Throttling: Retry-After, Batching and Safe Writes. Comments are checked for spam and held for moderation before appearing.

Loading comments...

Engineering insights, direct to you.

Receive the latest Systems Engineering tutorials, production guides, Engineering Labs and operational best practices.