Getting started / Quickstart
Quickstart
This walks you from a new account to a generated PDF in about five minutes. You will use the Example invoice template that every new account starts with, so there is 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. You will find it on the
template in the dashboard (there is a copy button next to it). This is the value you pass as
templateId. It is not the same as the URL id in the dashboard, which is internal.
4. Send your first request
POST your data to /v1/generate with the key in the Authorization header. The response
body is the PDF.
curl -X POST https://api.pdfglyph.dev/v1/generate \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"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"
}
}' \
--output document.pdfReplace 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
201withContent-Type: application/pdf. The body is the raw PDF bytes, ready to save, email, or stream to your user. - An
X-Generation-Idheader identifying the logged generation, andX-Render-Duration-Mswith how long the render took.
If something is wrong, you get a JSON error instead of a PDF, shaped like
{ "error": { "code", "message" } }. 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
- Understand the moving parts in Core concepts.
- Build your own template with the Handlebars reference.
- See the full endpoint contract in Generate a document.
- Ship safely with Going to production.