Graph $batch Dependent Requests and Ordering Prompt
Design a Microsoft Graph $batch payload that chains dependent requests (create team, then add members, then post welcome) using the dependsOn ordering, with per-request error handling and a 20-request chunking strategy.
- Target user
- Engineers automating multi-step Teams provisioning via Graph
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a senior platform engineer who has used Graph $batch with dependsOn to run multi-step Teams provisioning in a single round trip and handled the partial-failure cases. I will provide: - The ordered steps you want to batch (e.g. create team -> add channels -> add members -> post card): [STEPS] - The total count of sub-operations (members, channels) per provisioning run: [COUNTS] - Your auth model (app-only vs delegated): [AUTH] - How you want to handle a mid-batch failure: [FAILURE POLICY] Your job: 1. **Build the batch** — construct the JSON batch request with each step as a request object (id, method, url, body, headers); show a real example for the [STEPS] above. 2. **Order with dependsOn** — use dependsOn so step 2 only runs if step 1 succeeded; explain that Graph evaluates dependencies and that a failed dependency yields a 424 Failed Dependency for downstream requests. 3. **Respect the 20-request limit** — a single $batch holds at most 20 requests; show how to chunk [COUNTS] sub-operations across multiple batches and how to thread state (the new team id) from batch 1 into batch 2. 4. **Per-request status** — parse the responses array, mapping each id back to its step, and surface which sub-operations succeeded vs 424'd vs 429'd. 5. **Throttling inside batch** — individual sub-requests can return 429 with their own Retry-After; show selective retry of only the throttled sub-requests rather than replaying the whole batch. 6. **Idempotency** — make re-running a partially-failed provisioning safe (skip already-created resources) so a retry doesn't duplicate channels or members. Output as: (a) the full $batch JSON with dependsOn, (b) the chunking plan across the 20-request limit, (c) the response-parsing and per-request status map, (d) the selective-retry logic for 429s, (e) the idempotent re-run strategy. Bias toward: dependsOn for ordering, selective retry over full replay, and idempotent re-runs.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Why this prompt works
The Graph $batch endpoint is the right tool for multi-step Teams provisioning, but most examples show three independent requests bundled for a single round trip and stop there. Real provisioning is dependent: you can’t add members to a team that doesn’t exist yet. This prompt centers the dependsOn ordering primitive, forcing the design to express “step 2 only runs if step 1 succeeded” and to handle the 424 Failed Dependency that Graph returns downstream when an early step fails. That single detail separates a batch that provisions cleanly from one that fires member-adds at a team id that was never created.
The prompt also refuses to ignore the platform’s two unforgiving constraints: the 20-request-per-batch ceiling and per-sub-request throttling. By requiring an explicit chunking plan and the threading of state (the new team id) from one batch into the next, the output handles the common case of provisioning more than twenty members or channels. By requiring selective retry of only the sub-requests that returned 429 — each with its own Retry-After — it avoids the classic mistake of replaying an entire batch and duplicating everything that already succeeded.
Finally, the idempotency requirement makes partial failure survivable. Provisioning runs will fail halfway, and the difference between a calm retry and a duplicated mess is whether the re-run skips already-created resources. Asking for that explicitly produces a provisioning flow you can safely run twice, which in practice is the only kind worth shipping.
Related prompts
-
Teams Graph API Batch Requests for Bulk Operations Prompt
Use Microsoft Graph JSON batching to perform bulk Teams operations (membership, channel, tab changes) efficiently while respecting dependency ordering, throttling, and partial failure.
-
Teams Graph Team Provisioning from Template Prompt
Automate spinning up a fully-configured incident or project team from a reusable template via Graph — channels, tabs, apps, tags, and membership — instead of hand-building each war room.
-
Teams Graph Usage Report Adoption Digest Prompt
Use the Microsoft Graph reports API to build a Teams adoption / usage digest — active users, message and meeting activity, app usage — and post it back into Teams as an Adaptive Card for platform owners.
-
Graph Change Notifications with Rich Resource Data Batching Prompt
Design a Graph change-notification receiver that batches encrypted resource-data payloads, validates the dataSignature, and decrypts in bulk so a high-volume Teams message subscription does not melt your endpoint.
More Microsoft Teams prompts & error guides
Browse every Microsoft Teams prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.