DocShotAPI docs

Getting started

Create an account, copy your API key from API keys, and send it as a bearer token. Base URL: https://api.docshotapi.com.

curl https://api.docshotapi.com/v1/pdf \
  -H "Authorization: Bearer ds_live_..." \
  -H "Content-Type: application/json" \
  -d '{"html": "<h1>Hello</h1>"}' -o hello.pdf

Check your plan and remaining credits with GET /v1/account.

Response modes

  • "response": "binary" (default for files): the file itself, with X-Job-Id, X-Credits and X-Pages headers.
  • "response": "json": a job object whose result.file.url is a signed link that expires (expires_in_days, up to your plan's limit).
  • "response": "async": returns 202 immediately. Poll GET /v1/jobs/{id} or pass webhook_url.

PDFs: POST /v1/pdf

Give exactly one source: html, url, or template_id with data.

{
  "url": "https://example.com/report",
  "format": "A4", "landscape": false,
  "margin": {"top": "15mm", "bottom": "15mm", "left": "12mm", "right": "12mm"},
  "page_numbers": true,
  "header_html": "<div style='font-size:9px;width:100%;text-align:right;padding-right:12mm'>Q3 report</div>",
  "wait_for": "#chart-ready", "delay_ms": 500,
  "css": ".no-print { display: none }",
  "response": "json"
}

Other options: width/height (custom size), print_background, scale, page_ranges, media (print or screen), scroll (trigger lazy-loading), block_ads, hide_cookie_banners, hide_selectors, base_url (for relative links in html), user_agent. Header and footer HTML may use <span class="pageNumber">, totalPages, date and title.

Templates

Templates are HTML + CSS with Jinja2 variables, loops and conditionals. Build them in the dashboard editor (live preview, starter gallery, AI generator) or through /v1/templates. Every save creates a new version; pass template_version to pin one.

<h1>Invoice {{ number }}</h1>
{% for item in items %}
  <tr><td>{{ item.name }}</td><td>{{ item.price|money("$") }}</td></tr>
{% endfor %}
<p>Due {{ due|date("%d %B %Y") }}</p>

Values are HTML-escaped. Extra filters: money, number, date. Generate a template from a description or an example PDF with POST /v1/templates/generate (multipart: prompt, optional example file, optional save_as; 5 credits).

Screenshots: POST /v1/screenshot

{
  "url": "https://example.com",
  "full_page": true,
  "device": "iPhone 15",
  "format": "webp", "quality": 80,
  "dark_mode": false, "retina": false,
  "block_ads": true, "hide_cookie_banners": true,
  "hide_selectors": [".chat-widget"],
  "selector": null, "wait_for": null, "delay_ms": 0, "scroll": true
}

Without device, set viewport_width and viewport_height. Formats: png, jpeg, webp, pdf. transparent gives a PNG without a background. Full-page captures stop at 16,384 px tall.

AI extraction: POST /v1/extract

Send a PDF or image (multipart file) or a url, plus a JSON Schema (schema), a built-in preset (invoice, receipt, contract, form) or a saved schema_id. You get data matching your schema, a confidence score (0 to 1) for each top-level field, and notes. Scanned documents and photos work. 3 credits per page, up to 50 pages.

curl https://api.docshotapi.com/v1/extract -H "Authorization: Bearer ds_live_..." \
  -F file=@invoice.pdf \
  -F 'schema={"type":"object","properties":{"invoice_number":{"type":"string"},"total":{"type":"number"},"due_date":{"type":"string","format":"date"}},"required":["total"]}'

Optional instructions (up to 2,000 characters) steer what to extract. Uploaded documents are deleted as soon as the job finishes, and are never used to train models.

PDF utilities

Each takes multipart files (file or repeated files) or JSON with url/urls, plus options:

  • POST /v1/pdf/merge: 2 to 50 PDFs, in order.
  • POST /v1/pdf/split: ranges such as "1-3,4-10" or every N pages; returns a ZIP.
  • POST /v1/pdf/compress: quality low | medium | high.
  • POST /v1/pdf/watermark: text, opacity, angle, font_size, color.
  • POST /v1/pdf/rotate: degrees, optional pages.
  • POST /v1/pdf/to-images: format, dpi, pages; one image or a ZIP.
  • POST /v1/pdf/form-fields (free) and POST /v1/pdf/fill-form (fields object, flatten).
  • POST /v1/convert/office: Word, Excel, PowerPoint, OpenDocument, CSV or RTF to PDF (2 credits).

Webhooks

With webhook_url we POST {"event": "job.succeeded" | "job.failed", "job": {...}} when the job ends, retrying up to 3 more times. Verify the DocShot-Signature header (t=<unix>,v1=<hex>) with the secret from Settings:

import hmac, hashlib
def verify(secret, header, body: bytes):
    parts = dict(p.split("=", 1) for p in header.split(","))
    mac = hmac.new(secret.encode(), f"{parts['t']}.".encode() + body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(mac, parts["v1"])

Errors & limits

Errors look like {"error": {"code": "...", "message": "..."}}. Common codes: 400 invalid_request, 401 unauthorized, 402 insufficient_credits, 413 (too large), 422 (the page or document could not be processed), 429 rate_limited (see Retry-After), 504 render_timeout. Failed jobs are refunded.

Limits: 30 s per render, 5 MB of HTML, 25 MB uploads, 500 pages per PDF, requests per minute by plan. URLs must be public: private and internal addresses are refused.

Make, n8n, Zapier and MCP

  • Make: search for DocShotAPI in the scenario editor and paste your API key.
  • n8n: install the community node n8n-nodes-docshotapi.
  • Zapier: search for DocShotAPI and connect with your API key.
  • AI agents: run the MCP server (uvx docshotapi-mcp) with DOCSHOT_API_KEY set; tools: generate_pdf, screenshot, extract_data, merge_pdfs.