Node.js

Use Create a Fillable PDF from Node.js.

Official npm package coming soon. Until it's published, call the REST API directly — it's just a couple of lines with the built-in fetch (Node 18+). Everything below works today.

Convert a PDF

import { readFileSync } from "node:fs";

const form = new FormData();
form.append(
  "file",
  new Blob([readFileSync("applicant.pdf")], { type: "application/pdf" }),
  "applicant.pdf",
);
form.append("detect", "fields");

const res = await fetch("https://api.createafillablepdf.com/v1/convert", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.CAFP_KEY}` },
  body: form,
});

if (!res.ok) {
  const { error } = await res.json();
  throw new Error(`${error.type}: ${error.message}`);
}

const result = await res.json();
console.log(result.fields, result.document_url);

Fill a converted document

const res = await fetch("https://api.createafillablepdf.com/v1/fill", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.CAFP_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    conversion_id: "c_123",
    values: { applicant_legal_name: "Dana Okonkwo", is_us_citizen: true },
  }),
});
const filledPdf = Buffer.from(await res.arrayBuffer()); // the filled PDF bytes

When the official package ships, this becomes import FillablePDF from "createafillablepdf" with client.convert(...) and client.fill(...). The REST calls above will keep working either way.