Convert Endpoint

The /convert endpoint accepts HTML content, a URL, or a stored template and returns a signed URL to download the generated PDF.

Try It Out

Test the API directly from your browser:

Try it out

Sign in to manage your API keys, or paste one below.

{
  "html": "<!DOCTYPE html>\n<html>\n<head>\n  <style>\n    body { font-family: system-ui, sans-serif; padding: 40px; }\n    h1 { color: #1a1a1a; }\n  </style>\n</head>\n<body>\n  <h1>Hello from PDFShot!</h1>\n  <p>This PDF was generated from HTML.</p>\n</body>\n</html>",
  "options": {
    "format": "A4",
    "margin": "1in",
    "landscape": false,
    "printBackground": true
  }
}

Endpoint

POST https://convert.pdfshot.com/convert

Headers

HeaderValueRequired
AuthorizationBearer YOUR_API_KEYYes
Content-Typeapplication/jsonYes

Request Body

You must provide exactly one input source: html, url, or templateId.

From HTML

{
  "html": "<!DOCTYPE html><html><body><h1>Hello</h1></body></html>",
  "options": {
    "format": "A4"
  }
}

From URL

{
  "url": "https://pdfshot.com/demo/invoice",
  "options": {
    "format": "Letter"
  }
}

From Template

Render a stored template with variable substitution:

{
  "templateId": "550e8400-e29b-41d4-a716-446655440000",
  "variables": {
    "customerName": "Acme Corp",
    "invoiceNumber": "INV-001",
    "items": [
      { "name": "Widget Pro", "qty": 2, "price": 50.00 },
      { "name": "Service Fee", "qty": 1, "price": 25.00 }
    ]
  },
  "options": {
    "format": "A4"
  }
}

Templates are created in your Dashboard and use Handlebars syntax for variable substitution. See Templates Guide for more details.

Parameters

Input (choose one)

ParameterTypeDescription
htmlstringHTML content to render. Max 10MB.
urlstringHTTPS URL to render. Must be publicly accessible.
templateIdstringUUID of a stored template. Create templates in your Dashboard.

Template Variables

ParameterTypeDescription
variablesobjectKey-value pairs for Handlebars variable substitution. Required when using templateId.

Options (all optional)

ParameterTypeDefaultDescription
formatstring"A4"Page size: A4, Letter, Legal, Tabloid, or custom
marginstring or object"0"Page margins
landscapebooleanfalseLandscape orientation
printBackgroundbooleanfalsePrint CSS backgrounds
pageRangesstringallPages to include, e.g., "1-5" or "1,3,5"
scalenumber1.0Scale factor (0.1 to 2.0)
headerTemplatestringnoneHTML header template
footerTemplatestringnoneHTML footer template

See Options Reference for detailed documentation.

Response

Success (200)

{
  "success": true,
  "url": "https://pdf.pdfshot.com/abc123...",
  "expiresAt": "2025-01-01T13:00:00.000Z",
  "fileSizeBytes": 45321,
  "processingTimeMs": 2340
}
FieldTypeDescription
successbooleanAlways true for successful responses
urlstringSigned URL to download the PDF (valid for 1 hour)
expiresAtstringISO 8601 timestamp when the URL expires
fileSizeBytesnumberPDF file size in bytes
processingTimeMsnumberTotal render time in milliseconds

Error (4xx/5xx)

{
  "success": false,
  "error": {
    "code": "VALIDATION_FAILED",
    "message": "HTML content is required when url is not provided"
  }
}

See Error Codes for all possible errors.

URL Security

When using the url parameter:

  • Must use HTTPS (HTTP is rejected)
  • Private IP addresses are blocked (localhost, 10.x.x.x, 192.168.x.x, etc.)
  • AWS metadata endpoints are blocked

This prevents server-side request forgery (SSRF) attacks.

Size Limits

  • Maximum HTML size: 10MB
  • Maximum render time: 2 minutes (timeout)

Billing

Usage is billed by render time, not by request count.

  • Free tier: 5 minutes/month
  • After free tier: $0.20 per render minute

A typical single-page document renders in 1-3 seconds.