Create a permission for a file or shared drive

POST {{baseUrl}}/files/:fileId/permissions?key={{key}}&oauth_token={{oauthToken}}

Creates a permission for a file or shared drive. For more information on creating permissions, see Share files, folders & drives.

Warning:ย Concurrent permissions operations on the same file are not supported; only the last update is applied.

Request Params

KeyDatatypeRequiredDescription
emailMessagestringA plain text custom message to include in the notification email.
enforceSingleParentstringDeprecated. See moveToNewOwnersRoot for details.
moveToNewOwnersRootstringThis parameter will only take effect if the item is not in a shared drive and the request is attempting to transfer the ownership of the item. If set to true, the item will be moved to the new owner's My Drive root folder and all prior parents removed. If set to false, parents are not changed.
sendNotificationEmailstringWhether to send a notification email when sharing to users or groups. This defaults to true for users and groups, and is not allowed for other requests. It must not be disabled for ownership transfers.
supportsAllDrivesstringWhether the requesting application supports both My Drives and shared drives.
supportsTeamDrivesstringDeprecated use supportsAllDrives instead.
transferOwnershipstringWhether to transfer ownership to the specified user and downgrade the current owner to a writer. This parameter is required as an acknowledgement of the side effect. File owners can only transfer ownership of files existing on My Drive. Files existing in a shared drive are owned by the organization that owns that shared drive. Ownership transfers are not supported for files and folders in shared drives. Organizers of a shared drive can move items from that shared drive into their My Drive which transfers the ownership to them.
useDomainAdminAccessstringIssue the request as a domain administrator; if set to true, then the requester will be granted access if the file ID parameter refers to a shared drive and the requester is an administrator of the domain to which the shared drive belongs.
altstringData format for the response.
fieldsstringSelector specifying which fields to include in a partial response.
keystringAPI key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
oauth_tokenstringOAuth 2.0 token for the current user.
prettyPrintstringReturns response with indentations and line breaks.
quotaUserstringAn opaque string that represents a user for quota purposes. Must not exceed 40 characters.
userIpstringDeprecated. Please use quotaUser instead.

Request Body

{"allowFileDiscovery"=>"<boolean>", "deleted"=>"<boolean>", "displayName"=>"<string>", "domain"=>"<string>", "emailAddress"=>"<string>", "expirationTime"=>"<dateTime>", "id"=>"<string>", "kind"=>"drive#permission", "pendingOwner"=>"<boolean>", "permissionDetails"=>[{"inherited"=>"<boolean>", "inheritedFrom"=>"<string>", "permissionType"=>"<string>", "role"=>"<string>"}, {"inherited"=>"<boolean>", "inheritedFrom"=>"<string>", "permissionType"=>"<string>", "role"=>"<string>"}], "photoLink"=>"<string>", "role"=>"<string>", "teamDrivePermissionDetails"=>[{"inherited"=>"<boolean>", "inheritedFrom"=>"<string>", "role"=>"<string>", "teamDrivePermissionType"=>"<string>"}, {"inherited"=>"<boolean>", "inheritedFrom"=>"<string>", "role"=>"<string>", "teamDrivePermissionType"=>"<string>"}], "type"=>"<string>", "view"=>"<string>"}

HEADERS

KeyDatatypeRequiredDescription
Content-Typestring
Acceptstring

RESPONSES

status: OK

{&quot;allowFileDiscovery&quot;:&quot;\u003cboolean\u003e&quot;,&quot;deleted&quot;:&quot;\u003cboolean\u003e&quot;,&quot;displayName&quot;:&quot;\u003cstring\u003e&quot;,&quot;domain&quot;:&quot;\u003cstring\u003e&quot;,&quot;emailAddress&quot;:&quot;\u003cstring\u003e&quot;,&quot;expirationTime&quot;:&quot;\u003cdateTime\u003e&quot;,&quot;id&quot;:&quot;\u003cstring\u003e&quot;,&quot;kind&quot;:&quot;drive#permission&quot;,&quot;pendingOwner&quot;:&quot;\u003cboolean\u003e&quot;,&quot;permissionDetails&quot;:[{&quot;inherited&quot;:&quot;\u003cboolean\u003e&quot;,&quot;inheritedFrom&quot;:&quot;\u003cstring\u003e&quot;,&quot;permissionType&quot;:&quot;\u003cstring\u003e&quot;,&quot;role&quot;:&quot;\u003cstring\u003e&quot;},{&quot;inherited&quot;:&quot;\u003cboolean\u003e&quot;,&quot;inheritedFrom&quot;:&quot;\u003cstring\u003e&quot;,&quot;permissionType&quot;:&quot;\u003cstring\u003e&quot;,&quot;role&quot;:&quot;\u003cstring\u003e&quot;}],&quot;photoLink&quot;:&quot;\u003cstring\u003e&quot;,&quot;role&quot;:&quot;\u003cstring\u003e&quot;,&quot;teamDrivePermissionDetails&quot;:[{&quot;inherited&quot;:&quot;\u003cboolean\u003e&quot;,&quot;inheritedFrom&quot;:&quot;\u003cstring\u003e&quot;,&quot;role&quot;:&quot;\u003cstring\u003e&quot;,&quot;teamDrivePermissionType&quot;:&quot;\u003cstring\u003e&quot;},{&quot;inherited&quot;:&quot;\u003cboolean\u003e&quot;,&quot;inheritedFrom&quot;:&quot;\u003cstring\u003e&quot;,&quot;role&quot;:&quot;\u003cstring\u003e&quot;,&quot;teamDrivePermissionType&quot;:&quot;\u003cstring\u003e&quot;}],&quot;type&quot;:&quot;\u003cstring\u003e&quot;,&quot;view&quot;:&quot;\u003cstring\u003e&quot;}