Cloudek.Request a service session

AI operations

Approval-Gated Automation for M365 Licence and Guest Access with Power Automate and Microsoft Graph

Design a Power Automate request flow for Microsoft 365 licences and guests with least-privilege Graph permissions, human approval, audit and rollback.

Put approval before the Graph call

Licence assignment and guest invitations change access. A request form, prompt or agent can collect context, but none of those inputs should directly choose a target or call Microsoft Graph. The safe sequence is: validate the request, resolve the target from an authoritative source, preview the exact action, obtain approval, perform one bounded Graph operation, and write an audit record. This is part of the Power Automate AI for IT operations series.

This is approval-gated automation: the system prepares a proposed operation, while a named reviewer decides whether it may proceed. The guest access path should include a sponsor and a plan to review existing guest accounts, not only a new invitation step.

The article describes a design, not a deployed connector. Graph permissions and identity roles below are sourced from Microsoft's endpoint documentation, but an administrator must validate them against the actual action, tenant policy and current docs before use. Do not copy permissions from an example without reviewing the permission table.

Keep the request separate from the action

Use a request list or service desk as the source of truth. A useful record can include a request reference, request type, business reason, desired start date, target person reference, requested licence or guest purpose, sponsor, approval state and decision time. Keep retention and access controls consistent with the organisation's identity process.

If a prompt or conversational assistant reads the request, limit it to classifying or summarising the submitted fields. Treat free text as untrusted data; it must not override the request type, target, approval policy or action. The AI prompt and AI Builder guide explains schema validation, and the least-privilege guide covers agent identity boundaries.

Resolve the target using a stable identifier from the authenticated request process, not a display name typed into a prompt. If there are multiple matches, no match, or a mismatch between requester and target, stop and ask an administrator. A free-text licence name should map to an allowed SKU table with a human-readable display label; reject products that are not in the approved catalogue.

Separate the two operations

Do not combine licence assignment and guest invitation into one generic do what the request says flow. They have different Graph endpoints, permissions, approval questions, lifecycle and rollback:

RequestGraph operationApproval evidenceRollback question
Assign a licencePOST /users/{id}/assignLicenseProduct, target, business justification and expected cost sourceIs removal safe, and what workloads rely on the licence?
Invite a guestPOST /invitationsSponsor, purpose, expiry/review plan and allowed domain policyShould sign-in be blocked, access removed, or both?

For licensing, Microsoft's assignLicense API documents LicenseAssignment.ReadWrite.All as the least-privileged Graph permission for the operation. It lists delegated and application permission options and supported Entra roles. Use the endpoint documentation to confirm whether the chosen permission type and caller role are appropriate for the flow. Do not substitute a broad permission simply because it is familiar.

For invitation, Microsoft's invitation API documents User.Invite.All as the least-privileged permission. Its delegated role requirements include Guest Inviter, Directory Writers or User Administrator under the documented conditions. Tenant invitation restrictions can also affect the outcome. Verify those rules with the tenant administrator before enabling the operation.

Flow stages

  1. Receive: accept a request from a controlled form, service desk or internal application.
  2. Validate: require the fields for that request type; reject unknown properties and unsupported values.
  3. Resolve: look up the target and requested product from authoritative directory or catalogue data.
  4. Check policy: confirm the requester may request this action and the target meets eligibility rules.
  5. Preview: display the exact user reference, licence SKU or invitation purpose, sponsor, timing and consequence.
  6. Approve: require a named authorised reviewer to approve that exact preview.
  7. Act: call only the corresponding Graph endpoint, using a dedicated identity and the approved values.
  8. Verify: read back the minimum fields needed to confirm the action result; if verification is inconclusive, route to an administrator.
  9. Audit: save the request reference, decision, actor, action type, timestamp and outcome.

The Draft, Preview, Human approve, Act, Log pattern applies whether the request came from a form or a conversational agent. If the approval expires, the flow should stop and ask for a new request rather than replaying a stale approval.

Approval card contents

An approver should be able to distinguish a harmless draft from a real change. Show:

  • The target resolved by the system and enough context to disambiguate it.
  • The exact licence product to assign, or the guest invitation's purpose and sponsor.
  • The request reference, business reason, request date and requested duration.
  • The relevant eligibility and policy checks, including any that could not be confirmed.
  • Whether the action has already run, and the result if the card is reopened.
  • A clear reject path and a way to request correction.

Do not put an approval button on a card where a reviewer cannot inspect the target and consequences. A user clicking “approve” does not make a malformed request safe. Re-check the approval state immediately before the Graph call and ensure the approval refers to the same request version that was previewed.

Make retries safe

Power Automate can retry connector actions depending on their configuration. A timeout may occur after Graph has completed the operation but before the flow received the response. Blindly repeating the call can create duplicate invitations or confusing state. Store an operation state keyed by the request reference, mark the request as in progress before the call, and reconcile uncertain results before trying again. Confirm the exact Graph endpoint semantics and idempotency behaviour; do not assume a request is safe to replay.

For a licence, read the current licence assignments before retrying and compare with the approved SKU. For an invitation, search using the invitation's stable correlation context and verify the result before resubmitting. These reads must be tenant-bound and limited to the fields required for the operation. If the flow cannot tell whether the first attempt succeeded, leave it pending for an administrator rather than running another write.

Audit without oversharing

Keep an audit record sufficient to explain who requested, reviewed and executed the operation. A record may include the request reference, operation category, approval identifier, decision, time, Graph outcome code and the service identity. Store only the identifiers required for the organisation's process and restrict access. Do not copy full prompts, raw messages, tokens or complete Graph responses into the audit list.

Keep run history and the request system under their own retention and access rules. An audit list should not become a shadow directory or a place where a broad group can browse guest addresses. If a log must include a target reference, use the organisation's approved identifier handling and ensure only authorised operators can access it.

Rollback is an owned procedure

For licence removal, first identify downstream services and user impact. A licence may enable workloads or retain data under a specific service plan. The rollback runbook should name who confirms impact, how to remove the assigned SKU through the supported admin workflow or Graph operation, and how to verify the resulting state. Do not automatically remove licences after a fixed timer unless the business owner has explicitly approved that lifecycle.

For a guest, the organisation may need to block sign-in, remove access from groups and applications, then remove or retain the directory object according to policy. Those are separate decisions. The invitation itself may have been redeemed, and external access may exist in multiple resources. A runbook should identify the sponsor, application owners, access-review process and records-retention rule before removal.

When either rollback is uncertain, preserve the request and raise it for an administrator. Reversibility is not permission to act without review.

Review existing guests too

New guest invitations are only half of external-access governance. Include a regular review of existing guests: confirm sponsor and business purpose, review last activity where the available signal is reliable, check group and application access, and set an owner and review date. A guest with no recent sign-in is not automatically unused; workload access and business context may not be visible from one activity signal. Route ambiguous cases to the sponsor instead of deleting the account.

The read-only stale account and guest review describes a review process for existing guests. This page does not claim to automate that review or to make changes through OpsPilot. Use the tenant's own authorised administration workflow and retain decisions according to policy.

Test before enabling

Use a non-production tenant with synthetic request data. Exercise missing target, ambiguous target, unknown SKU, unauthorised requester, approval rejection, expired approval, duplicate delivery, timeout after a successful Graph response, and a guest domain blocked by policy. Confirm that every refusal creates a useful but privacy-aware audit outcome and that no write occurs before approval.

Review the API permission and identity role separately. Application permissions can act without a signed-in user; delegated permissions act in a user context. Choose a model deliberately, document the identity owner, and verify which administrative role is needed for the intended call. Keep credentials in the organisation's approved secret store; never put tokens in flow text, examples or logs.

For each test, capture the expected state transition rather than a real person's details. For example, a synthetic request can move from Submitted to Approved and then Completed, while a rejected or expired request must remain non-executable. Assert that the Graph action is not reached for every refusal path. Test the audit record for missing and duplicate events, and ensure the reviewer can distinguish a second attempt from a completed first attempt. Only then should the owner decide whether a limited production pilot is appropriate.

Summary

Build licence and guest flows as separate, approval-gated operations. Resolve targets from trusted data, validate every input, show an exact preview, use the documented least-privilege Graph permission, re-check the approval before the call, and audit the result without copying unnecessary personal data. Review existing guests on a separate schedule, and keep rollback under an accountable administrator.

Microsoft sources checked on 24 November 2026: Assign license API and Create invitation API.

Frequently asked questions

Should a prompt choose the licence SKU or guest account?

No. Resolve the requested product and target through a fixed catalogue and authoritative identity source, validate them, and show them to an approver. Reject unknown or ambiguous requests instead of guessing.

Which Graph permission assigns a licence?

Microsoft Graph documents LicenseAssignment.ReadWrite.All for assignLicense. The endpoint also has supported delegated and application permission models; check the current permission table and tenant role requirements before configuring access.

Which Graph permission sends a guest invitation?

Microsoft Graph documents User.Invite.All for creating an invitation. Check the endpoint's current delegated roles and tenant invitation policy; an API permission alone does not mean the request should be approved.

What should the audit log store?

Record a request reference, action type, approval decision, approver, time and outcome. Avoid storing the full prompt, message or unnecessary identity details in a broad operations log.

How do I undo an assignment or invitation?

Document separate, permission-checked rollback steps: remove an assigned licence after confirming impact, or block sign-in and remove guest access according to policy. Do not make rollback automatic without an owner-approved procedure.

CHECK THIS IN YOUR TENANT • OPSPILOT

Which guests can reach your data? LIVE

OpsPilot lists guest accounts and what they can reach in Microsoft 365. External sharing and anonymous links are not built yet.

Read-only. Customer sign-in is an invitation-only trial, so access is agreed with you first.

Was this helpful?