Getting Started
Send HTML, a URL, or a stored template, get back a signed download link to your PDF.
Quick Example
const response = await fetch('https://convert.pdfshot.com/convert', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
html: '<h1>Hello World</h1>',
options: { format: 'A4' }
})
})
const { url } = await response.json()
import requests
response = requests.post(
'https://convert.pdfshot.com/convert',
headers={
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
json={
'html': '<h1>Hello World</h1>',
'options': { 'format': 'A4' }
}
)
url = response.json()['url']
payload := map[string]interface{}{
"html": "<h1>Hello World</h1>",
"options": map[string]string{"format": "A4"},
}
body, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST",
"https://convert.pdfshot.com/convert",
bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
require 'net/http'
require 'json'
uri = URI('https://convert.pdfshot.com/convert')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['Authorization'] = 'Bearer YOUR_API_KEY'
request['Content-Type'] = 'application/json'
request.body = {
html: '<h1>Hello World</h1>',
options: { format: 'A4' }
}.to_json
response = http.request(request)
url = JSON.parse(response.body)['url']
$ch = curl_init('https://convert.pdfshot.com/convert');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer YOUR_API_KEY',
'Content-Type: application/json'
],
CURLOPT_POSTFIELDS => json_encode([
'html' => '<h1>Hello World</h1>',
'options' => ['format' => 'A4']
])
]);
$response = curl_exec($ch);
$url = json_decode($response, true)['url'];
curl -X POST https://convert.pdfshot.com/convert \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"html": "<h1>Hello World</h1>",
"options": { "format": "A4" }
}'
Response:
{
"success": true,
"url": "https://pdf.pdfshot.com/abc123...",
"expiresAt": "2025-01-01T13:00:00.000Z"
}
How It Works
- Send a request with HTML content, a URL, or a template ID
- PDFShot renders the page to PDF
- Get a signed URL to download your PDF (valid for 1 hour)
Using Templates
For repeated documents like invoices, create a template in your Dashboard, then render with variables:
const response = await fetch('https://convert.pdfshot.com/convert', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
templateId: 'your-template-id',
variables: {
customerName: 'Acme Corp',
invoiceNumber: 'INV-001',
total: 125.00
}
})
})
const { url } = await response.json()
response = requests.post(
'https://convert.pdfshot.com/convert',
headers={
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
json={
'templateId': 'your-template-id',
'variables': {
'customerName': 'Acme Corp',
'invoiceNumber': 'INV-001',
'total': 125.00
}
}
)
curl -X POST https://convert.pdfshot.com/convert \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"templateId": "your-template-id",
"variables": {
"customerName": "Acme Corp",
"invoiceNumber": "INV-001",
"total": 125.00
}
}'
Templates use Handlebars syntax for variable substitution. See the Templates Guide for more details.
Get Your API Key
- Sign up for a free account
- Go to your Dashboard
- Create a new API key
- Copy the key (you'll only see it once)
The free tier includes 5 render minutes per month. That's roughly 150 typical single-page documents.
Base URL
All API requests go to:
https://convert.pdfshot.com
Next Steps
- Authentication - Learn about API key security
- Convert Endpoint - Full API reference
- Templates - Reusable layouts with variables
- Options - Customize your PDFs
- Code Examples - Copy-paste snippets for your language