CloudPDF API Reference
CloudPDF is a cloud-based PDF management service. It enables users to upload, store, secure, track and deliver PDFs for your website.
In this API reference we will explain how to interact with our Server API. You will need this API if you want to upload or change, for example, documents on CloudPDF through your application.
If you are looking for information on implementing the client side viewer please follow the viewer SDK documentation.
Don't hesitate to contact us through the chat in the right bottom corner if you have questions.
Base URL
All API requests should be done to our base URL
https://api.cloudpdf.io
Authentication
CloudPDF uses API keys to allow access to the API. You can find the API key in your Dashboard → Settings → API Keys.
CloudPDF expects the API key to be included in all API requests to the server in a header that looks like the following:
X-Authorization: API_KEY
To verify if your authentication and request is valid you can use this endpoint. If the authorization is successful it will respond with the message "Authorized"
There are two methods of authentication for the API. They are simple authentication and signed authentication.
{"message": "Authorized","organizationName": "ACME Company LTD"}
Simple authentication
You can find the simple authentication API key in your Dashboard → Settings → API Keys.
Copy the API key with the name Simple API Key
You can use this API key directly in the X-Authorization header. Please be aware that the API is exposed on every API request - make sure you don't use Simple authentication on the client side.
If you don't want the API key to be exposed on every API request we suggest you to use Signed authentication.
Signed authentication
You can find the signed authentication API keys in your Dashboard → Settings → API Keys.
Copy the API keys with the name Secret Signing Key and Cloud Name.
We use JWT (JSON Web Tokens) to generate a signed token. You can learn on how to generate a JWT in your coding language here: https://jwt.io/.
Make sure to include the Cloud Name as kid in the JWT header.
You should sign the JWT header and payload with the Secret Signing Key and include the full JWT token in the X-Authorization header.
{"alg": "HS256","typ": "JWT","kid": "pXBZfeF1I" // add your cloud name here}
{"function": "APIV2GetAuth", // add the function name here"params": {}, // include all the parameters of the request here"iat": 1652954293,"exp": 1662997493}
Account
To check your account status at any time you can use this endpoint. It will respond with your quota levels and current usage levels. Usage resets every 30 days.
{"organizationName": "ACME Company LTD","plan": "Professional","allowedMonthlyUploads": 100,"usedMonthlyUploads": 36,"allowedMonthlyViews": 1999,"usedMonthlyViews": 130,"allowedStorage": 1073741824,"usedStorage": 95751557}
Errors
The CloudPDF API uses the following status / error codes.
200 | OK |
202 | Accepted -- Your request is has been accepted for processing |
400 | Bad Request -- Your request is invalid |
401 | Unauthorized -- Your API key is wrong |
402 | Payment Required -- Your have run out of your plans quota. |
403 | Forbidden -- Unauthorized request. |
404 | Not Found -- The specified resource can not be found |
Documents
Documents are the main resource on CloudPDF.
The document object
These are the attributes of the document object
Attributes
The identifier of the document
The name of the document
Description of the document
The PDF file
The identifier of the file
The current status of the file; WaitingUpload, Processing, Failed, Completed
A pre-signed URL where you can upload your PDF to. This field will only be populated on creation of the document.
These are the default document permissions
Options are: "NotAllowed", "Allowed", "EmailRequired"
Is search allowed in the document
Is selection allowed in the document
Require info to open a document. Set as an array with possible options: "email", "name", "organization", "phone"
If true, the document is publicly accessible. If false the document is not publicly accessible.
{"id": "5e6665b0-c276-494f-abfc-01e7b1151461","name": "test.pdf","description": "test document","file": {"id": "804ac929-7c46-404f-a166-72c6b3cea049","status": "WaitingUpload","uploadUrl": "https://cloudpdf-document-dev.s3.amazonaws.com/804ac929-7c46-404f-a166-72c6b3cea049.pdf?Content-Type=application%2Fpdf&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJVXNAZ5KS7UKHXEA%2F20220516%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20220516T214206Z&X-Amz-Expires=900&X-Amz-Signature=0fe718742a0bab2cff698f1c16c47d1c27fed63afbf5249b89d736e2d12dd4d6&X-Amz-SignedHeaders=host","thumbnail": null,"size": null},"defaultPermissions": {"download": "Allowed","search": true,"selection": true,"info": null,"public": true}}
Create a document
Before you can upload a PDF to CloudPDF you must create a new document.
The server will return a pre-signed upload URL where you can upload your PDF file.
After uploading the file you must notify our server that the upload is finished and we will process the PDF by our PDF engine.
Parameters
The name of the PDF you want to upload.
Description of the PDF you want to upload.
The ID of the folder you want to create the document in.
Set tags on the document to easily filter and search documents later
Set the default permissions for this document. If none are given we use the default permissions of the organization. You can change the default permissions of the organization in the Dashboard → Settings → Upload Settings.
Options are: "NotAllowed", "Allowed", "EmailRequired"
Is search allowed in the document
Is selection allowed in the document
Require info to open a document. Set as an array with possible options: "email", "name", "organization", "phone"
If true, the document is publicly accessible. If false the document is not publicly accessible.
var data = {"name" : "sales_document.pdf","parentId" : "ac3429c6-07c1-4123-89e2-0acb558b74b7","tags": ["sales"],"defaultPermissions": {"search": false,"selection": false,"public": true,"download": "NotAllowed""info": ["email"]}}fetch('https://api.cloudpdf.io/v2/documents', {method: 'POST',body: JSON.stringify(data),headers: {'Content-Type' : 'application/json','X-Authorization' : API_KEY}})
Retrieve a document
Parameters
The identifier of the document
fetch(`https://api.cloudpdf.io/v2/documents/${ID}`, {method: 'GET',headers: {'X-Authorization' : API_KEY}})
Update a document
Parameters
The identifier of the document you want to update
A description of the document
The ID of the folder you want to move the document to
Tags to easily find this document later
The default permissions for this document. If none are given we use the default permissions of the organization. You can change the default permissions of the organization in the Dashboard → Settings → Upload Settings.
Options are: "NotAllowed", "Allowed", "EmailRequired"
Is search allowed in the document
Is selection allowed in the document
Require info to open a document. Set as an array with possible options: "email", "name", "organization", "phone"
If true, the document is publicly accessible. If false the document is not publicly accessible.
var data = {"name": "test.pdf","description": "test document","tags": ["test", "test1"],"defaultPermissions": {"info": ["email"],"download": "NotAllowed","public": true,"selection": false,"search": true}}fetch(`https://api.cloudpdf.io/v2/documents/${ID}`, {method: 'PUT',body: JSON.stringify(data),headers: {'Content-Type' : 'application/json','X-Authorization' : API_KEY}})
Delete a document
Parameters
The identifier of the document
fetch(`https://api.cloudpdf.io/v2/documents/${ID}`, {method: 'DELETE',headers: {'X-Authorization' : API_KEY}})
Create new file version
When you have a new version of your PDF. You can upload it to an already existing document without having to create a new one.
Parameters
The document identifier.
The name of the PDF you want to upload.
var data = {"name" : "sales_document.pdf"}fetch(`https://api.cloudpdf.io/v2/documents/${ID}/files`, {method: 'POST',body: JSON.stringify(data),headers: {'Content-Type' : 'application/json','X-Authorization' : API_KEY}})
Upload file
After you create a document you will receive an Amazon signed URL where you can upload your PDF file. We suggest to upload the file directly from the clients browser to spare your server load. You can look at the example using Axios in TypeScript.
When the file upload is finished you must notify our server.
import axios from 'axios';axios.put(signedUploadURL, file, {headers: {"Content-Type": "application/pdf"},onUploadProgress: (e) => {// Show progressconst percentComplete = Math.round((e.loaded * 100) / e.total);console.log(percentComplete);},});
Upload file completed
After uploading your file to Amazon S3 you must notify our server on this endpoint that the upload is complete. On a successful request the status of the document will change from "WaitingUpload" to "Processing".
You can poll the GET endpoint for status updates or use a webhook to find out if your document has completed processing by our PDF engine.
Parameters
The identifier of the document
The identifier of the file
Notify the server that you uploaded the PDF file to the Amazon S3 bucket
var data = {"uploadCompleted" : true}fetch(`https://api.cloudpdf.io/v2/documents/${ID}/files/${FILEID}`, {method: 'PATCH',body: JSON.stringify(data),headers: {'Content-Type' : 'application/json','X-Authorization' : API_KEY}})
Retrieve a file
Parameters
The identifier of the document
The identifier of the file
fetch(`https://api.cloudpdf.io/v2/documents/${ID}/files/${FILEID}`, {method: 'GET',headers: {'X-Authorization' : API_KEY}})
Viewer document
This is the endpoint the CloudPDF viewer calls to render the document. In general we do not recommend using this endpoint. We put it in the API reference to give you clarity on how to generate the signed JWT token.
You can only call this endpoint with a signed token or without token for public documents.
This endpoint will not allow simple token authentication.
Parameters
The identifier of the document
Options are: "NotAllowed", "Allowed", "EmailRequired". This parameter only has effect in combination with a signed JWT token. If no JWT token is included in the request, the default permissions will be returned.
Is search allowed in the document. This parameter only has effect in combination with a signed JWT token. If no JWT token is included in the request, the default permissions will be returned.
Is selection allowed in the document. This parameter only has effect in combination with a signed JWT token. If no JWT token is included in the request, the default permissions will be returned.
Require info to open document. Should be send in an array. Possible options are: email, phone, organization, name. This parameter only has effect in combination with a signed JWT token. If no JWT token is included in the request, the default permissions will be returned.
var data = {"search": false,"selection": true,"download": "NotAllowed","info": ["email"]}fetch(`https://api.cloudpdf.io/v2/viewer/documents/${ID}`, {method: 'GET',body: JSON.stringify(data),headers: {'Content-Type' : 'application/json','X-Authorization' : SIGNED_JWT_TOKEN}})
Generate viewer token
You can find the signed authentication API keys in the Dashboard → Settings → API Keys.
Copy the API keys with the name Secret Signing Key and Cloud Name.
We use JWT (JSON Web Tokens) to generate a signed token. You can learn how to generate a JWT in your coding language here: https://jwt.io/.
Make sure to include the Cloud Name as kid in the JWT header.
You should sign the JWT header and payload with the Secret Signing Key and include the full JWT token in the X-Authorization header.
{"alg": "HS256","typ": "JWT","kid": "pXBZfeF1I" // add your cloud name here}
{"function": "APIGetDocument","params": {"id": "cff8e851-69f9-4e77-ae91-749ef48a889f","download": "NotAllowed","selection": true,"search": false},"iat": 1652954293,"exp": 1662997493}
Webhooks
Webhooks are used to notify your system of specific CloudPDF events.
POST | /v2/webhooks |
GET | /v2/webhooks/:id |
PUT | /v2/webhooks/:id |
DELETE | /v2/webhooks/:id |
GET | /v2/webhooks |
The webhook object
Attributes
The identifier of the webhook
The name of the webhook
This is the secret that will be sent with the request as a query string. You can use it to protect your webhook endpoint.
If false the webhook is disabled, if true the webhook is active.
The URL that the webhook will request when an event is triggered
The headers that will be sent with the webhook request
The events that will trigger the webhook URL
The name of the event
The slug of the event
{"id": "1","name": "Test","secret": "","enabled": true,"url": "https://yourendpoint.com/webhook-event","headers": {},"events": [{"name": "A document is updated","slug": "document.updated"}]}
Create a webhook
Parameters
The name of your webhook for your own reference
The URL that the webhook should trigger on a event
Optional secret that you can use to secure the webhook endpoint
An array of events. Possible values are: document.created, document.updated, collection.created, collection.updated, tracker.new, lead.new, file.processed
Object of header keys and values that will be sent as request header on the webhook request
var data = {"name": "Test webhook 2","url": "https://yourdomain.com/webhook-endpoint","secret": "a secret password","events": ["document.created", "document.updated", "collection.created"]}fetch('https://api.cloudpdf.io/v2/webhooks', {method: 'POST',body: JSON.stringify(data),headers: {'Content-Type' : 'application/json','X-Authorization' : API_KEY}})
Retrieve a webhook
Parameters
The identifier of the webhook
fetch(`https://api.cloudpdf.io/v2/webhooks/${ID}`, {method: 'GET',headers: {'X-Authorization' : API_KEY}})
Update a webhook
Parameters
The identifier of the webhook you want to update
The name of the webhook for your own reference
The URL that the webhook should trigger on a event
Optional secret that you can use to secure the webhook endpoint
An array of events on which the webhook will be triggered. Possible values are: document.created, document.updated, collection.created, collection.updated, tracker.new, lead.new
Object of header keys and values that will be sent as request header on the webhook request
var data = {"name": "Test webhook 2","url": "https://yourdomain.com/webhook-endpoint","secret": "a secret password","events": ["document.created", "document.updated", "collection.created"]}fetch(`https://api.cloudpdf.io/v2/webhooks/${ID}`, {method: 'PUT',body: JSON.stringify(data),headers: {'Content-Type' : 'application/json','X-Authorization' : API_KEY}})
Delete a webhook
Parameters
The identifier of the webhook you want to delete
fetch(`https://api.cloudpdf.io/v2/webhooks/${ID}`, {method: 'DELETE',headers: {'X-Authorization' : API_KEY}})
List all webhooks
fetch(`https://api.cloudpdf.io/v2/webhooks`, {method: 'GET',headers: {'X-Authorization' : API_KEY}})