Link Search Menu Expand Document

Upload Files

Files Storage

You can upload files as temporary files into PDF.co. Temporary files are stored for 1 hour by default and then auto removed.

To store files permanently (pdf templates, images you want to re-use) please use PDF.co built-in files storage at https://app.pdf.co/files instead.

You can also use 3rd party cloud services:

  • Dropbox: you can use public link to a file from Dropbox
  • Google Drive: you can use link to a file that was shared as anyone with a link
  • Google Docs/Sheets/Slides: you can use a link to a document in Google Docs that was shared as anyone with a link
  • Any other cloud service that can store a file and provide a link to uploaded file.

IMPORTANT NOTE FOR GOOGLE DRIVE/DOCS users: free Google Drive/Docs limits number of requests to their files. If you use link to file or document from Google Drive or Google Drive then make sure you have no more than 5-10 requests per minute. Otherwise Google Drive returns no file or error page.

Temporary Files Upload

You can upload temporary files up to 2GB in size. Please note that to process these files you should use async=true mode with data extraction and tools endpoints along with /job/check to check status of background jobs you create.

Steps to Upload File:

1) First, call /file/upload/get-presigned-url. It will generate link for uploading (presignedUrl) and final link (url) 2) Now send your file to the presignedUrl link using PUT method within next 30 minutes. 3) Oncce finished, use url to access the file you have just uploaded.

Note: all uploaded files are considered to be temporary files and are automatically permanently removed after 1 hour.

Status Errors

CodeDescription
200The request has succeeded
400bad input parameters
401unauthorized
403not enough credits
405Timeout error. To process large documents or files please use asynchronous mode ( set async parameter to true) and then check the status using /job/check endpoint. If file contains many pages then specify a page range using pages parameter. The number of pages of the document can be obtained using the endpoint /pdf/info

Example: Uploading a Temporary File

Sample Request:

! Don’t forget to set x-api-key url param or http header param (preferred) to API key, get yours here

GET
https://api.pdf.co/v1/file/upload/get-presigned-url?name=test.pdf&encrypt=true

200
{
    "presignedUrl": "https://pdf-temp-files.s3-us-west-2.amazonaws.com/28e191b14f3a4f43b16fcef1d53d191e/test.pdf?X-Amz-Expires=900&....",
    "url": "https://pdf-temp-files.s3-us-west-2.amazonaws.com/28e191b14f3a4f43b16fcef1d53d191e/test.pdf?X-Amz-Expires=....",
    "error": false,
    "status": 200,
    "name": "test.pdf",
    "remainingCredits": 93574
}

PUT
https://pdf-temp-files.s3-us-west-2.amazonaws.com/28e191b14f3a4f43b16fcef1d53d191e/test.pdf?X-Amz-Expires=900&....
--form 'file=@/path/to/file'

200
{
}

Now you can access your file using link from "url" param to from the first step.

Available methods

[GET] /file/upload/get-presigned-url (GET generate secure URL for upload)

Description: This method generates links to upload your local file to. Use this presignedUrl from the response to upload your file. Once you upload your file to this presignedUrl using PUT, you can use url link to access the uploaded file.

With this method you can upload files up to 2GB in size. Please note that to process these files you should use async=true mode with data extraction and tools endpoints along with /job/check to check status of background jobs you create.

Steps to Upload File:

  • First, call /file/upload/get-presigned-url. It will generate link for uploading (presignedUrl) and final link (url)
  • Now send your file to the presignedUrl link using PUT method within next 30 minutes.
  • Oncce finished, use url to access the file you have just uploaded.

Important: all uploaded files are considered to be temporary files and are automatically permanently removed after 1 hour.

Status Errors

CodeDescription
200The request has succeeded
400bad input parameters
401unauthorized
403not enough credits
405Timeout error. To process large documents or files please use asynchronous mode ( set async parameter to true) and then check the status using /job/check endpoint. If file contains many pages then specify a page range using pages parameter. The number of pages of the document can be obtained using the endpoint /pdf/info

Example

Sample Request:

! Don’t forget to set x-api-key url param or http header param (preferred) to API key, get yours here

GET
https://api.pdf.co/v1/file/upload/get-presigned-url?name=test.pdf&encrypt=true

200
{
    "presignedUrl": "https://pdf-temp-files.s3-us-west-2.amazonaws.com/28e191b14f3a4f43b16fcef1d53d191e/test.pdf?X-Amz-Expires=900&....",
    "url": "https://pdf-temp-files.s3-us-west-2.amazonaws.com/28e191b14f3a4f43b16fcef1d53d191e/test.pdf?X-Amz-Expires=....",
    "error": false,
    "status": 200,
    "name": "test.pdf",
    "remainingCredits": 93574
}

PUT
https://pdf-temp-files.s3-us-west-2.amazonaws.com/28e191b14f3a4f43b16fcef1d53d191e/test.pdf?X-Amz-Expires=900&....
--form 'file=@/path/to/file'

200
{
}

Now you can access your file using link from "url" param to from the first step.

Description

  • Method: GET
  • URL: /v1/file/upload/get-presigned-url

Query parameters

  • name: test.pdf ,* name: test.pdf
  • encrypt: true

Body payload

keyvaluedescriptiondisabled
x-api-key Optional. Please use http headers instead when possible because passing your API key as parameter for POST or GET is not secure and is for legacy app compatibility only. 
true   

Example responses

/file/upload/get-presigned-url
{
    "presignedUrl": "https://pdf-temp-files.s3-us-west-2.amazonaws.com/0c72bf56341142ba83c8f98b47f14d62/test.pdf?X-Amz-Expires=900&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIZJDPLX6D7EHVCKA/20200302/us-west-2/s3/aws4_request&X-Amz-Date=20200302T143951Z&X-Amz-SignedHeaders=host&X-Amz-Signature=8650913644b6425ba8d52b78634698e5fc8970157d971a96f0279a64f4ba87fc",
    "url": "https://pdf-temp-files.s3-us-west-2.amazonaws.com/0c72bf56341142ba83c8f98b47f14d62/test.pdf?X-Amz-Expires=3600&x-amz-security-token=FwoGZXIvYXdzEGgaDA9KaTOXRjkCdCqSTCKBAW9tReCLk1fVTZBH9exl9VIbP8Gfp1pE9hg6et94IBpNamOaBJ6%2B9Vsa5zxfiddlgA%2BxQ4tpd9gprFAxMzjN7UtjU%2B2gf%2FKbUKc2lfV18D2wXKd1FEhC6kkGJVL5UaoFONG%2Fw2jXfLxe3nCfquMEDo12XzcqIQtNFWXjKPWBkQEvmii4tfTyBTIot4Na%2BAUqkLshH0R7HVKlEBV8btqa0ctBjwzwpWkoU%2BF%2BCtnm8Lm4Eg%3D%3D&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIA4NRRSZPHEGHTOA4W/20200302/us-west-2/s3/aws4_request&X-Amz-Date=20200302T143951Z&X-Amz-SignedHeaders=host;x-amz-security-token&X-Amz-Signature=243419ac4a9a315eebc2db72df0817de6a261a684482bbc897f0e7bb5d202bb9",
    "error": false,
    "status": 200,
    "name": "test.pdf",
    "remainingCredits": 98145
}
Generate URL for upload: /file/upload/get-presigned-url
{
    "presignedUrl": "https://pdf-temp-files.s3-us-west-2.amazonaws.com/63f7f641a3144f84ac209b4f514bc0df/myFile.png?X-Amz-Expires=900&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIZJDPLX6D7EHVCKA/20200716/us-west-2/s3/aws4_request&X-Amz-Date=20200716T091225Z&X-Amz-SignedHeaders=host&X-Amz-Signature=14d3eb91305d96804deccb6985cbbd4552705f5ddb2144b901a97c8e7abc1ac3",
    "url": "https://pdf-temp-files.s3-us-west-2.amazonaws.com/63f7f641a3144f84ac209b4f514bc0df/myFile.png?X-Amz-Expires=3600&x-amz-security-token=FwoGZXIvYXdzECMaDC5PzTA618EQiHoskyKBAeYQcVKbK%2B0F5nnjBV6MKbPNvueaFlSBSPxPi31BdtFzw1jAIXjAvATkBwTPRx%2FVwhszDtYQRVkbhsZF6HLotVUedrcdGHOrsWV5DpN2xKgnX7xRcJrvUu0wieaJHDmHzFL1eNzFwj2927L%2BtadEfmz1a0SiEImJZujcLF78lJZ5mSj7s8D4BTIok4Xja8wyqnBBp2EOcZw8qrUxeR7Ufd0aw4bf7Z1Cur1f0PFg8hlrYQ%3D%3D&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIA4NRRSZPHAPA4HUJS/20200716/us-west-2/s3/aws4_request&X-Amz-Date=20200716T091225Z&X-Amz-SignedHeaders=host;x-amz-security-token&X-Amz-Signature=26e27b48c5284665914fdd981d7b0b5b6e70e64839f28621f3dc82256e492879",
    "error": false,
    "status": 200,
    "name": "myFile.png",
    "remainingCredits": 77779
}

Code Snippets

CURL
curl --location --request GET 'https://api.pdf.co/v1/file/upload/get-presigned-url?name=test.pdf&encrypt=true' \
--header 'x-api-key: '
JavaScript
var myHeaders = new Headers();
myHeaders.append("x-api-key", "");

var formdata = new FormData();

var requestOptions = {
	method: 'GET',
	headers: myHeaders,
	body: formdata,
	redirect: 'follow'
};

fetch("https://api.pdf.co/v1/file/upload/get-presigned-url?name=test.pdf&encrypt=true", requestOptions)
	.then(response => response.text())
	.then(result => console.log(result))
	.catch(error => console.log('error', error));
NodeJs
var request = require('request');
var options = {
	'method': 'GET',
	'url': 'https://api.pdf.co/v1/file/upload/get-presigned-url?name=test.pdf&encrypt=true',
	'headers': {
		'x-api-key': ''
	},
	formData: {

	}
};
request(options, function (error, response) {
	if (error) throw new Error(error);
	console.log(response.body);
});

PHP
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
	CURLOPT_URL => 'https://api.pdf.co/v1/file/upload/get-presigned-url?name=test.pdf&encrypt=true',
	CURLOPT_RETURNTRANSFER => true,
	CURLOPT_ENCODING => '',
	CURLOPT_MAXREDIRS => 10,
	CURLOPT_TIMEOUT => 0,
	CURLOPT_FOLLOWLOCATION => true,
	CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
	CURLOPT_CUSTOMREQUEST => 'GET',
	CURLOPT_HTTPHEADER => array(
		'x-api-key: '
	),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Java
import java.io.*;
import okhttp3.*;
public class main {
	public static void main(String []args) throws IOException{
		OkHttpClient client = new OkHttpClient().newBuilder()
			.build();
		Request request = new Request.Builder()
			.url("https://api.pdf.co/v1/file/upload/get-presigned-url?name=test.pdf&encrypt=true")
			.method("GET", null)
			.addHeader("x-api-key", "")
			.build();
		Response response = client.newCall(request).execute();
		System.out.println(response.body().string());
	}
}

C#
using System;
using RestSharp;
namespace HelloWorldApplication {
	class HelloWorld {
		static void Main(string[] args) {
			var client = new RestClient("https://api.pdf.co/v1/file/upload/get-presigned-url?name=test.pdf&encrypt=true");
			client.Timeout = -1;
			var request = new RestRequest(Method.GET);
			request.AddHeader("x-api-key", "");
			request.AlwaysMultipartFormData = true;
			IRestResponse response = client.Execute(request);
			Console.WriteLine(response.Content);
		}
	}
}

Python
import requests

url = "https://api.pdf.co/v1/file/upload/get-presigned-url?name=test.pdf&encrypt=true"

payload={}
files={}
headers = {
	'x-api-key': ''
}

response = requests.request("GET", url, headers=headers, data=payload, files=files)

print(response.text)

Powershell
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("x-api-key", "")

$multipartContent = [System.Net.Http.MultipartFormDataContent]::new()
$body = $multipartContent

$response = Invoke-RestMethod 'https://api.pdf.co/v1/file/upload/get-presigned-url?name=test.pdf&encrypt=true' -Method 'GET' -Headers $headers -Body $body
$response | ConvertTo-Json

[PUT] PUT presignedUrl –formdata file=..

With this method you can upload files up to 2GB in size. Please note that to process these files you should use async=true mode with data extraction and tools endpoints along with /job/check to check status of background jobs you create.

Steps to Upload File:

  • First, call /file/upload/get-presigned-url. It will generate link for uploading (presignedUrl) and final link (url)
  • Now send your file to the presignedUrl link using PUT method within next 30 minutes.
  • Oncce finished, use url to access the file you have just uploaded.

Important: all uploaded files are considered to be temporary files and are automatically permanently removed after 1 hour.

Status Errors

CodeDescription
200The request has succeeded
400bad input parameters
401unauthorized
403not enough credits
405Timeout error. To process large documents or files please use asynchronous mode ( set async parameter to true) and then check the status using /job/check endpoint. If file contains many pages then specify a page range using pages parameter. The number of pages of the document can be obtained using the endpoint /pdf/info

Workflow

Sample Request:

! Don’t forget to set x-api-key url param or http header param (preferred) to API key, get yours here

Generate secure link where you will upload your file:
GET
https://api.pdf.co/v1/file/upload/get-presigned-url?name=test.pdf&encrypt=true

200
{
    "presignedUrl": "https://pdf-temp-files.s3-us-west-2.amazonaws.com/28e191b14f3a4f43b16fcef1d53d191e/test.pdf?X-Amz-Expires=900&....",
    "url": "https://pdf-temp-files.s3-us-west-2.amazonaws.com/28e191b14f3a4f43b16fcef1d53d191e/test.pdf?X-Amz-Expires=....",
}

Now all PUT to upload file to "presignedUrl" you've got:
https://pdf-temp-files.s3-us-west-2.amazonaws.com/28e191b14f3a4f43b16fcef1d53d191e/test.pdf?X-Amz-Expires=900&....
--form 'file=@/path/to/file'

200
{
}

Now your file is available via link from "url" param from the first step

Description

  • Method: PUT
  • URL: %3Cinsert%20presignedUrl%20generated%20by%20https://api.pdf.co/v1/file/upload/get-presigned-url%20%3E

Query parameters

No query parameters accepted.

Body payload

keyvaluedescriptiondisabled
x-api-key Optional. Please use http headers instead when possible because passing your API key as parameter for POST or GET is not secure and is for legacy app compatibility only. 
true   
fileLocal file to upload.file/Users/em/Downloads/logo.png

Example responses

/file/upload/get-presigned-url
{
    "presignedUrl": "https://pdf-temp-files.s3-us-west-2.amazonaws.com/0c72bf56341142ba83c8f98b47f14d62/test.pdf?X-Amz-Expires=900&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIZJDPLX6D7EHVCKA/20200302/us-west-2/s3/aws4_request&X-Amz-Date=20200302T143951Z&X-Amz-SignedHeaders=host&X-Amz-Signature=8650913644b6425ba8d52b78634698e5fc8970157d971a96f0279a64f4ba87fc",
    "url": "https://pdf-temp-files.s3-us-west-2.amazonaws.com/0c72bf56341142ba83c8f98b47f14d62/test.pdf?X-Amz-Expires=3600&x-amz-security-token=FwoGZXIvYXdzEGgaDA9KaTOXRjkCdCqSTCKBAW9tReCLk1fVTZBH9exl9VIbP8Gfp1pE9hg6et94IBpNamOaBJ6%2B9Vsa5zxfiddlgA%2BxQ4tpd9gprFAxMzjN7UtjU%2B2gf%2FKbUKc2lfV18D2wXKd1FEhC6kkGJVL5UaoFONG%2Fw2jXfLxe3nCfquMEDo12XzcqIQtNFWXjKPWBkQEvmii4tfTyBTIot4Na%2BAUqkLshH0R7HVKlEBV8btqa0ctBjwzwpWkoU%2BF%2BCtnm8Lm4Eg%3D%3D&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIA4NRRSZPHEGHTOA4W/20200302/us-west-2/s3/aws4_request&X-Amz-Date=20200302T143951Z&X-Amz-SignedHeaders=host;x-amz-security-token&X-Amz-Signature=243419ac4a9a315eebc2db72df0817de6a261a684482bbc897f0e7bb5d202bb9",
    "error": false,
    "status": 200,
    "name": "test.pdf",
    "remainingCredits": 98145
}
PUT Upload File PUT presignedUrl –formdata file=..

Code Snippets

CURL
curl --location --request PUT '<insert presignedUrl generated by https://api.pdf.co/v1/file/upload/get-presigned-url >' \
--header 'x-api-key: ' \
--form 'file=@"/Users/em/Downloads/logo.png"'
JavaScript
var myHeaders = new Headers();
myHeaders.append("x-api-key", "");

var formdata = new FormData();
formdata.append("file", fileInput.files[0], "logo.png");

var requestOptions = {
	method: 'PUT',
	headers: myHeaders,
	body: formdata,
	redirect: 'follow'
};

fetch("<insert presignedUrl generated by https://api.pdf.co/v1/file/upload/get-presigned-url >", requestOptions)
	.then(response => response.text())
	.then(result => console.log(result))
	.catch(error => console.log('error', error));
NodeJs
var request = require('request');
var fs = require('fs');
var options = {
	'method': 'PUT',
	'url': '<insert presignedUrl generated by https://api.pdf.co/v1/file/upload/get-presigned-url >',
	'headers': {
		'x-api-key': ''
	},
	formData: {
		'file': {
			'value': fs.createReadStream('/Users/em/Downloads/logo.png'),
			'options': {
				'filename': 'logo.png',
				'contentType': null
			}
		}
	}
};
request(options, function (error, response) {
	if (error) throw new Error(error);
	console.log(response.body);
});

PHP
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
	CURLOPT_URL => '%3Cinsert%20presignedUrl%20generated%20by%20https://api.pdf.co/v1/file/upload/get-presigned-url%20%3E',
	CURLOPT_RETURNTRANSFER => true,
	CURLOPT_ENCODING => '',
	CURLOPT_MAXREDIRS => 10,
	CURLOPT_TIMEOUT => 0,
	CURLOPT_FOLLOWLOCATION => true,
	CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
	CURLOPT_CUSTOMREQUEST => 'PUT',
	CURLOPT_POSTFIELDS => array('file'=> new CURLFILE('/Users/em/Downloads/logo.png')),
	CURLOPT_HTTPHEADER => array(
		'x-api-key: '
	),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Java
import java.io.*;
import okhttp3.*;
public class main {
	public static void main(String []args) throws IOException{
		OkHttpClient client = new OkHttpClient().newBuilder()
			.build();
		MediaType mediaType = MediaType.parse("text/plain");
		RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
			.addFormDataPart("file","logo.png",
				RequestBody.create(MediaType.parse("application/octet-stream"),
				new File("/Users/em/Downloads/logo.png")))
			.build();
		Request request = new Request.Builder()
			.url("<insert presignedUrl generated by https://api.pdf.co/v1/file/upload/get-presigned-url >")
			.method("PUT", body)
			.addHeader("x-api-key", "")
			.build();
		Response response = client.newCall(request).execute();
		System.out.println(response.body().string());
	}
}

C#
using System;
using RestSharp;
namespace HelloWorldApplication {
	class HelloWorld {
		static void Main(string[] args) {
			var client = new RestClient("<insert presignedUrl generated by https://api.pdf.co/v1/file/upload/get-presigned-url >");
			client.Timeout = -1;
			var request = new RestRequest(Method.PUT);
			request.AddHeader("x-api-key", "");
			request.AddFile("file", "/Users/em/Downloads/logo.png");
			IRestResponse response = client.Execute(request);
			Console.WriteLine(response.Content);
		}
	}
}

Python
import requests

url = "<insert presignedUrl generated by https://api.pdf.co/v1/file/upload/get-presigned-url >"

payload={}
files=[
	('file',('logo.png',open('/Users/em/Downloads/logo.png','rb'),'image/png'))
]
headers = {
	'x-api-key': ''
}

response = requests.request("PUT", url, headers=headers, data=payload, files=files)

print(response.text)

Powershell
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("x-api-key", "")

$multipartContent = [System.Net.Http.MultipartFormDataContent]::new()
$multipartFile = '/Users/em/Downloads/logo.png'
$FileStream = [System.IO.FileStream]::new($multipartFile, [System.IO.FileMode]::Open)
$fileHeader = [System.Net.Http.Headers.ContentDispositionHeaderValue]::new("form-data")
$fileHeader.Name = "file"
$fileHeader.FileName = "logo.png"
$fileContent = [System.Net.Http.StreamContent]::new($FileStream)
$fileContent.Headers.ContentDisposition = $fileHeader
$multipartContent.Add($fileContent)

$body = $multipartContent

$response = Invoke-RestMethod '<insert presignedUrl generated by https://api.pdf.co/v1/file/upload/get-presigned-url >' -Method 'PUT' -Headers $headers -Body $body
$response | ConvertTo-Json

[POST] /file/upload (Uploading small file)

Description: Uploads a small (up to 100KB) local file as a temporary file in PDF.co storage. Note: temporary files are automatically permanently removed after 1 hour.

Status Errors

CodeDescription
200The request has succeeded
400bad input parameters
401unauthorized
403not enough credits
405Timeout error. To upload large documents or files please use /file/upload/get-presigned-url instead to get url that you should upload into (see source code samples

Example

Sample Request:

! Don’t forget to set x-api-key url param or http header param (preferred) to API key, get yours here

Description

  • Method: POST
  • URL: /v1/file/upload

Query parameters

No query parameters accepted.

Body payload

keyvaluedescriptiondisabled 
x-api-key Optional. Please use http headers instead when possible because passing your API key as parameter for POST or GET is not secure and is for legacy app compatibility only.  
true    
name optional. The name the file will be stored with. Must be a String.texttrue
filerequired. Local file should be selectedfile  

Example responses

POST Upload small file: /file/upload
{
    "url": "https://pdf-temp-files.s3.amazonaws.com/28b6041bcfe34c469ed44f15f0594d5f/logo.dat",
    "error": false,
    "status": 200,
    "name": "logo",
    "remainingCredits": 77772
}
/file/upload/url
{
    "url": "https://pdf-temp-files.s3.amazonaws.com/1a4a92ac805c41c28ef75a24e0f35ba5/sample.pdf",
    "error": false,
    "status": 200,
    "name": "sample.pdf",
    "remainingCredits": 98145
}

Code Snippets

CURL
curl --location --request POST 'https://api.pdf.co/v1/file/upload' \
--header 'x-api-key: ' \
--form 'file=@"/path/to/file"'
JavaScript
var myHeaders = new Headers();
myHeaders.append("x-api-key", "");

var formdata = new FormData();
formdata.append("file", fileInput.files[0], "file");

var requestOptions = {
	method: 'POST',
	headers: myHeaders,
	body: formdata,
	redirect: 'follow'
};

fetch("https://api.pdf.co/v1/file/upload", requestOptions)
	.then(response => response.text())
	.then(result => console.log(result))
	.catch(error => console.log('error', error));
NodeJs
var request = require('request');
var fs = require('fs');
var options = {
	'method': 'POST',
	'url': 'https://api.pdf.co/v1/file/upload',
	'headers': {
		'x-api-key': ''
	},
	formData: {
		'file': {
			'value': fs.createReadStream('/path/to/file'),
			'options': {
				'filename': 'file',
				'contentType': null
			}
		}
	}
};
request(options, function (error, response) {
	if (error) throw new Error(error);
	console.log(response.body);
});

PHP
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
	CURLOPT_URL => 'https://api.pdf.co/v1/file/upload',
	CURLOPT_RETURNTRANSFER => true,
	CURLOPT_ENCODING => '',
	CURLOPT_MAXREDIRS => 10,
	CURLOPT_TIMEOUT => 0,
	CURLOPT_FOLLOWLOCATION => true,
	CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
	CURLOPT_CUSTOMREQUEST => 'POST',
	CURLOPT_POSTFIELDS => array('file'=> new CURLFILE('/path/to/file')),
	CURLOPT_HTTPHEADER => array(
		'x-api-key: '
	),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Java
import java.io.*;
import okhttp3.*;
public class main {
	public static void main(String []args) throws IOException{
		OkHttpClient client = new OkHttpClient().newBuilder()
			.build();
		MediaType mediaType = MediaType.parse("text/plain");
		RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
			.addFormDataPart("file","file",
				RequestBody.create(MediaType.parse("application/octet-stream"),
				new File("/path/to/file")))
			.build();
		Request request = new Request.Builder()
			.url("https://api.pdf.co/v1/file/upload")
			.method("POST", body)
			.addHeader("x-api-key", "")
			.build();
		Response response = client.newCall(request).execute();
		System.out.println(response.body().string());
	}
}

C#
using System;
using RestSharp;
namespace HelloWorldApplication {
	class HelloWorld {
		static void Main(string[] args) {
			var client = new RestClient("https://api.pdf.co/v1/file/upload");
			client.Timeout = -1;
			var request = new RestRequest(Method.POST);
			request.AddHeader("x-api-key", "");
			request.AddFile("file", "/path/to/file");
			IRestResponse response = client.Execute(request);
			Console.WriteLine(response.Content);
		}
	}
}

Python
import requests

url = "https://api.pdf.co/v1/file/upload"

payload={}
files=[
	('file',('file',open('/path/to/file','rb'),'application/octet-stream'))
]
headers = {
	'x-api-key': ''
}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)

Powershell
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("x-api-key", "")

$multipartContent = [System.Net.Http.MultipartFormDataContent]::new()
$multipartFile = '/path/to/file'
$FileStream = [System.IO.FileStream]::new($multipartFile, [System.IO.FileMode]::Open)
$fileHeader = [System.Net.Http.Headers.ContentDispositionHeaderValue]::new("form-data")
$fileHeader.Name = "file"
$fileHeader.FileName = "file"
$fileContent = [System.Net.Http.StreamContent]::new($FileStream)
$fileContent.Headers.ContentDisposition = $fileHeader
$multipartContent.Add($fileContent)

$body = $multipartContent

$response = Invoke-RestMethod 'https://api.pdf.co/v1/file/upload' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json

[POST] /file/upload/base64 (Upload small file as Base64)

Description: Creates temporary file using base64 source data. You may use this temporary file URL with other API methods. Temporary files are automatically permanently removed after 1 hour. GET or POST request.

Status Errors

CodeDescription
200The request has succeeded
400bad input parameters
401unauthorized
403not enough credits
405Timeout error. To process large documents or files please use asynchronous mode ( set async parameter to true) and then check the status using /job/check endpoint. If file contains many pages then specify a page range using pages parameter. The number of pages of the document can be obtained using the endpoint /pdf/info

Example

Sample Request:

! Don’t forget to set x-api-key url param or http header param (preferred) to API key, get yours here

POST

{
	"file" : "data:image/gif;base64,R0lGODlhEAAQAPUtACIiIScnJigoJywsLDIyMjMzMzU1NTc3Nzg4ODk5OTs7Ozw8PEJCQlBQUFRUVFVVVVhYWG1tbXt7fInDRYvESYzFSo/HT5LJVJPJVJTKV5XKWJbKWZbLWpfLW5jLXJrMYaLRbaTScKXScKXScafTdIGBgYODg6alprLYhbvekr3elr3el9Dotf///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAAAAAAAIf8LSW1hZ2VNYWdpY2sNZ2FtbWE9MC40NTQ1NQAsAAAAABAAEAAABpJAFGgkKhpFIRHpw2qBLJiLdCrNTFKt0wjD2Xi/G09l1ZIwRJeNZs3uUFQtEwCCVrM1bnhJYHDU73ktJQELBH5pbW+CAQoIhn94ioMKB46HaoGTB5WPaZmMm5wOIRcekqChliIZFXqoqYYkE2SaoZuWH1gmAgsIvr8ICQUPTRIABgTJyskFAw1ZDBAO09TUDw0RQQA7"
}

Description

  • Method: POST
  • URL: /v1/file/upload/base64

Query parameters

No query parameters accepted.

Body payload

keyvaluedescriptiondisabled 
x-api-key Optional. Please use http headers instead when possible because passing your API key as parameter for POST or GET is not secure and is for legacy app compatibility only.  
true    
namecustom nameoptional. The name the file will be stored with. Must be a String.texttrue
filedata:image/gif;base64,R0lGODlhEAAQAPUtACIiIScnJigoJywsLDIyMjMzMzU1NTc3Nzg4ODk5OTs7Ozw8PEJCQlBQUFRUVFVVVVhYWG1tbXt7fInDRYvESYzFSo/HT5LJVJPJVJTKV5XKWJbKWZbLWpfLW5jLXJrMYaLRbaTScKXScKXScafTdIGBgYODg6alprLYhbvekr3elr3el9Dotf///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAAAAAAAIf8LSW1hZ2VNYWdpY2sNZ2FtbWE9MC40NTQ1NQAsAAAAABAAEAAABpJAFGgkKhpFIRHpw2qBLJiLdCrNTFKt0wjD2Xi/G09l1ZIwRJeNZs3uUFQtEwCCVrM1bnhJYHDU73ktJQELBH5pbW+CAQoIhn94ioMKB46HaoGTB5WPaZmMm5wOIRcekqChliIZFXqoqYYkE2SaoZuWH1gmAgsIvr8ICQUPTRIABgTJyskFAw1ZDBAO09TUDw0RQQA7required. Base64-encoded file bytes. Must be a String.text 

Example responses

https://api.pdf.co/v1/file/upload/base64
{
    "url": "https://pdf-temp-files.s3.amazonaws.com/a8ac8a3cec3344f08f556bfd2d678b2f/uploadfile.txt",
    "error": false,
    "status": 200,
    "remainingCredits": 98145
}
POST Upload small file as Base64: /file/upload/base64
{
    "url": "https://pdf-temp-files.s3.amazonaws.com/7588d614c9ad41eb98ec317a02abda63/uploadfile.txt",
    "error": false,
    "status": 200,
    "remainingCredits": 77769
}

Code Snippets

CURL
curl --location --request POST 'https://api.pdf.co/v1/file/upload/base64' \
--header 'x-api-key: ' \
--form 'file="data:image/gif;base64,R0lGODlhEAAQAPUtACIiIScnJigoJywsLDIyMjMzMzU1NTc3Nzg4ODk5OTs7Ozw8PEJCQlBQUFRUVFVVVVhYWG1tbXt7fInDRYvESYzFSo/HT5LJVJPJVJTKV5XKWJbKWZbLWpfLW5jLXJrMYaLRbaTScKXScKXScafTdIGBgYODg6alprLYhbvekr3elr3el9Dotf///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAAAAAAAIf8LSW1hZ2VNYWdpY2sNZ2FtbWE9MC40NTQ1NQAsAAAAABAAEAAABpJAFGgkKhpFIRHpw2qBLJiLdCrNTFKt0wjD2Xi/G09l1ZIwRJeNZs3uUFQtEwCCVrM1bnhJYHDU73ktJQELBH5pbW+CAQoIhn94ioMKB46HaoGTB5WPaZmMm5wOIRcekqChliIZFXqoqYYkE2SaoZuWH1gmAgsIvr8ICQUPTRIABgTJyskFAw1ZDBAO09TUDw0RQQA7"'
JavaScript
var myHeaders = new Headers();
myHeaders.append("x-api-key", "");

var formdata = new FormData();
formdata.append("file", "data:image/gif;base64,R0lGODlhEAAQAPUtACIiIScnJigoJywsLDIyMjMzMzU1NTc3Nzg4ODk5OTs7Ozw8PEJCQlBQUFRUVFVVVVhYWG1tbXt7fInDRYvESYzFSo/HT5LJVJPJVJTKV5XKWJbKWZbLWpfLW5jLXJrMYaLRbaTScKXScKXScafTdIGBgYODg6alprLYhbvekr3elr3el9Dotf///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAAAAAAAIf8LSW1hZ2VNYWdpY2sNZ2FtbWE9MC40NTQ1NQAsAAAAABAAEAAABpJAFGgkKhpFIRHpw2qBLJiLdCrNTFKt0wjD2Xi/G09l1ZIwRJeNZs3uUFQtEwCCVrM1bnhJYHDU73ktJQELBH5pbW+CAQoIhn94ioMKB46HaoGTB5WPaZmMm5wOIRcekqChliIZFXqoqYYkE2SaoZuWH1gmAgsIvr8ICQUPTRIABgTJyskFAw1ZDBAO09TUDw0RQQA7");

var requestOptions = {
	method: 'POST',
	headers: myHeaders,
	body: formdata,
	redirect: 'follow'
};

fetch("https://api.pdf.co/v1/file/upload/base64", requestOptions)
	.then(response => response.text())
	.then(result => console.log(result))
	.catch(error => console.log('error', error));
NodeJs
var request = require('request');
var options = {
	'method': 'POST',
	'url': 'https://api.pdf.co/v1/file/upload/base64',
	'headers': {
		'x-api-key': ''
	},
	formData: {
		'file': 'data:image/gif;base64,R0lGODlhEAAQAPUtACIiIScnJigoJywsLDIyMjMzMzU1NTc3Nzg4ODk5OTs7Ozw8PEJCQlBQUFRUVFVVVVhYWG1tbXt7fInDRYvESYzFSo/HT5LJVJPJVJTKV5XKWJbKWZbLWpfLW5jLXJrMYaLRbaTScKXScKXScafTdIGBgYODg6alprLYhbvekr3elr3el9Dotf///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAAAAAAAIf8LSW1hZ2VNYWdpY2sNZ2FtbWE9MC40NTQ1NQAsAAAAABAAEAAABpJAFGgkKhpFIRHpw2qBLJiLdCrNTFKt0wjD2Xi/G09l1ZIwRJeNZs3uUFQtEwCCVrM1bnhJYHDU73ktJQELBH5pbW+CAQoIhn94ioMKB46HaoGTB5WPaZmMm5wOIRcekqChliIZFXqoqYYkE2SaoZuWH1gmAgsIvr8ICQUPTRIABgTJyskFAw1ZDBAO09TUDw0RQQA7'
	}
};
request(options, function (error, response) {
	if (error) throw new Error(error);
	console.log(response.body);
});

PHP
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
	CURLOPT_URL => 'https://api.pdf.co/v1/file/upload/base64',
	CURLOPT_RETURNTRANSFER => true,
	CURLOPT_ENCODING => '',
	CURLOPT_MAXREDIRS => 10,
	CURLOPT_TIMEOUT => 0,
	CURLOPT_FOLLOWLOCATION => true,
	CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
	CURLOPT_CUSTOMREQUEST => 'POST',
	CURLOPT_POSTFIELDS => array('file' => 'data:image/gif;base64,R0lGODlhEAAQAPUtACIiIScnJigoJywsLDIyMjMzMzU1NTc3Nzg4ODk5OTs7Ozw8PEJCQlBQUFRUVFVVVVhYWG1tbXt7fInDRYvESYzFSo/HT5LJVJPJVJTKV5XKWJbKWZbLWpfLW5jLXJrMYaLRbaTScKXScKXScafTdIGBgYODg6alprLYhbvekr3elr3el9Dotf///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAAAAAAAIf8LSW1hZ2VNYWdpY2sNZ2FtbWE9MC40NTQ1NQAsAAAAABAAEAAABpJAFGgkKhpFIRHpw2qBLJiLdCrNTFKt0wjD2Xi/G09l1ZIwRJeNZs3uUFQtEwCCVrM1bnhJYHDU73ktJQELBH5pbW+CAQoIhn94ioMKB46HaoGTB5WPaZmMm5wOIRcekqChliIZFXqoqYYkE2SaoZuWH1gmAgsIvr8ICQUPTRIABgTJyskFAw1ZDBAO09TUDw0RQQA7'),
	CURLOPT_HTTPHEADER => array(
		'x-api-key: '
	),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Java
import java.io.*;
import okhttp3.*;
public class main {
	public static void main(String []args) throws IOException{
		OkHttpClient client = new OkHttpClient().newBuilder()
			.build();
		MediaType mediaType = MediaType.parse("text/plain");
		RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
			.addFormDataPart("file","data:image/gif;base64,R0lGODlhEAAQAPUtACIiIScnJigoJywsLDIyMjMzMzU1NTc3Nzg4ODk5OTs7Ozw8PEJCQlBQUFRUVFVVVVhYWG1tbXt7fInDRYvESYzFSo/HT5LJVJPJVJTKV5XKWJbKWZbLWpfLW5jLXJrMYaLRbaTScKXScKXScafTdIGBgYODg6alprLYhbvekr3elr3el9Dotf///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAAAAAAAIf8LSW1hZ2VNYWdpY2sNZ2FtbWE9MC40NTQ1NQAsAAAAABAAEAAABpJAFGgkKhpFIRHpw2qBLJiLdCrNTFKt0wjD2Xi/G09l1ZIwRJeNZs3uUFQtEwCCVrM1bnhJYHDU73ktJQELBH5pbW+CAQoIhn94ioMKB46HaoGTB5WPaZmMm5wOIRcekqChliIZFXqoqYYkE2SaoZuWH1gmAgsIvr8ICQUPTRIABgTJyskFAw1ZDBAO09TUDw0RQQA7")
			.build();
		Request request = new Request.Builder()
			.url("https://api.pdf.co/v1/file/upload/base64")
			.method("POST", body)
			.addHeader("x-api-key", "")
			.build();
		Response response = client.newCall(request).execute();
		System.out.println(response.body().string());
	}
}

C#
using System;
using RestSharp;
namespace HelloWorldApplication {
	class HelloWorld {
		static void Main(string[] args) {
			var client = new RestClient("https://api.pdf.co/v1/file/upload/base64");
			client.Timeout = -1;
			var request = new RestRequest(Method.POST);
			request.AddHeader("x-api-key", "");
			request.AlwaysMultipartFormData = true;
			request.AddParameter("file", "data:image/gif;base64,R0lGODlhEAAQAPUtACIiIScnJigoJywsLDIyMjMzMzU1NTc3Nzg4ODk5OTs7Ozw8PEJCQlBQUFRUVFVVVVhYWG1tbXt7fInDRYvESYzFSo/HT5LJVJPJVJTKV5XKWJbKWZbLWpfLW5jLXJrMYaLRbaTScKXScKXScafTdIGBgYODg6alprLYhbvekr3elr3el9Dotf///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAAAAAAAIf8LSW1hZ2VNYWdpY2sNZ2FtbWE9MC40NTQ1NQAsAAAAABAAEAAABpJAFGgkKhpFIRHpw2qBLJiLdCrNTFKt0wjD2Xi/G09l1ZIwRJeNZs3uUFQtEwCCVrM1bnhJYHDU73ktJQELBH5pbW+CAQoIhn94ioMKB46HaoGTB5WPaZmMm5wOIRcekqChliIZFXqoqYYkE2SaoZuWH1gmAgsIvr8ICQUPTRIABgTJyskFAw1ZDBAO09TUDw0RQQA7");
			IRestResponse response = client.Execute(request);
			Console.WriteLine(response.Content);
		}
	}
}

Python
import requests

url = "https://api.pdf.co/v1/file/upload/base64"

payload={'file': 'data:image/gif;base64,R0lGODlhEAAQAPUtACIiIScnJigoJywsLDIyMjMzMzU1NTc3Nzg4ODk5OTs7Ozw8PEJCQlBQUFRUVFVVVVhYWG1tbXt7fInDRYvESYzFSo/HT5LJVJPJVJTKV5XKWJbKWZbLWpfLW5jLXJrMYaLRbaTScKXScKXScafTdIGBgYODg6alprLYhbvekr3elr3el9Dotf///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAAAAAAAIf8LSW1hZ2VNYWdpY2sNZ2FtbWE9MC40NTQ1NQAsAAAAABAAEAAABpJAFGgkKhpFIRHpw2qBLJiLdCrNTFKt0wjD2Xi/G09l1ZIwRJeNZs3uUFQtEwCCVrM1bnhJYHDU73ktJQELBH5pbW+CAQoIhn94ioMKB46HaoGTB5WPaZmMm5wOIRcekqChliIZFXqoqYYkE2SaoZuWH1gmAgsIvr8ICQUPTRIABgTJyskFAw1ZDBAO09TUDw0RQQA7'}
files=[

]
headers = {
	'x-api-key': ''
}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)

Powershell
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("x-api-key", "")

$multipartContent = [System.Net.Http.MultipartFormDataContent]::new()
$stringHeader = [System.Net.Http.Headers.ContentDispositionHeaderValue]::new("form-data")
$stringHeader.Name = "file"
$stringContent = [System.Net.Http.StringContent]::new("data:image/gif;base64,R0lGODlhEAAQAPUtACIiIScnJigoJywsLDIyMjMzMzU1NTc3Nzg4ODk5OTs7Ozw8PEJCQlBQUFRUVFVVVVhYWG1tbXt7fInDRYvESYzFSo/HT5LJVJPJVJTKV5XKWJbKWZbLWpfLW5jLXJrMYaLRbaTScKXScKXScafTdIGBgYODg6alprLYhbvekr3elr3el9Dotf///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAAAAAAAIf8LSW1hZ2VNYWdpY2sNZ2FtbWE9MC40NTQ1NQAsAAAAABAAEAAABpJAFGgkKhpFIRHpw2qBLJiLdCrNTFKt0wjD2Xi/G09l1ZIwRJeNZs3uUFQtEwCCVrM1bnhJYHDU73ktJQELBH5pbW+CAQoIhn94ioMKB46HaoGTB5WPaZmMm5wOIRcekqChliIZFXqoqYYkE2SaoZuWH1gmAgsIvr8ICQUPTRIABgTJyskFAw1ZDBAO09TUDw0RQQA7")
$stringContent.Headers.ContentDisposition = $stringHeader
$multipartContent.Add($stringContent)

$body = $multipartContent

$response = Invoke-RestMethod 'https://api.pdf.co/v1/file/upload/base64' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json

[POST] /file/upload/url (Upload file from URL)

Description: Downloads file from a source url and uploads it as a temporary file. Temporary files are automatically permanently removed after 1 hour.

Status Errors

CodeDescription
200The request has succeeded
400bad input parameters
401unauthorized
403not enough credits
405Timeout error. To process large documents or files please use asynchronous mode ( set async parameter to true) and then check the status using /job/check endpoint. If file contains many pages then specify a page range using pages parameter. The number of pages of the document can be obtained using the endpoint /pdf/info

Example

Sample Request:

! Don’t forget to set x-api-key url param or http header param (preferred) to API key, get yours here

POST

{
"url" : "https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/pdf-split/sample.pdf"
}

Description

  • Method: POST
  • URL: /v1/file/upload/url

Query parameters

No query parameters accepted.

Body payload

keyvaluedescriptiondisabled
x-api-key Optional. Please use http headers instead when possible because passing your API key as parameter for POST or GET is not secure and is for legacy app compatibility only. 
true   
namesample.pdfoptional. The name the file will be stored with. Must be a String.text
urlhttps://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/pdf-split/sample.pdfrequired. URL of the file to upload. Must be a String.text

Example responses

POST Upload from URL: /file/upload/url
{
    "url": "https://pdf-temp-files.s3.amazonaws.com/4e36f2962b7f4248b7167f4389d534d5/sample.pdf",
    "error": false,
    "status": 200,
    "name": "sample.pdf",
    "remainingCredits": 77767
}
/file/upload/url
{
    "url": "https://pdf-temp-files.s3.amazonaws.com/1a4a92ac805c41c28ef75a24e0f35ba5/sample.pdf",
    "error": false,
    "status": 200,
    "name": "sample.pdf",
    "remainingCredits": 98145
}

Code Snippets

CURL
curl --location --request POST 'https://api.pdf.co/v1/file/upload/url' \
--header 'x-api-key: ' \
--form 'name="sample.pdf"' \
--form 'url="https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/pdf-split/sample.pdf"'
JavaScript
var myHeaders = new Headers();
myHeaders.append("x-api-key", "");

var formdata = new FormData();
formdata.append("name", "sample.pdf");
formdata.append("url", "https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/pdf-split/sample.pdf");

var requestOptions = {
	method: 'POST',
	headers: myHeaders,
	body: formdata,
	redirect: 'follow'
};

fetch("https://api.pdf.co/v1/file/upload/url", requestOptions)
	.then(response => response.text())
	.then(result => console.log(result))
	.catch(error => console.log('error', error));
NodeJs
var request = require('request');
var options = {
	'method': 'POST',
	'url': 'https://api.pdf.co/v1/file/upload/url',
	'headers': {
		'x-api-key': ''
	},
	formData: {
		'name': 'sample.pdf',
		'url': 'https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/pdf-split/sample.pdf'
	}
};
request(options, function (error, response) {
	if (error) throw new Error(error);
	console.log(response.body);
});

PHP
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
	CURLOPT_URL => 'https://api.pdf.co/v1/file/upload/url',
	CURLOPT_RETURNTRANSFER => true,
	CURLOPT_ENCODING => '',
	CURLOPT_MAXREDIRS => 10,
	CURLOPT_TIMEOUT => 0,
	CURLOPT_FOLLOWLOCATION => true,
	CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
	CURLOPT_CUSTOMREQUEST => 'POST',
	CURLOPT_POSTFIELDS => array('name' => 'sample.pdf','url' => 'https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/pdf-split/sample.pdf'),
	CURLOPT_HTTPHEADER => array(
		'x-api-key: '
	),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Java
import java.io.*;
import okhttp3.*;
public class main {
	public static void main(String []args) throws IOException{
		OkHttpClient client = new OkHttpClient().newBuilder()
			.build();
		MediaType mediaType = MediaType.parse("text/plain");
		RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
			.addFormDataPart("name","sample.pdf")
			.addFormDataPart("url","https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/pdf-split/sample.pdf")
			.build();
		Request request = new Request.Builder()
			.url("https://api.pdf.co/v1/file/upload/url")
			.method("POST", body)
			.addHeader("x-api-key", "")
			.build();
		Response response = client.newCall(request).execute();
		System.out.println(response.body().string());
	}
}

C#
using System;
using RestSharp;
namespace HelloWorldApplication {
	class HelloWorld {
		static void Main(string[] args) {
			var client = new RestClient("https://api.pdf.co/v1/file/upload/url");
			client.Timeout = -1;
			var request = new RestRequest(Method.POST);
			request.AddHeader("x-api-key", "");
			request.AlwaysMultipartFormData = true;
			request.AddParameter("name", "sample.pdf");
			request.AddParameter("url", "https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/pdf-split/sample.pdf");
			IRestResponse response = client.Execute(request);
			Console.WriteLine(response.Content);
		}
	}
}

Python
import requests

url = "https://api.pdf.co/v1/file/upload/url"

payload={'name': 'sample.pdf',
'url': 'https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/pdf-split/sample.pdf'}
files=[

]
headers = {
	'x-api-key': ''
}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)

Powershell
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("x-api-key", "")

$multipartContent = [System.Net.Http.MultipartFormDataContent]::new()
$stringHeader = [System.Net.Http.Headers.ContentDispositionHeaderValue]::new("form-data")
$stringHeader.Name = "name"
$stringContent = [System.Net.Http.StringContent]::new("sample.pdf")
$stringContent.Headers.ContentDisposition = $stringHeader
$multipartContent.Add($stringContent)

$stringHeader = [System.Net.Http.Headers.ContentDispositionHeaderValue]::new("form-data")
$stringHeader.Name = "url"
$stringContent = [System.Net.Http.StringContent]::new("https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/pdf-split/sample.pdf")
$stringContent.Headers.ContentDisposition = $stringHeader
$multipartContent.Add($stringContent)

$body = $multipartContent

$response = Invoke-RestMethod 'https://api.pdf.co/v1/file/upload/url' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json

[GET] /file/upload/url (Upload from URL)

Description: Downloads file from a source url and uploads it as a temporary file. Temporary files are automatically permanently removed after 1 hour.

Status Errors

CodeDescription
200The request has succeeded
400bad input parameters
401unauthorized
403not enough credits
405Timeout error. To process large documents or files please use asynchronous mode ( set async parameter to true) and then check the status using /job/check endpoint. If file contains many pages then specify a page range using pages parameter. The number of pages of the document can be obtained using the endpoint /pdf/info

Example

Sample Request:

! Don’t forget to set x-api-key url param or http header param (preferred) to API key, get yours here

POST

{
"url" : "https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/pdf-split/sample.pdf"
}

Description

  • Method: GET
  • URL: /v1/file/upload/url

Query parameters

  • url: https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/pdf-split/sample.pdf

Body payload

keyvaluedescriptiondisabled
x-api-key Optional. Please use http headers instead when possible because passing your API key as parameter for POST or GET is not secure and is for legacy app compatibility only. 
true   

Example responses

/file/upload/url
{
    "url": "https://pdf-temp-files.s3.amazonaws.com/703aa298cfe745baa3449fbdaba4d1d7/sample.pdf",
    "error": false,
    "status": 200,
    "name": "sample.pdf",
    "remainingCredits": 98145
}
GET Upload from URL: /file/upload/url
{
    "url": "https://pdf-temp-files.s3.amazonaws.com/97415d1c45a04b29ac42c8dc01883316/sample.pdf",
    "error": false,
    "status": 200,
    "name": "sample.pdf",
    "remainingCredits": 77765
}

Code Snippets

CURL
curl --location --request GET 'https://api.pdf.co/v1/file/upload/url?url=https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/pdf-split/sample.pdf' \
--header 'x-api-key: '
JavaScript
var myHeaders = new Headers();
myHeaders.append("x-api-key", "");

var formdata = new FormData();

var requestOptions = {
	method: 'GET',
	headers: myHeaders,
	body: formdata,
	redirect: 'follow'
};

fetch("https://api.pdf.co/v1/file/upload/url?url=https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/pdf-split/sample.pdf", requestOptions)
	.then(response => response.text())
	.then(result => console.log(result))
	.catch(error => console.log('error', error));
NodeJs
var request = require('request');
var options = {
	'method': 'GET',
	'url': 'https://api.pdf.co/v1/file/upload/url?url=https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/pdf-split/sample.pdf',
	'headers': {
		'x-api-key': ''
	},
	formData: {

	}
};
request(options, function (error, response) {
	if (error) throw new Error(error);
	console.log(response.body);
});

PHP
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
	CURLOPT_URL => 'https://api.pdf.co/v1/file/upload/url?url=https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/pdf-split/sample.pdf',
	CURLOPT_RETURNTRANSFER => true,
	CURLOPT_ENCODING => '',
	CURLOPT_MAXREDIRS => 10,
	CURLOPT_TIMEOUT => 0,
	CURLOPT_FOLLOWLOCATION => true,
	CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
	CURLOPT_CUSTOMREQUEST => 'GET',
	CURLOPT_HTTPHEADER => array(
		'x-api-key: '
	),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Java
import java.io.*;
import okhttp3.*;
public class main {
	public static void main(String []args) throws IOException{
		OkHttpClient client = new OkHttpClient().newBuilder()
			.build();
		Request request = new Request.Builder()
			.url("https://api.pdf.co/v1/file/upload/url?url=https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/pdf-split/sample.pdf")
			.method("GET", null)
			.addHeader("x-api-key", "")
			.build();
		Response response = client.newCall(request).execute();
		System.out.println(response.body().string());
	}
}

C#
using System;
using RestSharp;
namespace HelloWorldApplication {
	class HelloWorld {
		static void Main(string[] args) {
			var client = new RestClient("https://api.pdf.co/v1/file/upload/url?url=https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/pdf-split/sample.pdf");
			client.Timeout = -1;
			var request = new RestRequest(Method.GET);
			request.AddHeader("x-api-key", "");
			request.AlwaysMultipartFormData = true;
			IRestResponse response = client.Execute(request);
			Console.WriteLine(response.Content);
		}
	}
}

Python
import requests

url = "https://api.pdf.co/v1/file/upload/url?url=https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/pdf-split/sample.pdf"

payload={}
files={}
headers = {
	'x-api-key': ''
}

response = requests.request("GET", url, headers=headers, data=payload, files=files)

print(response.text)

Powershell
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("x-api-key", "")

$multipartContent = [System.Net.Http.MultipartFormDataContent]::new()
$body = $multipartContent

$response = Invoke-RestMethod 'https://api.pdf.co/v1/file/upload/url?url=https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/pdf-split/sample.pdf' -Method 'GET' -Headers $headers -Body $body
$response | ConvertTo-Json

[POST] /file/delete

Description: Deletes temp file (that was uploaded by you or generated by API)

IMPORTANT: All temp files are autoremoved after 1 hour. You may use /file/delete methods to explicitely force remove temp files once you don’t need them.

Parameters

  • url required. URL of previously uploaded temporary file or output file that was generated by API method.

Description

  • Method: POST
  • URL: /v1/file/delete

Query parameters

No query parameters accepted.

Body payload

{
    "file": "https://pdf-temp-files.s3.amazonaws.com/b5c1e67d98ab438292ff1fea0c7cdc9d/sample.pdf"
}

Example responses

/file/delete
{
    "error": false,
    "status": 200,
    "remainingCredits": 9999986
}
POST /file/delete
{
    "error": false,
    "status": 200,
    "remainingCredits": 77778
}

Code Snippets

CURL
curl --location --request POST 'https://api.pdf.co/v1/file/delete' \
--header 'x-api-key: ' \
--data-raw '{
    "file": "https://pdf-temp-files.s3.amazonaws.com/b5c1e67d98ab438292ff1fea0c7cdc9d/sample.pdf"
}'
JavaScript
var myHeaders = new Headers();
myHeaders.append("x-api-key", "");

var raw = "{\n    \"file\": \"https://pdf-temp-files.s3.amazonaws.com/b5c1e67d98ab438292ff1fea0c7cdc9d/sample.pdf\"\n}";

var requestOptions = {
	method: 'POST',
	headers: myHeaders,
	body: raw,
	redirect: 'follow'
};

fetch("https://api.pdf.co/v1/file/delete", requestOptions)
	.then(response => response.text())
	.then(result => console.log(result))
	.catch(error => console.log('error', error));
NodeJs
var request = require('request');
var options = {
	'method': 'POST',
	'url': 'https://api.pdf.co/v1/file/delete',
	'headers': {
		'x-api-key': ''
	},
	body: '{\n    "file": "https://pdf-temp-files.s3.amazonaws.com/b5c1e67d98ab438292ff1fea0c7cdc9d/sample.pdf"\n}'

};
request(options, function (error, response) {
	if (error) throw new Error(error);
	console.log(response.body);
});

PHP
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
	CURLOPT_URL => 'https://api.pdf.co/v1/file/delete',
	CURLOPT_RETURNTRANSFER => true,
	CURLOPT_ENCODING => '',
	CURLOPT_MAXREDIRS => 10,
	CURLOPT_TIMEOUT => 0,
	CURLOPT_FOLLOWLOCATION => true,
	CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
	CURLOPT_CUSTOMREQUEST => 'POST',
	CURLOPT_POSTFIELDS =>'{
    "file": "https://pdf-temp-files.s3.amazonaws.com/b5c1e67d98ab438292ff1fea0c7cdc9d/sample.pdf"
}',
	CURLOPT_HTTPHEADER => array(
		'x-api-key: '
	),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Java
import java.io.*;
import okhttp3.*;
public class main {
	public static void main(String []args) throws IOException{
		OkHttpClient client = new OkHttpClient().newBuilder()
			.build();
		MediaType mediaType = MediaType.parse("text/plain");
		RequestBody body = RequestBody.create(mediaType, "{\n    \"file\": \"https://pdf-temp-files.s3.amazonaws.com/b5c1e67d98ab438292ff1fea0c7cdc9d/sample.pdf\"\n}");
		Request request = new Request.Builder()
			.url("https://api.pdf.co/v1/file/delete")
			.method("POST", body)
			.addHeader("x-api-key", "")
			.build();
		Response response = client.newCall(request).execute();
		System.out.println(response.body().string());
	}
}

C#
using System;
using RestSharp;
namespace HelloWorldApplication {
	class HelloWorld {
		static void Main(string[] args) {
			var client = new RestClient("https://api.pdf.co/v1/file/delete");
			client.Timeout = -1;
			var request = new RestRequest(Method.POST);
			request.AddHeader("x-api-key", "");
			var body = @"{" + "\n" +
			@"    ""file"": ""https://pdf-temp-files.s3.amazonaws.com/b5c1e67d98ab438292ff1fea0c7cdc9d/sample.pdf""" + "\n" +
			@"}";
			request.AddParameter("text/plain", body,  ParameterType.RequestBody);
			IRestResponse response = client.Execute(request);
			Console.WriteLine(response.Content);
		}
	}
}

Python
import requests

url = "https://api.pdf.co/v1/file/delete"

payload = "{\n    \"file\": \"https://pdf-temp-files.s3.amazonaws.com/b5c1e67d98ab438292ff1fea0c7cdc9d/sample.pdf\"\n}"
headers = {
	'x-api-key': ''
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

Powershell
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("x-api-key", "")

$body = "{`n    `"file`": `"https://pdf-temp-files.s3.amazonaws.com/b5c1e67d98ab438292ff1fea0c7cdc9d/sample.pdf`"`n}"

$response = Invoke-RestMethod 'https://api.pdf.co/v1/file/delete' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json

[POST] /file/hash

Description: Calculate and return MD5 hash of file by url. Commonly used to control if source document has been changed or not because every little change will cause hash string to differ as well. GET or POST request.

Parameters

  • url required. URL to the source file. Supports links from Google Drive, Dropbox and from built-in PDF.co files storage. For uploading files via API please check Files Upload section. If you are randomly getting Too Many Requests or Access Denied error for your input url, please try to add cache: to enable built-in url caching.

Description

  • Method: POST
  • URL: /v1/file/hash

Query parameters

No query parameters accepted.

Body payload

{
    "url": "https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/pdf-split/sample.pdf"
}

Example responses

/file/hash
{
    "hash": "d942e5becdcb0386598cce15e9e56deb1ca9d893b8578a88eca4a62f02c4000b",
    "remainingCredits": 98143
}

Code Snippets

CURL
curl --location --request POST 'https://api.pdf.co/v1/file/hash' \
--header 'x-api-key: ' \
--header 'Content-Type: application/json' \
--data-raw '{
    "url": "https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/pdf-split/sample.pdf"
}'
JavaScript
var myHeaders = new Headers();
myHeaders.append("x-api-key", "");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
 "url": "https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/pdf-split/sample.pdf"
});

var requestOptions = {
	method: 'POST',
	headers: myHeaders,
	body: raw,
	redirect: 'follow'
};

fetch("https://api.pdf.co/v1/file/hash", requestOptions)
	.then(response => response.text())
	.then(result => console.log(result))
	.catch(error => console.log('error', error));
NodeJs
var request = require('request');
var options = {
	'method': 'POST',
	'url': 'https://api.pdf.co/v1/file/hash',
	'headers': {
		'x-api-key': '',
		'Content-Type': 'application/json'
	},
	body: JSON.stringify({
	 "url": "https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/pdf-split/sample.pdf"
	})

};
request(options, function (error, response) {
	if (error) throw new Error(error);
	console.log(response.body);
});

PHP
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
	CURLOPT_URL => 'https://api.pdf.co/v1/file/hash',
	CURLOPT_RETURNTRANSFER => true,
	CURLOPT_ENCODING => '',
	CURLOPT_MAXREDIRS => 10,
	CURLOPT_TIMEOUT => 0,
	CURLOPT_FOLLOWLOCATION => true,
	CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
	CURLOPT_CUSTOMREQUEST => 'POST',
	CURLOPT_POSTFIELDS =>'{
    "url": "https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/pdf-split/sample.pdf"
}',
	CURLOPT_HTTPHEADER => array(
		'x-api-key: ',
		'Content-Type: application/json'
	),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Java
import java.io.*;
import okhttp3.*;
public class main {
	public static void main(String []args) throws IOException{
		OkHttpClient client = new OkHttpClient().newBuilder()
			.build();
		MediaType mediaType = MediaType.parse("application/json");
		RequestBody body = RequestBody.create(mediaType, "{\n    \"url\": \"https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/pdf-split/sample.pdf\"\n}");
		Request request = new Request.Builder()
			.url("https://api.pdf.co/v1/file/hash")
			.method("POST", body)
			.addHeader("x-api-key", "")
			.addHeader("Content-Type", "application/json")
			.build();
		Response response = client.newCall(request).execute();
		System.out.println(response.body().string());
	}
}

C#
using System;
using RestSharp;
namespace HelloWorldApplication {
	class HelloWorld {
		static void Main(string[] args) {
			var client = new RestClient("https://api.pdf.co/v1/file/hash");
			client.Timeout = -1;
			var request = new RestRequest(Method.POST);
			request.AddHeader("x-api-key", "");
			request.AddHeader("Content-Type", "application/json");
			var body = @"{" + "\n" +
			@"    ""url"": ""https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/pdf-split/sample.pdf""" + "\n" +
			@"}";
			request.AddParameter("application/json", body,  ParameterType.RequestBody);
			IRestResponse response = client.Execute(request);
			Console.WriteLine(response.Content);
		}
	}
}

Python
import requests
import json

url = "https://api.pdf.co/v1/file/hash"

payload = json.dumps({
 "url": "https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/pdf-split/sample.pdf"
})
headers = {
	'x-api-key': '',
	'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

Powershell
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("x-api-key", "")
$headers.Add("Content-Type", "application/json")

$body = "{`n    `"url`": `"https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/pdf-split/sample.pdf`"`n}"

$response = Invoke-RestMethod 'https://api.pdf.co/v1/file/hash' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json