INTEGRAZIONE / V1

La tua prima richiesta PDF.

Un template, una API key e JSON. La guida usa gli stessi dati inventati dell’anteprima in homepage.

01 / Crea il tuo template

Apri la Console, salva l’HTML di esempio come template e copia il suo template_id. Crea una API key per lo stesso account. Conservala sul server in SYSINVOICE_API_KEY; non inserirla nel codice del browser.

Console

Il template di esempio

Questo esempio A4 minimale supporta una riga con quantità 1. Per fatture più complesse calcola i totali nella tua applicazione. Il CSS è incorporato; non servono risorse remote o script.

Scarica il template HTML
Il template di esempio
<!doctype html>
<html lang="en"><head><meta charset="utf-8">
<style>
@page { size: A4; margin: 0; }
* { box-sizing: border-box; }
body { margin: 0; padding: 64px; color: #15223b; font: 15px Arial, sans-serif; }
header { display: flex; justify-content: space-between; border-bottom: 3px solid #0891b2; padding-bottom: 32px; }
h1 { font-size: 38px; margin: 0 0 10px; letter-spacing: -1px; }
h2 { font-size: 16px; margin: 0 0 8px; }
p { line-height: 1.7; }
.muted { color: #526078; font-size: 12px; }
.meta { margin: 38px 0; display: flex; justify-content: space-between; }
table { width: 100%; border-collapse: collapse; margin-top: 42px; }
th { padding: 14px 8px; text-align: left; background: #f1f5f9; color: #526078; font-size: 11px; }
td { padding: 22px 8px; border-bottom: 1px solid #dbe2eb; }
.right { text-align: right; }
.total { display: flex; justify-content: space-between; margin-top: 30px; padding: 24px 8px; background: #ecfeff; font-weight: bold; font-size: 20px; }
footer { margin-top: 180px; padding-top: 20px; border-top: 1px solid #dbe2eb; }
</style></head><body>
<header><div><h2>NORTHSTAR / STUDIO</h2><span class="muted">Digital products &amp; engineering</span></div><span class="muted">INVOICE</span></header>
<div class="meta"><div><h1>{{ .invoice_number }}</h1><span class="muted">Issued {{ .issued_at }}</span></div><div><span class="muted">BILL TO</span><p>Acme Labs<br>Sample account</p></div></div>
<table><thead><tr><th>DESCRIPTION</th><th class="right">QTY</th><th class="right">AMOUNT</th></tr></thead><tbody>
{{ range .line_items }}<tr><td>{{ .description }}</td><td class="right">{{ .qty }}</td><td class="right">{{ .amount }} {{ $.currency }}</td></tr>{{ end }}
</tbody></table>
<div class="total"><span>Total</span><span>{{ .total }} {{ .currency }}</span></div>
<p class="muted">Thank you for building with us.</p>
<footer class="muted">SysInvoice / Fictional example / One line item, quantity 1 / 01</footer>
</body></html>

02 / Esegui la richiesta

Sostituisci tpl_your_invoice_template con l’ID restituito dalla Console. Il corpo JSON accetta template_id e document_data, con dimensione massima di 2 MiB. L’esempio è illustrativo e non chiama l’API da questo sito.

Richiesta
curl --fail-with-body --request POST \  https://api.sysinvoice.com/v1/invoices/generate \  --header "Authorization: Bearer $SYSINVOICE_API_KEY" \  --header 'Content-Type: application/json' \  --header 'Accept: application/pdf' \  --data '{  "template_id": "tpl_your_invoice_template",  "document_data": {    "invoice_number": "INV-2026-001",    "issued_at": "2026-11-10",    "currency": "EUR",    "line_items": [      {        "description": "API integration",        "qty": 1,        "price": 240,        "amount": "240.00"      }    ],    "total": "240.00"  }}' \  --output invoice.pdf
Solo esempio: imposta la tua API key e sostituisci template_id con l’ID del template salvato.

03 / Gestisci la risposta

La richiesta riuscita restituisce HTTP 200 e byte application/pdf, con Cache-Control: no-store e X-Request-Id per la diagnostica. Salva o trasmetti la risposta dalla tua applicazione.

Apri il PDF di esempio

Gestisci esplicitamente gli errori

JSON malformato restituisce 400; credenziali non valide 401; template sconosciuto 404; dati non validi 422. Con 429 rispetta Retry-After. Con --fail-with-body, cURL termina con errore per risposte HTTP di errore: controlla la risposta prima di trattare il file come PDF.