Create invitation
Namespace: microsoft.graph
Use this API to create a new invitation. Invitation adds an external user to the organization.
When creating a new invitation, you have several options available:
- On invitation creation, Microsoft Graph can automatically send an invitation email directly to the invited user, or your app can use the inviteRedeemUrl returned in the response to craft your own invitation (through your communication mechanism of choice) to the invited user. If you decide to have Microsoft Graph send an invitation email automatically, you can specify the content and language of the email by using invitedUserMessageInfo.
- When the user is invited, a user entity (of userType
Guest
) is created and can be used to control access to resources. The invited user has to go through the redemption process to access any resources they have been invited to.
This API is available in the following national cloud deployments.
Global service | US Government L4 | US Government L5 (DOD) | China operated by 21Vianet |
---|---|---|---|
✅ | ✅ | ✅ | ✅ |
Permissions
Choose the permission or permissions marked as least privileged for this API. Use a higher privileged permission or permissions only if your app requires it. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.
Permission type | Least privileged permissions | Higher privileged permissions |
---|---|---|
Delegated (work or school account) | User.Invite.All | Directory.ReadWrite.All, User.ReadWrite.All |
Delegated (personal Microsoft account) | Not supported. | Not supported. |
Application | User.Invite.All | Directory.ReadWrite.All, User.ReadWrite.All |
Important
Application permissions (app-only) do not work if B2B invitations are disabled on the tenant or if B2B invitations are restricted to administrators.
HTTP request
POST /invitations
Request headers
Header | Value |
---|---|
Authorization | Bearer {token}. Required. Learn more about authentication and authorization. |
Content-Type | application/json |
Request body
In the request body, supply a JSON representation of an invitation object.
The following table lists the parameters that are required when you create an invitation.
Parameter | Type | Description |
---|---|---|
invitedUserEmailAddress | string | The email address of the user you're inviting. |
inviteRedirectUrl | string | The URL that the user will be redirected to after redemption. |
Response
If successful, this method returns 201 Created
response code and an invitation object in the response body.
Example
Request
The following example shows a request.
POST https://graph.microsoft.com/v1.0/invitations
Content-type: application/json
{
"invitedUserEmailAddress": "admin@fabrikam.com",
"inviteRedirectUrl": "https://myapp.contoso.com"
}
Response
The following example shows the response.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 201 Created
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#invitations/$entity",
"id": "9071bfde-35e0-47d2-a582-d244ab1b4af6",
"inviteRedeemUrl": "https://login.microsoftonline.com/redeem?rd=https%3a%2f%2finvitations.microsoft.com%2fredeem%2f%3ftenant%3d69997834-fa40-45da-xxxx-382c3bdc66c3%26user%3d9071bfde-35e0-47d2-a582-d244ab1b4af6%26ticket%3dwCFIFW%25252frzl2A%25252fpZFZk5fCLJprpDxtcjR8s%25252fo1QZA0yQ%25253d%26ver%3d2.0",
"invitedUserDisplayName": null,
"invitedUserType": "Guest",
"invitedUserEmailAddress": "admin@fabrikam.com",
"sendInvitationMessage": false,
"resetRedemption": false,
"inviteRedirectUrl": "https://myapp.contoso.com",
"status": "PendingAcceptance",
"invitedUserMessageInfo": {
"messageLanguage": null,
"customizedMessageBody": null,
"ccRecipients": [
{
"emailAddress": {
"name": null,
"address": null
}
}
]
},
"invitedUser": {
"id": "cbb896f9-8306-49d0-b56b-b8e39cd28825"
}
}
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기