Add shared link to file


Adds a shared link to a file.



Path Parameters

stringin pathrequired

The unique identifier that represents a file.

The ID for any file can be determined by visiting a file in the web application and copying the ID from the URL. For example, for the URL https://* the file_id is 123.

Query Parameters

stringin queryrequired

Explicitly request the shared_link fields to be returned for this item.

Request Body


application/jsonFile (Full)

Returns the base representation of a file with a new shared link attached.

application/jsonClient error

Returned when there is an incorrect permission combination

application/jsonClient error

Returned when the access token provided in the Authorization header is not recognized or not provided.

application/jsonClient error

Returned if the user does not have all the permissions to complete the update.

application/jsonClient error

Returned if the file is not found, or the user does not have access to the file.

application/jsonClient error

Returned if the file_id is not in a recognized format.

application/jsonClient error

Returns an error when the If-Match header does not match the current etag value of the file. This indicates that the file has changed since it was last requested.

application/jsonClient error

An unexpected client error.

Add shared link to file
You can now try out some of our APIs live, right here in the documentation.
Log in

Request Example

curl -i -X PUT "" \
     -H "authorization: Bearer <ACCESS_TOKEN>" \
     -d '{
       "shared_link": {
         "access": "open",
         "password": "mypassword",
         "unshared_at": "2012-12-12T10:53:43-08:00",
         "permissions": {
           "can_download": false
file_id = '11111'

url = client.file(file_id).get_shared_link(access='open', allow_download=True, allow_edit=True)
print(f'The file shared link URL is: {url}')
string fileId = "11111";
var sharedLinkParams = new BoxSharedLinkRequest()
    Access =,
    Permissions = new BoxPermissionsRequest
        Download = true,
        Edit = true
BoxFile file = client.FilesManager.CreateSharedLinkAsync(fileId, sharedLinkParams);
string sharedLinkUrl = file.SharedLink.Url;
// Optionally we can calculate and set the date when shared link will automatically be disabled
final long ONE_WEEK_MILLIS = 1000 * 60 * 60 * 24 * 7;
long unsharedTimestamp = System.currentTimeMillis() + ONE_WEEK_MILLIS;
Date unsharedDate = new Date(unsharedTimestamp);

BoxFile file = new BoxFile(api, "id");
BoxSharedLinkRequest sharedLinkRequest = new BoxSharedLinkRequest()
    .permissions(true, true)
BoxSharedLink sharedLink = file.createSharedLink(sharedLinkRequest);
client.files.update('12345', {
  shared_link: {
    access: "open",
    password: "do-not-use-this-password", 
    unshared_at: "2022-12-12T10:53:43-08:00",
    vanity_name: "my-shared-link",
    permissions: {
	  can_view: true,
	  can_download: true,
	  can_edit: true
}).then(file => {
  // ...
    forFile: "11111", 
    access: .open, 
    canDownload: true, 
    canEdit: true
) { (result: Result<SharedLink, BoxSDKError>) in
    guard case let .success(sharedLink) = result else {
        print("Error setting file shared link")

    print("File shared link URL is \(sharedLink.url), with \(sharedLink.access) access")

Response Example

  "id": "12345",
  "type": "file",
  "etag": "1",
  "shared_link": {
    "url": "",
    "download_url": "",
    "vanity_url": null,
    "vanity_name": null,
    "effective_access": "open",
    "effective_permission": "can_download",
    "is_password_enabled": false,
    "unshared_at": "2020-09-21T10:34:41-07:00",
    "download_count": 0,
    "preview_count": 0,
    "access": "open",
    "permissions": {
      "can_preview": true,
      "can_download": true,
      "can_edit": true