curl --request PUT \
--url 'https://sandbox.circularo.com/api/v1/files/{hash}/preview?token='import requests
url = "https://sandbox.circularo.com/api/v1/files/{hash}/preview?token="
response = requests.put(url)
print(response.text)const options = {method: 'PUT'};
fetch('https://sandbox.circularo.com/api/v1/files/{hash}/preview?token=', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://sandbox.circularo.com/api/v1/files/{hash}/preview?token=",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://sandbox.circularo.com/api/v1/files/{hash}/preview?token="
req, _ := http.NewRequest("PUT", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://sandbox.circularo.com/api/v1/files/{hash}/preview?token=")
.asString();require 'uri'
require 'net/http'
url = URI("https://sandbox.circularo.com/api/v1/files/{hash}/preview?token=")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
response = http.request(request)
puts response.read_body{
"content": "p7kd2m4s9xq1v8b3n6c0z5w2e7r4t1y9u3i6o8a2s5d7f0g4h1j3k6l9z2x5c8v0b4",
"failureReason": "conversion_error",
"hash": "as0ia4jdqecwq0u5s1omd9krs4u244ic2n2545kyhyat9imkwyg1bgec16r94tth",
"status": "failed_irrecoverable",
"statusDate": "2023-11-07T05:31:56Z"
}{
"status": 400,
"type": "VALIDATION:INPUT_INVALID",
"message": "Invalid input",
"requestId": "3fa85f6457174562b3fc2c963f66afa6"
}{
"status": 401,
"type": "AUTH:UNAUTHORIZED",
"message": "Authentication failed",
"requestId": "3fa85f6457174562b3fc2c963f66afa6"
}{
"status": 403,
"type": "AUTH:ACCESS_DENIED",
"message": "Access denied",
"requestId": "3fa85f6457174562b3fc2c963f66afa6"
}{
"status": 404,
"type": "RESOURCE:NOT_FOUND",
"message": "Resource not found",
"requestId": "3fa85f6457174562b3fc2c963f66afa6"
}Request the PDF preview of a file
PUT /files/{hash}/preview
Makes sure an office file - a text document, a spreadsheet or a presentation - has a PDF preview, and answers with where the preview stands. It works for any file the caller may read, including one that is not attached to anything yet or sits in a draft; once the file becomes part of a document, the document’s file entry takes the preview over without converting the file again.
The preview is generated in the background. A file without one starts generating it; a file whose last attempt failed for a reason that may pass is tried again once the retry cooldown, which grows with every failed attempt, is over; anything else is left alone, so the call is safe to repeat.
The call waits for the preview: it answers as soon as the preview is finished or has failed. A preview that takes longer than the server lets a request wait is answered with status in_progress, and the call is then simply made again. A final status is finished, with content identifying the PDF, which is then downloaded like any other file, or one of the failed states.
Token authorization: Authorize using a token — either a session token obtained from login or an API key — to call this endpoint.
curl --request PUT \
--url 'https://sandbox.circularo.com/api/v1/files/{hash}/preview?token='import requests
url = "https://sandbox.circularo.com/api/v1/files/{hash}/preview?token="
response = requests.put(url)
print(response.text)const options = {method: 'PUT'};
fetch('https://sandbox.circularo.com/api/v1/files/{hash}/preview?token=', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://sandbox.circularo.com/api/v1/files/{hash}/preview?token=",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://sandbox.circularo.com/api/v1/files/{hash}/preview?token="
req, _ := http.NewRequest("PUT", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://sandbox.circularo.com/api/v1/files/{hash}/preview?token=")
.asString();require 'uri'
require 'net/http'
url = URI("https://sandbox.circularo.com/api/v1/files/{hash}/preview?token=")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
response = http.request(request)
puts response.read_body{
"content": "p7kd2m4s9xq1v8b3n6c0z5w2e7r4t1y9u3i6o8a2s5d7f0g4h1j3k6l9z2x5c8v0b4",
"failureReason": "conversion_error",
"hash": "as0ia4jdqecwq0u5s1omd9krs4u244ic2n2545kyhyat9imkwyg1bgec16r94tth",
"status": "failed_irrecoverable",
"statusDate": "2023-11-07T05:31:56Z"
}{
"status": 400,
"type": "VALIDATION:INPUT_INVALID",
"message": "Invalid input",
"requestId": "3fa85f6457174562b3fc2c963f66afa6"
}{
"status": 401,
"type": "AUTH:UNAUTHORIZED",
"message": "Authentication failed",
"requestId": "3fa85f6457174562b3fc2c963f66afa6"
}{
"status": 403,
"type": "AUTH:ACCESS_DENIED",
"message": "Access denied",
"requestId": "3fa85f6457174562b3fc2c963f66afa6"
}{
"status": 404,
"type": "RESOURCE:NOT_FOUND",
"message": "Resource not found",
"requestId": "3fa85f6457174562b3fc2c963f66afa6"
}Authorizations
Path Parameters
Response
Returns where the preview of the file stands.
Why the last attempt to generate the preview failed; empty unless it failed.
conversion_error: The converter could not read the file, for example because it is damaged or its content does not match its type.file_too_large: The file is larger than the biggest file a PDF preview is generated for.service_error: The conversion service failed or could not be reached.timeout: The conversion did not finish in time.
conversion_error, file_too_large, service_error, timeout, null Where generating the preview stands.
failed_irrecoverable: The file cannot be turned into a PDF preview - its content was rejected or it is too large - and it is not tried again.failed_recoverable: The last attempt failed for a reason that may pass, such as a timeout or an unavailable conversion service. The next request for the preview tries again once the retry cooldown has passed.finished: The PDF preview is ready andcontentidentifies it.in_progress: The PDF preview is being generated.
failed_irrecoverable, failed_recoverable, finished, in_progress, null