Box Developer Documentation
Latest version

Add shared link to web link

put
https://api.box.com/2.0
/web_links/:web_link_id

Adds a shared link to a web link.

Request

bearer [ACCESS_TOKEN]
application/json

Path Parameters

Query Parameters

stringin queryrequired
shared_link

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

Request Body

Response

application/jsonWeb link

Returns the base representation of a web link 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.

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

Request Example

cURL
curl -i -X PUT "https://api.box.com/2.0/web_links/32423234?fields=shared_link" \
     -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
         }
       }
     }'
TypeScript Gen
await client.sharedLinksWebLinks.addShareLinkToWebLink(
  webLinkId,
  {
    sharedLink: {
      access: 'open' as AddShareLinkToWebLinkRequestBodySharedLinkAccessField,
      password: 'Secret123@',
    } satisfies AddShareLinkToWebLinkRequestBodySharedLinkField,
  } satisfies AddShareLinkToWebLinkRequestBody,
  { fields: 'shared_link' } satisfies AddShareLinkToWebLinkQueryParams,
);
Python Gen
client.shared_links_web_links.add_share_link_to_web_link(
    web_link_id,
    "shared_link",
    shared_link=AddShareLinkToWebLinkSharedLink(
        access=AddShareLinkToWebLinkSharedLinkAccessField.OPEN, password="Secret123@"
    ),
)
.NET Gen
await client.SharedLinksWebLinks.AddShareLinkToWebLinkAsync(webLinkId: webLinkId, requestBody: new AddShareLinkToWebLinkRequestBody() { SharedLink = new AddShareLinkToWebLinkRequestBodySharedLinkField() { Access = AddShareLinkToWebLinkRequestBodySharedLinkAccessField.Open, Password = "Secret123@" } }, queryParams: new AddShareLinkToWebLinkQueryParams(fields: "shared_link"));
Python
url = client.web_link('12345').get_shared_link(access='open')
print(f'The web link shared link URL is: {url}')
.NET
string webLinkId = "11111";
var sharedLinkParams = new BoxSharedLinkRequest()
{
    Access = BoxSharedLinkAccessType.open
};
BoxWebLink link = client.WebLinksManager
    .CreateSharedLinkAsync(webLinkId, sharedLinkParams);
string sharedLinkUrl = link.SharedLink.Url;
iOS
client.webLinks.setSharedLink(forWebLink: "11111", access: .open) { (result: Result<SharedLink, BoxSDKError>) in
    guard case let .success(sharedLink) = result else {
        print("Error setting weblink shared link")
        return
    }

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

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": false,
      "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": "web_link"
}