Getting started / Quickstart

Quickstart

This walks you from a new account to a generated PDF in about five minutes. You'll use the Example invoice template that every new account starts with, so there's nothing to build first.

1. Create an account

Sign up with an email and password. Every new account is seeded with a published Example invoice template, so the template list is never empty and your first render works immediately. No credit card is required, and the Free plan stays free.

2. Create an API key

Open API keys in the dashboard and create a key. The full key is shown once, at creation, so copy it somewhere safe right away. Keys begin with sb_.

The key is the only secret in the request. Only a hash of it is stored, so it can never be shown again. If you lose it, revoke it and create a new one.

3. Find your template id

Each template has a public id that looks like tpl_invoice_8x2k. It's shown on the template in the dashboard (there's a copy button next to it). This is the value you pass as templateId. It's not the same as the URL id in the dashboard, which is internal.

4. Send your first request

The fastest path is the official TypeScript SDK (npm install pdfglyph), which handles the endpoint, auth header, typed errors, and retries for you. Prefer raw HTTP? POST your data to /v1/generate with the key in the Authorization header, and the response body is the PDF. Both are below:

import { writeFile } from "node:fs/promises";
import { PdfGlyph } from "pdfglyph";

const client = new PdfGlyph({
  apiKey: "YOUR_API_KEY",
  baseUrl: "https://api.pdfglyph.dev",
});

const { pdf } = await client.generate({
  templateId: "tpl_invoice_8x2k",
  data: {
    "customer": "Northwind Ltd",
    "number": "INV-2048",
    "items": [
      {
        "description": "Consulting",
        "amount": "€900.00"
      },
      {
        "description": "Support",
        "amount": "€340.00"
      }
    ],
    "total": "€1,240.00"
  },
});

// pdf is a Uint8Array — write it to a file, return it, or stream it.
await writeFile("document.pdf", pdf);

Replace YOUR_API_KEY with the key from step 2 and tpl_invoice_8x2k with your own template id. The data object fills the template's variables.

5. Read the response

On success you get:

  • HTTP 201 with Content-Type: application/pdf. The body is the raw PDF bytes, ready to save, email, or stream to your user.
  • An X-Generation-Id header identifying the logged generation, and X-Render-Duration-Ms with how long the render took. (The SDK surfaces these as generationId and durationMs on the result.)

If something is wrong, you get a JSON error instead of a PDF, shaped like { "error": { "code", "message" } }. The SDK throws it as a typed error class instead. See Errors for the full list. A failed call never counts against your quota.

Using curl? Add --output document.pdf so the bytes are written to a file instead of your terminal. The cURL tab above already does this.

Next steps