Skip to main content

Shares API

Share a file or folder, choose who can reach it, and set what each recipient may do. Two base paths are involved: shared lists what has been shared with you, and shares manages the shares you provide.

Base URL and scope

/api/external/v1/shared
/api/external/v1/shares

Listing, reading a share, searching users, and reading share types need api:read. Creating, changing, removing a share, and setting recipients additionally need api:write.

Share types

A share has one type, which decides who can reach the resource.

TypeWho can reach the resource
SPECIFIC_USERSOnly the users you name as recipients
ORG_LINKAnyone inside the organization
PUBLIC_LINKAnyone with the link

Every resource in the same hierarchy must use the same share type. Call the share-types endpoint before creating a share to find out which types the resource allows.

Permission flags

Permissions are five booleans, used both for the share as a whole and for each recipient.

FlagPermission
cvView
ceEdit
cdDownload
cuUpload
csRe-share

cv is the prerequisite for the others: any of ce, cd, cu, or cs set to true requires cv to be true. Turning cv off while another permission is on fails with PERMISSION_003. For ORG_LINK and PUBLIC_LINK, cv must be true and the remaining four must be sent explicitly.

In responses the same permissions appear under their long names: canView, canEdit, canDownload, canUpload, canDelete, and canShare.

List what is shared with you

GET /api/external/v1/shared
ParameterTypeRequiredDescription
psintegerYesPage size, minimum 1
rtenumNoFILE or FOLDER
ftenumNoFile type - document, spreadsheet, presentation, pdf, image, note
oistringNoOwner id, up to 254 characters
sddateNoStart of the modified-date range; ignored unless ed is also sent
eddateNoEnd of the modified-date range; ignored unless sd is also sent
sbenumNoSort field - name, size, update, open, share; ignored unless so is also sent
soenumNoSort order; ignored unless sb is also sent
cilongNoCursor id from the previous page
cvobjectNoCursor value from the previous page
ctenumNoCursor type from the previous page
List shared
curl -X GET "https://drive.example.com/api/external/v1/shared?ps=10" \
-H "Authorization: Bearer replace-with-your-api-key"
cv means two different things

As a query parameter on this endpoint, cv is the pagination cursor value. In a share request body, cv is the view permission. The two never appear in the same request.

Each entry reports the resource, its owner and tenant, when it was shared, your effective permissions, and who registered or last changed the share. It also carries isStarred and starredSeq, so a shared item can be starred like any other resource. This endpoint uses cursor pagination; see Common conventions.

Read the share types a resource allows

GET /api/external/v1/shares/{resourceSeq}/share-types
ParameterTypeRequiredDescription
resourceSeqlongYesPath parameter - the resource to check
ssintegerNoOwner seq; null when you own the resource
Share types response
{
"result": true,
"code": 200,
"message": "OK",
"data": {
"editable": true,
"allowSpecificUsers": true,
"allowOrgLink": true,
"allowPublic": true,
"shareTypes": [
{
"code": "SPECIFIC_USERS",
"name": "Specific users",
"allowedPermissions": ["DOWNLOAD", "EDIT", "SHARE", "VIEW"]
},
{
"code": "ORG_LINK",
"name": "Anyone in the organization",
"allowedPermissions": ["DOWNLOAD", "EDIT", "VIEW"]
},
{
"code": "PUBLIC_LINK",
"name": "Anyone with the link",
"allowedPermissions": ["DOWNLOAD", "EDIT", "VIEW"]
}
]
}
}

allowedPermissions is what an administrator permits for that type; a share cannot grant more than this. Note that ORG_LINK and PUBLIC_LINK do not offer re-share.

Create a share

Requires api:write

Only the owner of the resource can create a share. Read the allowed share types first.

POST /api/external/v1/shares
ParameterTypeRequiredDescription
rslongYesThe file or folder to share
stenumYesShare type - SPECIFIC_USERS, ORG_LINK, or PUBLIC_LINK
cvbooleanNoView permission; must be true for ORG_LINK and PUBLIC_LINK
cebooleanNoEdit permission; required for ORG_LINK and PUBLIC_LINK
cdbooleanNoDownload permission; required for ORG_LINK and PUBLIC_LINK
cubooleanNoUpload permission; required for ORG_LINK and PUBLIC_LINK
csbooleanNoRe-share permission; required for ORG_LINK and PUBLIC_LINK
tsarrayNoRecipients; used when st is SPECIFIC_USERS

Each entry in ts names one recipient and their permissions:

FieldTypeRequiredDescription
usintegerYesRecipient user seq
cvbooleanYesView permission; must be true
cebooleanYesEdit permission
cdbooleanYesDownload permission
cubooleanYesUpload permission
csbooleanYesRe-share permission
sebooleanNoSend a notification email to this recipient
Create share
curl -X POST "https://drive.example.com/api/external/v1/shares" \
-H "Authorization: Bearer replace-with-your-api-key" \
-H "Content-Type: application/json" \
-d '{"rs": 5125, "st": "SPECIFIC_USERS", "cv": true, "ce": true, "cd": false, "cu": true, "cs": false, "ts": [{"us": 21, "cv": true, "ce": true, "cd": false, "cu": false, "cs": false, "se": true}]}'

The response returns the new shareSeq and the resulting permissions. Keep the shareSeq; every later operation on this share uses it.

Read a share

GET /api/external/v1/shares/{shareSeq}
ParameterTypeRequiredDescription
shareSeqlongYesPath parameter - the share to read
ssintegerNoOwner seq; required when you are not the owner

Returns the share type, the share-level permissions, password and isPasswordEnabled, expireDate, and a targets array of recipients with their own permissions and tenant.

modifiable reports whether the share type can still be changed. When it is false, the type is fixed - usually because another resource in the same hierarchy already set it.

Change a share

Requires api:write

Only the owner of the resource can change a share. Recipients can be set only while the type is SPECIFIC_USERS.

PATCH /api/external/v1/shares/{shareSeq}
ParameterTypeRequiredDescription
shareSeqlongYesPath parameter - the share to change
stenumYesShare type
cvbooleanNoView permission; must be true for ORG_LINK and PUBLIC_LINK
cebooleanNoEdit permission; required for ORG_LINK and PUBLIC_LINK
cdbooleanNoDownload permission; required for ORG_LINK and PUBLIC_LINK
cubooleanNoUpload permission; required for ORG_LINK and PUBLIC_LINK
csbooleanNoRe-share permission; required for ORG_LINK and PUBLIC_LINK
tsarrayNoRecipients, in the same shape as on create
Change share
curl -X PATCH "https://drive.example.com/api/external/v1/shares/36" \
-H "Authorization: Bearer replace-with-your-api-key" \
-H "Content-Type: application/json" \
-d '{"st": "SPECIFIC_USERS", "cv": true, "ce": true, "cd": true, "cu": true, "cs": false, "ts": [{"us": 25, "cv": true, "ce": true, "cd": true, "cu": false, "cs": false, "se": true}]}'

Set recipients

Requires api:write

Replaces the recipient list without changing the share type or its share-level permissions. Unlike the change endpoint, a user who was granted re-share permission may call this, not only the owner.

PUT /api/external/v1/shares/{shareSeq}/targets
ParameterTypeRequiredDescription
shareSeqlongYesPath parameter - the share to set recipients on
tsarrayNoRecipients, in the same shape as on create
ssintegerNoSharing user seq; null for your own resource

The list is replacing, not additive: a recipient you leave out loses access.

Remove a share

Requires api:write
DELETE /api/external/v1/shares/{shareSeq}
ParameterTypeRequiredDescription
shareSeqlongYesPath parameter - the share to remove

Everyone loses access, and any link for this share stops resolving. The resource itself is untouched.

Find recipients

GET /api/external/v1/shares/{shareSeq}/users

Lists the current recipients of a share with their id, name, status, and tenant. Pass ss when you are not the owner.

To find users who could be added, search instead. Use the first form when the share already exists and the second when you are still composing one:

GET /api/external/v1/shares/{shareSeq}/users/search
GET /api/external/v1/shares/users/search
ParameterTypeRequiredDescription
skstringYesSearch keyword - an email address or account name
ssintegerNoOwner seq; required when you are not the owner

Matches are returned under data.items.

GET /api/external/v1/shares/link/{token}
ParameterTypeRequiredDescription
tokenstringYesPath parameter - the token from the share URL

Returns the resource the link points to, its owner, isPublicLink, and a redirectUrl to send the browser to. Get the link itself from the share-link endpoint in Common conventions.

A public link still requires a key here

The internal path for this operation allows anonymous access, but this external endpoint does not. It always requires an API Key, and it checks view permission against the account the key represents - even for a PUBLIC_LINK share. A link that works anonymously in a browser will return PERMISSION_002 here if the key's account cannot view the resource. An unknown or revoked token returns SHARE_007.

Errors

See Errors for the full list of codes these endpoints return.