Box Developer Documentation
Latest version

Get shared link for file

get
https://api.box.com/2.0
/files/:file_id

This endpoint is in the version 2024.0. No changes are required to continue using it. For more details, see Box API versioning.

Gets the information for a shared link on a file.

Request

bearer [ACCESS_TOKEN]
application/json

Path Parameters

stringin pathrequired
12345

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://*.app.box.com/files/123 the file_id is 123.

Query Parameters

stringin queryrequired
shared_link

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

Response

application/jsonFile (Full)

Returns the base representation of a file with the additional shared link information.

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 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

An unexpected client error.

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

Request Example

Learn more about Box SDK versionig strategy.


cURL
curl -i -X GET "https://api.box.com/2.0/files/32423234?fields=shared_link" \
     -H "authorization: Bearer <ACCESS_TOKEN>"
Node/TypeScript v10
await client.sharedLinksFiles.getSharedLinkForFile(fileId, {
  fields: 'shared_link',
} satisfies GetSharedLinkForFileQueryParams);
Python v10
client.shared_links_files.get_shared_link_for_file(file_id, "shared_link")
.NET v10
await client.SharedLinksFiles.GetSharedLinkForFileAsync(fileId: fileId, queryParams: new GetSharedLinkForFileQueryParams(fields: "shared_link"));
Swift v10
try await client.sharedLinksFiles.getSharedLinkForFile(fileId: fileId, queryParams: GetSharedLinkForFileQueryParams(fields: "shared_link"))
Java v10
client.getSharedLinksFiles().getSharedLinkForFile(fileId, new GetSharedLinkForFileQueryParams("shared_link"))
Java v4
BoxFile file = new BoxFile(api, "id");
BoxFile.Info info = file.getInfo();
BoxSharedLink link = info.getSharedLink();
String url = link.getUrl();
Python v3
file_id = '11111'
shared_link = client.file(file_id).get().shared_link
url = shared_link['url']
Node v3
client.files.get('11111', { fields: 'shared_link' })
  .then(file => {
    let url = file.shared_link.download_url
    //...
  })

Response Example

{
  "etag": "1",
  "id": "12345",
  "shared_link": {
    "access": "open",
    "download_count": 0,
    "download_url": "https://app.box.com/shared/static/kwio6b4ovt1264rnfbyqo1.pdf",
    "effective_access": "open",
    "effective_permission": "can_download",
    "is_password_enabled": false,
    "permissions": {
      "can_download": true,
      "can_edit": true,
      "can_preview": true
    },
    "preview_count": 0,
    "unshared_at": "2020-09-21T10:34:41-07:00",
    "url": "https://app.box.com/s/kwio6b4ovt1264rnfbyqo1",
    "vanity_name": null,
    "vanity_url": null
  },
  "type": "file"
}