permission: grant
Namespace: microsoft.graph
Grant users access to a link represented by a permission.
Permissions
One of the following permissions is required to call this API. To learn more, including how to choose permissions, see Permissions.
| Permission type | Permissions (from least to most privileged) |
|---|---|
| Delegated (work or school account) | Files.ReadWrite, Files.ReadWrite.All, Sites.ReadWrite.All |
| Delegated (personal Microsoft account) | Not supported |
| Application | Files.ReadWrite.All, Sites.ReadWrite.All |
HTTP request
POST /shares/{encoded-sharing-url}/permission/grant
Request headers
| Name | Description |
|---|---|
| Authorization | Bearer {token}. Required. |
Request body
In the request body, provide a JSON object with the following parameters.
{
"recipients": [
{ "@odata.type": "microsoft.graph.driveRecipient" }
],
"roles": [ "read | write"]
}
| Parameter | Type | Description |
|---|---|---|
| recipients | Collection(driveRecipient) | A collection of recipients who will receive access. |
| roles | Collection(String) | If the link is an "existing access" link, specifies roles to be granted to the users. Otherwise must match the role of the link. |
For a list of available roles, see roles property values.
Response
If successful, this method returns a 200 OK response code and a permission collection in the response body.
A permission representing the updated link will always be returned in the result set on success. The updated link can be identified by the presence of a 'link' facet containing the 'scope' property. In some cases it may be possible that the updated link has a different URL than the original link, in which case the new URL should be used.
Read the Error Responses topic for more info about how errors are returned.
Example
This example grants the users john@contoso.com and ryan@external.com access to a sharing link without modifying other existing permissions on the link.
Request
POST https://graph.microsoft.com/v1.0/shares/{encoded-sharing-url}/permission/grant
Content-type: application/json
{
"recipients": [
{
"email": "john@contoso.com"
},
{
"email": "ryan@external.com"
}
],
"roles": ["read"]
}
Response
HTTP/1.1 200 OK
Content-type: application/json
{
"value": [
{
"hasPassword": false,
"id": "5fab944a-47ec-48d0-a9b5-5178a926d00f",
"link": {
"preventsDownload": false,
"scope": "users",
"type": "view",
"webUrl": "https://contoso.sharepoint.com/:t:/g/design/EZexPoDjW4dMtKFUfAl6BK4BvIUuss52hLYzihBfx-PD6Q"
},
"roles": [
"read"
]
}
]
}
Note: The response object shown here might be shortened for readability.
If the link is an existing access link, additional permissions will be returned representing the following:
- User-type permissions representing recipients who were successfully granted access. These can be identified by presence of the grantedTo property.
- Link-type permissions representing invitations that need to be sent to unrecognized external users for them to gain access. These can be identified by the presence of an invitation facet. These entries will contain a link with the invitation URL, and the grantedToIdentities collection will indicate the users to whom the link should be sent.
HTTP/1.1 200 OK
Content-type: application/json
{
"value": [
{
"hasPassword": false,
"id": "00000000-0000-0000-0000-000000000000",
"link": {
"preventsDownload": false,
"scope": "existingAccess",
"type": "view",
"webUrl": "https://contoso.sharepoint.com/teams/design/shareddocs/Document.docx"
},
"roles": [
"read"
]
},
{
"grantedTo": {
"user": {
"displayName": "John Smith",
"email": "john@contoso.com",
"id": "47aecee2-d061-4730-8ecb-4c61360441ae"
}
},
"id": "aTowIy5mfG1lbWJlcnNoaXB8bGltaXRlZDJAa2xhbW9kYi5vbm1pY3Jvc29mdC5jb20",
"roles": [
"read"
]
},
{
"grantedToIdentities": [
{
"user": {
"email": "ryan@external.com"
}
}
],
"invitation": {
"signInRequired": true
},
"roles": [
"read"
],
"link": {
"type": "view",
"webUrl": "https://contoso.sharepoint.com/:t:/g/teams/design/EZexPoDjW4dMtKFUfAl6BK4Bw_F7gFH63O310A7lDtK0mQ"
}
}
]
}
Note: The response object shown here might be shortened for readability.
Feedback
Submit and view feedback for