Craftkitdocs

Quickstart

Render your first PDF from a template in under five minutes.

This walkthrough takes you from zero to a rendered PDF in five minutes. You'll create a project, design a template visually, mint an API key, hit the render endpoint, and download the result.

Quick Start

End-to-end, in three calls: render, poll, download. The same operation in three languages:

curl

# 1. Enqueue a render
curl -X POST https://api.craftkit.dev/v1/templates/invoice/render \
  -H "Authorization: Bearer $CRAFTKIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"data": {"customer": {"name": "Acme Corp"}}}'

# 2. Poll until succeeded (returns downloadUrl when done)
curl https://api.craftkit.dev/v1/renders/<id> \
  -H "Authorization: Bearer $CRAFTKIT_API_KEY"

# 3. Download the PDF
curl -L "<downloadUrl>" -o invoice.pdf

Node.js

const headers = {
  Authorization: `Bearer ${process.env.CRAFTKIT_API_KEY}`,
  'Content-Type': 'application/json',
};

const enqueue = await fetch('https://api.craftkit.dev/v1/templates/invoice/render', {
  method: 'POST',
  headers,
  body: JSON.stringify({ data: { customer: { name: 'Acme Corp' } } }),
});
const { id, pollUrl } = await enqueue.json();

let job;
do {
  await new Promise((r) => setTimeout(r, 250));
  job = await (await fetch(pollUrl, { headers })).json();
} while (job.status === 'queued' || job.status === 'rendering');

console.log('PDF ready at:', job.downloadUrl);

Python

import os, time, requests

headers = {"Authorization": f"Bearer {os.environ['CRAFTKIT_API_KEY']}"}

enqueue = requests.post(
    "https://api.craftkit.dev/v1/templates/invoice/render",
    headers=headers,
    json={"data": {"customer": {"name": "Acme Corp"}}},
).json()

job = enqueue
while job["status"] in ("queued", "rendering"):
    time.sleep(0.25)
    job = requests.get(enqueue["pollUrl"], headers=headers).json()

print("PDF ready at:", job["downloadUrl"])

Step 1 — Create a project

Sign in at app.craftkit.dev and create a project. A project is the unit that owns templates, API keys, webhooks, and rendered assets.

Step 2 — Design a template

Inside the project, click + New template and pick a builder mode:

Mode When to use it
Document canvas Paginated A4/Letter with headers, footers, and signatures. Use for contracts, certificates, invoices.
Simple flow A continuous document. Use for receipts, transactional emails, short one-pagers.

Use the toolbar to insert a Variable block. Give it a key path like customer.name and mark it required. Click Publish version when you're happy.

Step 3 — Mint an API key

Open the project's API keys tab and create one. The cleartext key is shown once — copy it immediately and store it as a server-side secret.

Step 4 — Render

The Quick Start above shows the full enqueue → poll → download cycle. Most renders complete in under 200ms. If you'd rather hold the connection open instead of polling, set options.sync: true on the request.

Tips

  • Pin renders to a specific version with options.versionNumber for deterministic output across template edits.
  • Use the dashboard's Renders tab to inspect every call: input data, duration, output asset, and which API key triggered it.
  • For high volume, configure an outgoing webhook (project settings) so Craftkit posts to you on completion — no polling needed.