curl --request POST \
--url https://api.pdf.co/v1/pdf/convert/from/email \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/email-to-pdf/sample.eml",
"margins": "10px 10px 10px 10px",
"papersize": "A4",
"orientation": "Portrait",
"embedattachments": true,
"convertattachments": true,
"name": "email-with-attachments",
"async": false,
"header": "<string>",
"footer": "<string>",
"expiration": 60,
"profiles": "{\"orientation\": \"landscape\", \"paperSize\": \"letter\" }",
"httpusername": "<string>",
"httppassword": "<string>"
}
'import requests
url = "https://api.pdf.co/v1/pdf/convert/from/email"
payload = {
"url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/email-to-pdf/sample.eml",
"margins": "10px 10px 10px 10px",
"papersize": "A4",
"orientation": "Portrait",
"embedattachments": True,
"convertattachments": True,
"name": "email-with-attachments",
"async": False,
"header": "<string>",
"footer": "<string>",
"expiration": 60,
"profiles": "{\"orientation\": \"landscape\", \"paperSize\": \"letter\" }",
"httpusername": "<string>",
"httppassword": "<string>"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
url: 'https://pdfco-test-files.s3.us-west-2.amazonaws.com/email-to-pdf/sample.eml',
margins: '10px 10px 10px 10px',
papersize: 'A4',
orientation: 'Portrait',
embedattachments: true,
convertattachments: true,
name: 'email-with-attachments',
async: false,
header: '<string>',
footer: '<string>',
expiration: 60,
profiles: '{"orientation": "landscape", "paperSize": "letter" }',
httpusername: '<string>',
httppassword: '<string>'
})
};
fetch('https://api.pdf.co/v1/pdf/convert/from/email', 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://api.pdf.co/v1/pdf/convert/from/email",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'url' => 'https://pdfco-test-files.s3.us-west-2.amazonaws.com/email-to-pdf/sample.eml',
'margins' => '10px 10px 10px 10px',
'papersize' => 'A4',
'orientation' => 'Portrait',
'embedattachments' => true,
'convertattachments' => true,
'name' => 'email-with-attachments',
'async' => false,
'header' => '<string>',
'footer' => '<string>',
'expiration' => 60,
'profiles' => '{"orientation": "landscape", "paperSize": "letter" }',
'httpusername' => '<string>',
'httppassword' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.pdf.co/v1/pdf/convert/from/email"
payload := strings.NewReader("{\n \"url\": \"https://pdfco-test-files.s3.us-west-2.amazonaws.com/email-to-pdf/sample.eml\",\n \"margins\": \"10px 10px 10px 10px\",\n \"papersize\": \"A4\",\n \"orientation\": \"Portrait\",\n \"embedattachments\": true,\n \"convertattachments\": true,\n \"name\": \"email-with-attachments\",\n \"async\": false,\n \"header\": \"<string>\",\n \"footer\": \"<string>\",\n \"expiration\": 60,\n \"profiles\": \"{\\\"orientation\\\": \\\"landscape\\\", \\\"paperSize\\\": \\\"letter\\\" }\",\n \"httpusername\": \"<string>\",\n \"httppassword\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.pdf.co/v1/pdf/convert/from/email")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"https://pdfco-test-files.s3.us-west-2.amazonaws.com/email-to-pdf/sample.eml\",\n \"margins\": \"10px 10px 10px 10px\",\n \"papersize\": \"A4\",\n \"orientation\": \"Portrait\",\n \"embedattachments\": true,\n \"convertattachments\": true,\n \"name\": \"email-with-attachments\",\n \"async\": false,\n \"header\": \"<string>\",\n \"footer\": \"<string>\",\n \"expiration\": 60,\n \"profiles\": \"{\\\"orientation\\\": \\\"landscape\\\", \\\"paperSize\\\": \\\"letter\\\" }\",\n \"httpusername\": \"<string>\",\n \"httppassword\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pdf.co/v1/pdf/convert/from/email")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"https://pdfco-test-files.s3.us-west-2.amazonaws.com/email-to-pdf/sample.eml\",\n \"margins\": \"10px 10px 10px 10px\",\n \"papersize\": \"A4\",\n \"orientation\": \"Portrait\",\n \"embedattachments\": true,\n \"convertattachments\": true,\n \"name\": \"email-with-attachments\",\n \"async\": false,\n \"header\": \"<string>\",\n \"footer\": \"<string>\",\n \"expiration\": 60,\n \"profiles\": \"{\\\"orientation\\\": \\\"landscape\\\", \\\"paperSize\\\": \\\"letter\\\" }\",\n \"httpusername\": \"<string>\",\n \"httppassword\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"status": "success",
"message": "Success",
"url": "https://pdf-temp-files.s3.us-west-2.amazonaws.com/output.pdf",
"jobId": "6YSZD3U872ZYYFEDMQCQSGEEO8YSF5WA",
"credits": 2,
"remainingCredits": 1480582,
"duration": 33
}{
"error": true,
"status": 400,
"message": "Bad request. Typically due to bad input parameters or unreachable input URLs (e.g., access restrictions like login or password)."
}{
"error": true,
"status": 401,
"message": "Unauthorized. Authentication is required and has failed or has not yet been provided."
}{
"error": true,
"status": 402,
"message": "Not enough credits."
}{
"error": true,
"status": 403,
"message": "Access forbidden for input URL."
}{
"error": true,
"status": 404,
"message": "The requested resource could not be found."
}{
"error": true,
"status": 408,
"message": "The server timed out waiting for the request."
}{
"error": true,
"status": 429,
"message": "Too many requests in a given time period."
}{
"error": true,
"status": 441,
"message": "Invalid Password. Password protected document."
}{
"error": true,
"status": 442,
"message": "Input document is damaged or of incorrect type."
}{
"error": true,
"status": 443,
"message": "Permissions. The operation is prohibited by document security settings."
}{
"error": true,
"status": 444,
"message": "Profiles parsing error. Please ensure that the configuration is supported."
}{
"error": true,
"status": 445,
"message": "Timeout error. For large documents, use asynchronous mode (async=true) and check status via /job/check."
}{
"error": true,
"status": 446,
"message": "Some files required for conversion are missing."
}{
"error": true,
"status": 447,
"message": "Invalid template."
}{
"error": true,
"status": 448,
"message": "Invalid URL or HTML. Ensure the provided URL is valid and accessible."
}{
"error": true,
"status": 449,
"message": "Invalid index range. Page index is out of range."
}{
"error": true,
"status": 450,
"message": "Invalid page range specified."
}{
"error": true,
"status": 452,
"message": "Invalid URL."
}{
"error": true,
"status": 454,
"message": "Invalid parameters."
}{
"error": true,
"status": 500,
"message": "Something went wrong. Please try again or contact support."
}PDF from Email (API Tester)
Run PDF from Email live from your browser — send a real request and see the response and credit usage, no code required. PDF.co API Tester.
curl --request POST \
--url https://api.pdf.co/v1/pdf/convert/from/email \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/email-to-pdf/sample.eml",
"margins": "10px 10px 10px 10px",
"papersize": "A4",
"orientation": "Portrait",
"embedattachments": true,
"convertattachments": true,
"name": "email-with-attachments",
"async": false,
"header": "<string>",
"footer": "<string>",
"expiration": 60,
"profiles": "{\"orientation\": \"landscape\", \"paperSize\": \"letter\" }",
"httpusername": "<string>",
"httppassword": "<string>"
}
'import requests
url = "https://api.pdf.co/v1/pdf/convert/from/email"
payload = {
"url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/email-to-pdf/sample.eml",
"margins": "10px 10px 10px 10px",
"papersize": "A4",
"orientation": "Portrait",
"embedattachments": True,
"convertattachments": True,
"name": "email-with-attachments",
"async": False,
"header": "<string>",
"footer": "<string>",
"expiration": 60,
"profiles": "{\"orientation\": \"landscape\", \"paperSize\": \"letter\" }",
"httpusername": "<string>",
"httppassword": "<string>"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
url: 'https://pdfco-test-files.s3.us-west-2.amazonaws.com/email-to-pdf/sample.eml',
margins: '10px 10px 10px 10px',
papersize: 'A4',
orientation: 'Portrait',
embedattachments: true,
convertattachments: true,
name: 'email-with-attachments',
async: false,
header: '<string>',
footer: '<string>',
expiration: 60,
profiles: '{"orientation": "landscape", "paperSize": "letter" }',
httpusername: '<string>',
httppassword: '<string>'
})
};
fetch('https://api.pdf.co/v1/pdf/convert/from/email', 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://api.pdf.co/v1/pdf/convert/from/email",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'url' => 'https://pdfco-test-files.s3.us-west-2.amazonaws.com/email-to-pdf/sample.eml',
'margins' => '10px 10px 10px 10px',
'papersize' => 'A4',
'orientation' => 'Portrait',
'embedattachments' => true,
'convertattachments' => true,
'name' => 'email-with-attachments',
'async' => false,
'header' => '<string>',
'footer' => '<string>',
'expiration' => 60,
'profiles' => '{"orientation": "landscape", "paperSize": "letter" }',
'httpusername' => '<string>',
'httppassword' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.pdf.co/v1/pdf/convert/from/email"
payload := strings.NewReader("{\n \"url\": \"https://pdfco-test-files.s3.us-west-2.amazonaws.com/email-to-pdf/sample.eml\",\n \"margins\": \"10px 10px 10px 10px\",\n \"papersize\": \"A4\",\n \"orientation\": \"Portrait\",\n \"embedattachments\": true,\n \"convertattachments\": true,\n \"name\": \"email-with-attachments\",\n \"async\": false,\n \"header\": \"<string>\",\n \"footer\": \"<string>\",\n \"expiration\": 60,\n \"profiles\": \"{\\\"orientation\\\": \\\"landscape\\\", \\\"paperSize\\\": \\\"letter\\\" }\",\n \"httpusername\": \"<string>\",\n \"httppassword\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.pdf.co/v1/pdf/convert/from/email")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"https://pdfco-test-files.s3.us-west-2.amazonaws.com/email-to-pdf/sample.eml\",\n \"margins\": \"10px 10px 10px 10px\",\n \"papersize\": \"A4\",\n \"orientation\": \"Portrait\",\n \"embedattachments\": true,\n \"convertattachments\": true,\n \"name\": \"email-with-attachments\",\n \"async\": false,\n \"header\": \"<string>\",\n \"footer\": \"<string>\",\n \"expiration\": 60,\n \"profiles\": \"{\\\"orientation\\\": \\\"landscape\\\", \\\"paperSize\\\": \\\"letter\\\" }\",\n \"httpusername\": \"<string>\",\n \"httppassword\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pdf.co/v1/pdf/convert/from/email")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"https://pdfco-test-files.s3.us-west-2.amazonaws.com/email-to-pdf/sample.eml\",\n \"margins\": \"10px 10px 10px 10px\",\n \"papersize\": \"A4\",\n \"orientation\": \"Portrait\",\n \"embedattachments\": true,\n \"convertattachments\": true,\n \"name\": \"email-with-attachments\",\n \"async\": false,\n \"header\": \"<string>\",\n \"footer\": \"<string>\",\n \"expiration\": 60,\n \"profiles\": \"{\\\"orientation\\\": \\\"landscape\\\", \\\"paperSize\\\": \\\"letter\\\" }\",\n \"httpusername\": \"<string>\",\n \"httppassword\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"status": "success",
"message": "Success",
"url": "https://pdf-temp-files.s3.us-west-2.amazonaws.com/output.pdf",
"jobId": "6YSZD3U872ZYYFEDMQCQSGEEO8YSF5WA",
"credits": 2,
"remainingCredits": 1480582,
"duration": 33
}{
"error": true,
"status": 400,
"message": "Bad request. Typically due to bad input parameters or unreachable input URLs (e.g., access restrictions like login or password)."
}{
"error": true,
"status": 401,
"message": "Unauthorized. Authentication is required and has failed or has not yet been provided."
}{
"error": true,
"status": 402,
"message": "Not enough credits."
}{
"error": true,
"status": 403,
"message": "Access forbidden for input URL."
}{
"error": true,
"status": 404,
"message": "The requested resource could not be found."
}{
"error": true,
"status": 408,
"message": "The server timed out waiting for the request."
}{
"error": true,
"status": 429,
"message": "Too many requests in a given time period."
}{
"error": true,
"status": 441,
"message": "Invalid Password. Password protected document."
}{
"error": true,
"status": 442,
"message": "Input document is damaged or of incorrect type."
}{
"error": true,
"status": 443,
"message": "Permissions. The operation is prohibited by document security settings."
}{
"error": true,
"status": 444,
"message": "Profiles parsing error. Please ensure that the configuration is supported."
}{
"error": true,
"status": 445,
"message": "Timeout error. For large documents, use asynchronous mode (async=true) and check status via /job/check."
}{
"error": true,
"status": 446,
"message": "Some files required for conversion are missing."
}{
"error": true,
"status": 447,
"message": "Invalid template."
}{
"error": true,
"status": 448,
"message": "Invalid URL or HTML. Ensure the provided URL is valid and accessible."
}{
"error": true,
"status": 449,
"message": "Invalid index range. Page index is out of range."
}{
"error": true,
"status": 450,
"message": "Invalid page range specified."
}{
"error": true,
"status": 452,
"message": "Invalid URL."
}{
"error": true,
"status": 454,
"message": "Invalid parameters."
}{
"error": true,
"status": 500,
"message": "Something went wrong. Please try again or contact support."
}Authorizations
Body
URL to the source file url attribute.
Set custom margins, overriding CSS default margins. Specify the margins in the format {top} {right} {bottom} {left}. You can usepx,mm,cmorinunits. Also, you can set margins for all sides at once using a single value.
"10px 10px 10px 10px"
Specifies the paper size. Accepts standard sizes like 'Letter', 'Legal', 'Tabloid', 'Ledger', 'A0'–'A6'. You can also set a custom size by providing width and height separated by a space, with optional units: px (pixels), mm (millimeters), cm (centimeters), or in (inches). Examples: '200 300', '200px 300px', '200mm 300mm', '20cm 30cm', '6in 8in'.
Letter, Legal, Tabloid, Ledger, A0, A1, A2, A3, A4, A5, A6 "A4"
Sets the document orientation. Options: Portrait for vertical layout, and Landscape for horizontal layout.
Portrait, Landscape File name for generated output.
Set async to true for long processes to run in the background, API will then return a jobId which you can use with the Background Job Check endpoint. Also see Webhooks & Callbacks
Set this to can add user definable HTML for the header to be applied on every page header. The format is html.
Set this to can add user definable HTML for the footer to be applied on every page bottom. The format is html.
Sets the expiration time for the output link, in minutes. After this period, generated output file(s) are automatically deleted from PDF.co Temporary Files Storage. The maximum allowed duration depends on your subscription plan. For permanent storage of input files (e.g., reusable images, PDF templates, documents), use PDF.co Built‑In Files Storage.
HTTP auth user name if required to access source URL.
HTTP auth password if required to access source URL.
Response
Success.
Status of the API response.
"success"
Descriptive message for the response status.
"Success"
URL to the output file.
"https://pdf-temp-files.s3.us-west-2.amazonaws.com/output.pdf"
Unique identifier for the job.
"6YSZD3U872ZYYFEDMQCQSGEEO8YSF5WA"
Credits used for this operation.
2
Credits remaining after this operation.
1480582
Time taken to complete the request, in milliseconds.
33
Was this page helpful?