On this page

Quickstart

Make your first call to docsgen, receive the PDF on your server and pass it on to your user, in four steps.

The call

A POST with the key in the header and the body in JSON. The response is the raw PDF, with content-type: application/pdf.

POST /api/documents
curl -X POST "https://docsgen.piensait.com/api/documents" \
  -H "authorization: Bearer $DOCGEN_API_KEY" \
  -H "content-type: application/json" \
  -d @cuenta-de-cobro.json \
  -o cuenta.pdf

Passing the PDF on to your user

The usual next step is to re-send it to the user with whatever file name suits you:

return new Response(pdf, {
  headers: {
    'content-type': 'application/pdf',
    'content-disposition': `attachment; filename="CuentaCobro-${numero}.pdf"`,
  },
});

The call is always made from your server, never from the browser. See Authentication.

Example bodies

There is a complete example body for each type, and they are not merely illustrative: they are part of our automated tests. Every time we touch the engine they are generated again, so if one ever stopped working, we would find out before you do.

Type Example
factura factura.json
cuenta-de-cobro cuenta-de-cobro.json
recibo-de-caja recibo-de-caja.json
contrato contrato.json
factura with a design factura-premium.json
factura as a POS receipt factura-tirilla.json
nota-credito nota-credito.json
nota-debito nota-debito.json
recibo-de-caja with a design recibo-de-caja-premium.json
estado-de-cuenta estado-de-cuenta.json
colilla-de-nomina colilla-de-nomina.json
colilla-de-nomina with integral salary colilla-de-nomina-integral.json
informe, portrait informe.json
informe, landscape informe-horizontal.json
entrada-de-inventario entrada-de-inventario.json
salida-de-inventario salida-de-inventario.json
traslado-de-inventario traslado-de-inventario.json

The fastest way to start is to take the example for your type, replace its data with yours and send it. Then trim whatever doesn’t apply.

Getting started

  1. Write to us and we will hand over your key. It is shown only once, when it is handed over: we don’t store it anywhere, so if it gets lost we issue another one.
  2. Take the example for your document type and send it as is, without changing anything: you should get a PDF back. This step separates a connection problem from a data problem.
  3. Replace it with your real data, field by field.
  4. Call from your server, never from the browser.