curl --request GET \
--url https://api.trycomp.ai/v1/attachments/{attachmentId}/preview \
--header 'X-API-Key: <api-key>'const options = {method: 'GET', headers: {'X-API-Key': '<api-key>'}};
fetch('https://api.trycomp.ai/v1/attachments/{attachmentId}/preview', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.trycomp.ai/v1/attachments/{attachmentId}/preview"
headers = {"X-API-Key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text){
"kind": "html",
"name": "q3-access-review.xlsx",
"url": "https://bucket.s3.amazonaws.com/path/to/file.pdf?signature=...",
"contentType": "application/pdf",
"expiresIn": 900,
"html": "<!doctype html><html>...</html>",
"message": "This file type cannot be previewed. Download it to review the contents."
}{
"message": "Attachment not found"
}Preview an attachment inline | Comp AI API
Returns an attachment in a form the browser can display: an inline signed URL for PDFs, images and text files, or HTML converted from Word and Excel. Use it.
curl --request GET \
--url https://api.trycomp.ai/v1/attachments/{attachmentId}/preview \
--header 'X-API-Key: <api-key>'const options = {method: 'GET', headers: {'X-API-Key': '<api-key>'}};
fetch('https://api.trycomp.ai/v1/attachments/{attachmentId}/preview', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.trycomp.ai/v1/attachments/{attachmentId}/preview"
headers = {"X-API-Key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text){
"kind": "html",
"name": "q3-access-review.xlsx",
"url": "https://bucket.s3.amazonaws.com/path/to/file.pdf?signature=...",
"contentType": "application/pdf",
"expiresIn": 900,
"html": "<!doctype html><html>...</html>",
"message": "This file type cannot be previewed. Download it to review the contents."
}{
"message": "Attachment not found"
}Authorizations
API key for authentication
Path Parameters
Unique attachment identifier
"att_abc123def456"
Response
Preview generated successfully
How to render the preview: url (inline signed URL), html (converted document), or unsupported.
url, html, unsupported "html"
Original file name of the attachment
"q3-access-review.xlsx"
Signed URL that renders inline in the browser. Present when kind is url.
"https://bucket.s3.amazonaws.com/path/to/file.pdf?signature=..."
Content type the signed URL is served with. Present when kind is url.
"application/pdf"
Seconds until the signed URL expires. Present when kind is url.
900
Self-contained HTML document rendering the file. Present when kind is html.
"<!doctype html><html>...</html>"
Why the file cannot be previewed. Present when kind is unsupported.
"This file type cannot be previewed. Download it to review the contents."
Was this page helpful?

