Skip to content
CastPDF
Documentation menu
Getting started

Documentation

How to generate PDFs with the CastPDF API, from HTML or from Liquid templates with JSON data.

On this page

CastPDF turns HTML into PDF over a small REST API. You either send HTML (and optional CSS) directly, or you store an HTML template with Liquid placeholders once and send only the JSON data for each document. Chromium renders the page; in print mode, Paged.js handles pagination, repeating table headers and page margin content.

Start here

  • Quickstart: create a test key and render your first PDF with curl, Node.js or Python.
  • Authentication and keys: test keys and live keys, the watermark and the limits of each.
  • API reference: every endpoint under /v1, with request fields, limits, responses and examples.
  • Errors and rate limits: every error code, its HTTP status and what to do about it.

Guides

  • Templates and versions: store templates, update them (every change is a new version), pin a version and preview it.
  • Print CSS: page size and margins, page breaks, repeating table headers, running headers, page numbers and fonts.
  • Usage and billing: what counts as a document (from a live key or the dashboard's Generate PDF button), rollover, overage and the spending cap, idempotency and file retention.

Reference

  • Liquid reference: the template language, the CastPDF filters and the sandbox limits.

The API at a glance

  • Base URL: https://api.castpdf.com/v1, JSON in and out (PDFs are returned as application/pdf).
  • Authentication: Authorization: Bearer YOUR_API_KEY on every request.
  • Every response carries an x-request-id header. Quote it when you contact support.
  • Errors always have the same shape: error.code, error.message and error.docs_url, which links to the code on the errors page.