Rellenar formulario PDF
Rellenar formulario es una API que mete datos en una plantilla PDF que ya tiene campos de formulario (esos PDF donde puedes hacer clic y escribir). Perfecto para generar contratos, solicitudes o fichas rellenas desde n8n, Make o Zapier, sin montar servidores.
Cómo funciona
Necesitas una plantilla PDF con campos de formulario ya creados (no vale un PDF normal sin campos; los formularios rellenables se hacen con Adobe Acrobat u otro editor de formularios). Le mandas la plantilla y un objeto con los valores, y te devuelve el PDF relleno.
¿No sabes qué campos tiene tu plantilla? Llama a la API SIN el objeto de datos y te devuelve la lista de campos disponibles (su nombre y tipo) en vez de rellenar nada — así puedes descubrirlos antes de automatizar. Esto también gasta 1 crédito, igual que rellenar.
Lo único que necesitas
- Tu API key. La creas en tu panel con "+ Crear llave". Se muestra una sola vez, así que cópiala y guárdala.
- En tu plataforma de automatización, un paso de tipo "HTTP Request" / "Hacer una petición HTTP" (lo tienen n8n, Make, Zapier, Pipedream…).
- Tu plantilla PDF con campos de formulario.
Paso 1: descubre los campos de tu plantilla
En el nodo HTTP Request de n8n:
- Method:
POST - URL:
https://api.cofferdock.com/pdf-fill-form - Send Headers: actívalo y añade dos:
x-api-key= tu llave, yContent-Type=application/pdf - Send Body: actívalo → elige la opción para mandar un archivo binario (en n8n: "n8n Binary File", con la propiedad binaria de tu plantilla, normalmente
data)
La respuesta trae la lista de campos con su nombre y tipo, por ejemplo: { "fields": [{ "name": "nombre_cliente", "type": "text" }, { "name": "acepto", "type": "checkbox" }] }. Usa esos nombres exactos en el paso 2.
Paso 2: rellena la plantilla
Cambia el cuerpo a JSON (para poder mandar la plantilla y los datos juntos):
- Send Body: JSON →
{ "file": "<tu plantilla en base64>", "data": { "nombre_cliente": "Ana García", "acepto": true } } - Send Headers:
x-api-key= tu llave,Content-Type=application/json - En Options → Response → Response Format: elige File (la respuesta ya es el PDF relleno)
Convierte tu plantilla a base64 con un nodo Code y la expresión {{'{{'}}$binary.data.toString('base64'){{'}}'}}, o con el nodo Move Binary Data.
Si un nombre de campo no existe en la plantilla (por ejemplo un typo), esa llamada NO falla: rellena los campos que sí reconoce y avisa de los que no en la cabecera X-Warnings (o en warnings si pides output=json).
Opciones (en el JSON)
| Opción | Por defecto | Para qué sirve |
|---|---|---|
data | — | Objeto con { "nombre_del_campo": "valor" }. Si lo omites, la API responde con la lista de campos en vez de rellenar. |
flatten | false | true deja el PDF "congelado": los valores ya no se pueden editar en un lector de PDF. |
Resumen de la API
- Endpoint:
POST https://api.cofferdock.com/pdf-fill-form - Auth: cabecera
x-api-key: TU_LLAVE. - Entrada: la plantilla va como
application/pdfa pelo (condatacomo JSON url-encoded en Query) o como JSON con{ file, data, flatten, inspect }. - Modo: sin
data(o coninspect=true) → inspección, devuelvefields. Condata(aunque sea{}) → relleno. - Salida del relleno: PDF binario por defecto; con
output=jsondevuelve{ pdf, warnings, meta }en base64. - Campos desconocidos: no bloquean la llamada, van a
warnings(o a la cabeceraX-Warningsen modo binario, con el número de avisos). - Límites: plantilla hasta 20 MB (50 MB en Business/Scale) en modo
application/pdf, o ~4 MB reales en JSON con base64. 30 peticiones/min por IP. 1 llamada = 1 crédito (inspeccionar o rellenar, por igual).
Tipos de campo soportados
| Tipo | Valor esperado en data |
|---|---|
text | Cualquier texto. |
checkbox | true/false. |
radio / dropdown / list | Uno de los valores de options (los ves en el modo inspección). |
button / signature | No se pueden rellenar por API; si aparecen en data, van a warnings. |
Ejemplos
curl (inspeccionar campos):
curl -X POST "https://api.cofferdock.com/pdf-fill-form" \
-H "x-api-key: TU_LLAVE" \
-H "Content-Type: application/pdf" \
--data-binary @plantilla.pdf
JavaScript (Node 18+, rellenar):
const fs = require('fs');
const r = await fetch('https://api.cofferdock.com/pdf-fill-form', {
method: 'POST',
headers: { 'x-api-key': 'TU_LLAVE', 'Content-Type': 'application/json' },
body: JSON.stringify({
file: fs.readFileSync('plantilla.pdf').toString('base64'),
data: { nombre_cliente: 'Ana García', acepto: true },
}),
});
fs.writeFileSync('relleno.pdf', Buffer.from(await r.arrayBuffer()));
Python (rellenar y aplanar):
import requests, base64
r = requests.post(
'https://api.cofferdock.com/pdf-fill-form',
headers={'x-api-key': 'TU_LLAVE', 'Content-Type': 'application/json'},
json={
'file': base64.b64encode(open('plantilla.pdf', 'rb').read()).decode(),
'data': {'nombre_cliente': 'Ana García', 'acepto': True},
'flatten': True,
},
)
open('relleno.pdf', 'wb').write(r.content)
Respuesta del modo inspección
{ "success": true, "mode": "inspect",
"fields": [
{ "name": "nombre_cliente", "type": "text", "value": "" },
{ "name": "acepto", "type": "checkbox", "value": false },
{ "name": "pais", "type": "dropdown", "options": ["ES","US","MX"], "value": null }
],
"meta": { "total_fields": 3, "used": 12, "remaining": 488 } }
Respuesta del relleno (con output=json)
{ "success": true, "mode": "fill", "pdf": "JVBERi0xLjQ…", "mime_type": "application/pdf",
"warnings": ["Unknown field: \"nombre_clientee\""],
"meta": { "fields_filled": 2, "flattened": false, "used": 13, "remaining": 487 } }
Lo que recibes
En modo inspección: un JSON con la lista de campos. En modo relleno: el PDF relleno directamente (o en base64 con output=json).
Fill PDF form
Fill form is an API that puts data into a PDF template that already has form fields (the kind of PDF where you can click and type). Great for generating filled contracts, applications or forms from n8n, Make or Zapier, with no servers to maintain.
How it works
You need a PDF template with form fields already built in (a plain PDF with no fields won't work; fillable forms are made with Adobe Acrobat or another form editor). You send the template and an object of values, and get back the filled PDF.
Don't know what fields your template has? Call the API WITHOUT the data object and it returns the list of available fields (their name and type) instead of filling anything — so you can discover them before automating. This also costs 1 credit, same as filling.
All you need
- Your API key. Create it in your dashboard with "+ Create key". It's shown only once, so copy and save it.
- In your automation platform, an "HTTP Request" step (n8n, Make, Zapier, Pipedream… all have one).
- Your PDF template with form fields.
Step 1: discover your template's fields
In n8n's HTTP Request node:
- Method:
POST - URL:
https://api.cofferdock.com/pdf-fill-form - Send Headers: on → add two:
x-api-key= your key, andContent-Type=application/pdf - Send Body: on → choose the binary file option (in n8n: "n8n Binary File", with your template's binary property, usually
data)
The response carries the list of fields with their name and type, e.g.: { "fields": [{ "name": "customer_name", "type": "text" }, { "name": "agree", "type": "checkbox" }] }. Use those exact names in step 2.
Step 2: fill the template
Switch the body to JSON (to send the template and the data together):
- Send Body: JSON →
{ "file": "<your template in base64>", "data": { "customer_name": "Jane Doe", "agree": true } } - Send Headers:
x-api-key= your key,Content-Type=application/json - Under Options → Response → Response Format: choose File (the response is already the filled PDF)
Convert your template to base64 with a Code node using {{'{{'}}$binary.data.toString('base64'){{'}}'}}, or with the Move Binary Data node.
If a field name doesn't exist in the template (say, a typo), that call does NOT fail: it fills the fields it recognizes and warns about the rest in the X-Warnings header (or in warnings if you ask for output=json).
Options (in the JSON)
| Option | Default | What it does |
|---|---|---|
data | — | Object with { "field_name": "value" }. Omit it and the API responds with the field list instead of filling. |
flatten | false | true "freezes" the PDF: values can no longer be edited in a PDF reader. |
API overview
- Endpoint:
POST https://api.cofferdock.com/pdf-fill-form - Auth: header
x-api-key: YOUR_KEY. - Input: the template goes as raw
application/pdf(withdataas URL-encoded JSON in a Query param) or as JSON with{ file, data, flatten, inspect }. - Mode: no
data(orinspect=true) → inspect, returnsfields. Withdata(even{}) → fill. - Fill output: binary PDF by default; with
output=jsonit returns{ pdf, warnings, meta }in base64. - Unknown fields: don't block the call, they go into
warnings(or theX-Warningsheader in binary mode, with the warning count). - Limits: template up to 20 MB (50 MB on Business/Scale) in
application/pdfmode, or ~4 MB real in JSON with base64. 30 requests/min per IP. 1 call = 1 credit (inspect or fill, equally).
Supported field types
| Type | Expected value in data |
|---|---|
text | Any text. |
checkbox | true/false. |
radio / dropdown / list | One of the values in options (visible in inspect mode). |
button / signature | Can't be filled via API; if present in data, they go to warnings. |
Examples
curl (inspect fields):
curl -X POST "https://api.cofferdock.com/pdf-fill-form" \
-H "x-api-key: YOUR_KEY" \
-H "Content-Type: application/pdf" \
--data-binary @template.pdf
JavaScript (Node 18+, fill):
const fs = require('fs');
const r = await fetch('https://api.cofferdock.com/pdf-fill-form', {
method: 'POST',
headers: { 'x-api-key': 'YOUR_KEY', 'Content-Type': 'application/json' },
body: JSON.stringify({
file: fs.readFileSync('template.pdf').toString('base64'),
data: { customer_name: 'Jane Doe', agree: true },
}),
});
fs.writeFileSync('filled.pdf', Buffer.from(await r.arrayBuffer()));
Python (fill and flatten):
import requests, base64
r = requests.post(
'https://api.cofferdock.com/pdf-fill-form',
headers={'x-api-key': 'YOUR_KEY', 'Content-Type': 'application/json'},
json={
'file': base64.b64encode(open('template.pdf', 'rb').read()).decode(),
'data': {'customer_name': 'Jane Doe', 'agree': True},
'flatten': True,
},
)
open('filled.pdf', 'wb').write(r.content)
Inspect mode response
{ "success": true, "mode": "inspect",
"fields": [
{ "name": "customer_name", "type": "text", "value": "" },
{ "name": "agree", "type": "checkbox", "value": false },
{ "name": "country", "type": "dropdown", "options": ["ES","US","MX"], "value": null }
],
"meta": { "total_fields": 3, "used": 12, "remaining": 488 } }
Fill response (with output=json)
{ "success": true, "mode": "fill", "pdf": "JVBERi0xLjQ…", "mime_type": "application/pdf",
"warnings": ["Unknown field: \"customr_name\""],
"meta": { "fields_filled": 2, "flattened": false, "used": 13, "remaining": 487 } }
What you get back
Inspect mode: a JSON with the field list. Fill mode: the filled PDF itself (or in base64 with output=json).