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
ParameterDescription
fileId
string
requiredThe file's id, as Get File and the folder listings return it.
Query parameters
ParameterDescription
library
string
optionalOne of sharepoint, msteams, google, onedrive, box, dropbox, cloudfiles, s3, azure, hubspot, azurefiles, sftp
driveId
string
optionalDrive Id. Required when library is sharepoint or msteams.
Header parameters
ParameterDescription
Authorization
string
requiredBearer API_Key. See Authentication.
Content-Type
string
optionalapplication/json, when you send a body.
Body parameters
ParameterDescription
permissions
array of strings
optionalWhat the viewer can do, from the values below. Left out, the preview shows the file name and no buttons.

Permissions

ValueWhat it turns on
show_headerThe bar above the file with its name and buttons. Without it no buttons show, whatever else you grant.
downloadThe Download button.
printThe Print button.
open_inThe Open in menu, for example to open the file in SharePoint or in a desktop app.
editLets 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"]
  }'
const response = await fetch(
  "https://api.cloudfiles.io/v1/files/{fileId}/preview?library=sharepoint&driveId={driveId}",
  {
    method: "POST",
    headers: {
      Authorization: "Bearer API_Key",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ permissions: ["show_header", "download", "print"] }),
  }
);
const { url, expiresAt } = await response.json();
console.log(url, expiresAt);
require "uri"
require "json"
require "net/http"

url = URI("https://api.cloudfiles.io/v1/files/{fileId}/preview?library=sharepoint&driveId={driveId}")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer API_Key"
request["Content-Type"] = "application/json"
request.body = JSON.dump({ permissions: ["show_header", "download", "print"] })

response = https.request(request)
puts JSON.parse(response.read_body)["url"]
import requests

response = requests.post(
    "https://api.cloudfiles.io/v1/files/{fileId}/preview",
    params={"library": "sharepoint", "driveId": "{driveId}"},
    headers={"Authorization": "Bearer API_Key"},
    json={"permissions": ["show_header", "download", "print"]},
)
print(response.json()["url"])

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

StatusWhat it means
400permissions is not a list or has a value not in the table above, or fileId is a folder.
403The API key is missing or unknown.
404The file does not exist in that library or drive.