Manage Applications

    Get a file thumbnail

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

    Retrieves a thumbnail, or smaller image representation, of a file.

    Sizes of 32x32,64x64, 128x128, and 256x256 can be returned in the .png format and sizes of 32x32, 94x94, 160x160, and 320x320 can be returned in the .jpg format.

    Thumbnails can be generated for the image and video file formats listed found on our community site.

    Request

    application/json

    Path Parameters

    stringin pathrequired
    png

    The file format for the thumbnail

    Value is one of "png", "jpg"

    stringin pathrequired
    12345

    The unique identifier that represent 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

    integerin queryoptional
    32032-320

    The maximum height of the thumbnail

    integerin queryoptional
    32032-320

    The maximum width of the thumbnail

    integerin queryoptional
    3232-320

    The minimum height of the thumbnail

    integerin queryoptional
    3232-320

    The minimum width of the thumbnail

    Response

    image/png

    When a thumbnail can be created the thumbnail data will be returned in the body of the response.

    image/jpg

    When a thumbnail can be created the thumbnail data will be returned in the body of the response.

    none

    Sometimes generating a thumbnail can take a few seconds. In these situations the API returns a Location-header pointing to a placeholder graphic for this file type.

    The placeholder graphic can be used in a user interface until the thumbnail generation has completed. The Retry-After-header indicates when to the thumbnail will be ready. At that time, retry this endpoint to retrieve the thumbnail.

    none

    Returns an error when Box is not able to create a thumbnail for this file type.

    Instead, a Location-header pointing to a placeholder graphic for this file type will be returned.

    application/jsonClient Error

    Returns an error if some of the parameters are missing or invalid.

    • requested_preview_unavailable - an invalid dimension was requested. This will happen if the dimension requested is larger or smaller than the available file sizes for the thumbnail format, or when when any of the size constraints contradict each other.
    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, or for additional reasons.

    • preview_cannot_be_generated - Box does not support thumbnails for this type of file
    You can now try out some of our APIs live, right here in the documentation.
    Log In

    Request Example

    cURL
    curl -X GET https://api.box.com/2.0/files/12345/thumbnail.png \
         -H "Authorization: Bearer <ACCESS_TOKEN>"
    .NET
    Stream thumbnailContents = await client.FilesManager.GetThumbnailAsync("11111", maxWidth: 160, maxHeight: 160);
    Python
    file_id = '11111'
    
    thumbnail = client.file(file_id).get_thumbnail(extension='jpg')
    Node
    client.files.getThumbnail('12345')
    	.then(thumbnailInfo => {
    		if (thumbnailInfo.location) {
    			// fetch thumbnail from location URL
    		} else if (thumbnailInfo.file) {
    			// use response.file Buffer contents as thumbnail
    		} else {
    			// no thumbnail available
    		}
    	});