Create Shared Link

Create Shared Link

Shared links may be created directly for file or folder resources to generate a read-only URL to permit users with the appropriate access level to view the content.

You may only have one active shared link for a file or folder at any time.

At minimum the information needed to create a shared link will be:

  • The type of resource, either a file or folder.
  • The ID of that resource.

Optionally when creating a shared link the following may be specified:

  • The access level, which may be one of:

    • open: A public shared link. Anyone with the link may access the link.
    • company: Anyone within your enterprise may access the link.
    • collaborators: Anyone collaborated on the content may access the link.
  • An expiration time when the shared link will automatically disable.
  • A password required to access the resource.

If an access level is not specified when creating a shared link it will use the default access level specified by the enterprise admin.

To create a shared link on a file, specify the ID of the file with any optional shared link parameters.

.NET
string fileId = "11111";
var sharedLinkParams = new BoxSharedLinkRequest()
{
    Access = BoxSharedLinkAccessType.open
};
BoxFile file = client.FilesManager.CreateSharedLinkAsync(fileId, sharedLinkParams);
string sharedLinkUrl = file.SharedLink.Url;

To create a shared link on a folder, specify the ID of the folder with any optional shared link parameters.

.NET
var sharedLinkParams = new BoxSharedLinkRequest()
{
    Access = BoxSharedLinkAccessType.open
};
BoxFolder folder = await client.FoldersManager.CreateSharedLinkAsync("11111", sharedLinkParams);
string sharedLinkUrl = folder.SharedLink.Url;