Skip to Content
Getting StartedYour First Render

Your First Render

You need three things from the previous steps:

  1. your secret key (sk_live_…) in a REFORGIO_SECRET_KEY env var,
  2. the ID of a published template (open the template in the dashboard — the ID is in the URL),
  3. @reforgio/sdk-core installed.

Render from Node.js

first-render.ts
import { ReforgioServer, ReforgioError } from '@reforgio/sdk-core/server' const reforgio = new ReforgioServer(process.env.REFORGIO_SECRET_KEY!) async function main(): Promise<void> { try { const doc = await reforgio.render('YOUR_TEMPLATE_ID', { invoice_number: 'INV-2026-001', customer_name: 'ACME Corp', items: [{ name: 'Design work', quantity: 10, price: 120 }], }) console.log(`Rendered in ${doc.renderTimeMs}ms (${doc.fileSizeBytes} bytes)`) console.log(`Download: ${doc.downloadUrl}`) } catch (err) { if (err instanceof ReforgioError) { // API errors carry the HTTP status and the server's message console.error(`Render failed (${err.statusCode}): ${err.message}`) process.exitCode = 1 return } throw err // network/unexpected errors } } void main()

Replace YOUR_TEMPLATE_ID and the data keys with your template’s actual variables, then:

REFORGIO_SECRET_KEY=sk_live_... npx tsx first-render.ts

A successful render responds with:

{ "documentId": "cm1a2b3c4d", "status": "completed", "downloadUrl": "https://…presigned storage URL…", "fileSizeBytes": 54321, "renderTimeMs": 320 }

Open downloadUrl in a browser — that’s your PDF. Pass 'xlsx' as the third argument to render for spreadsheet output (the template must have the XLSX format enabled and contain a table section).

If it fails

ErrorFix
401 Missing x-api-key header / Invalid API keyThe env var isn’t set or the key was mistyped/rotated
404 Template not foundWrong template ID (or it belongs to another organization)
400 Template is not publishedPublish the template in the dashboard first

The full catalog with every exact message is in Errors.

downloadUrl is a presigned, time-limited URL (about an hour by default). Don’t persist it — store documentId and request GET /v1/downloads/:id when you need a fresh link. Details in Backend rendering.

Where next