The link works for 15 minutes if it is not opened. Once open, the preview stays active while it is on screen, for up to 8 hours. Anyone with the link can view the file until then, so create a new link each time a user opens a file and do not share it further.
Path parameters
| Parameter | Description | |
|---|---|---|
fileIdstring |
required | The file's id, as Get File and the folder listings return it. |
Query parameters
| Parameter | Description | |
|---|---|---|
librarystring |
optional | One of sharepoint, msteams, google, onedrive, box, dropbox, cloudfiles, s3, azure, hubspot, azurefiles, sftp |
driveIdstring |
optional | Drive Id. Required when library is sharepoint or msteams. |
Header parameters
| Parameter | Description | |
|---|---|---|
Authorizationstring |
required | Bearer API_Key. See Authentication. |
Content-Typestring |
optional | application/json, when you send a body. |
Body parameters
| Parameter | Description | |
|---|---|---|
permissionsarray of strings |
optional | What the viewer can do, from the values below. Left out, the preview shows the file name and no buttons. |
Permissions
| Value | What it turns on |
|---|---|
show_header | The bar above the file with its name and buttons. Without it no buttons show, whatever else you grant. |
download | The Download button. |
print | The Print button. |
open_in | The Open in menu, for example to open the file in SharePoint or in a desktop app. |
edit | Lets the viewer annotate a PDF and save it as a new version of the same file, saved as the user the API key belongs to. |
Any other value is refused with 400. An empty list turns everything off.
Example request
curl --request POST 'https://api.cloudfiles.io/v1/files/{fileId}/preview?library=sharepoint&driveId={driveId}' \ --header 'Authorization: Bearer API_Key' \ --header 'Content-Type: application/json' \ --data '{ "permissions": ["show_header", "download", "print"] }'
Response body
201 Created. Send the user to url or load it in an iframe. expiresAt is when the link stops working if it has not been opened.
{
"url": "https://salesforce.cloudfiles.io/preview/files?code=3f9c2a7d4e1b8c6a0d5f2e9b7a1c4d8e",
"expiresAt": "2026-12-07T10:15:00.000Z"
}Errors
| Status | What it means |
|---|---|
| 400 | permissions is not a list or has a value not in the table above, or fileId is a folder. |
| 403 | The API key is missing or unknown. |
| 404 | The file does not exist in that library or drive. |