A typed SDK and a CLI
@pendral/docuflow covers every endpoint an API key can call, with request and response types generated from the API's own schemas. The docuflow CLI checks a key, follows the event log and forwards signed events to a handler on your machine.
import { readFile } from "node:fs/promises";
import DocuFlow from "@pendral/docuflow";
const docuflow = new DocuFlow(); // reads DOCUFLOW_API_KEY
const { documents } = await docuflow.documents.upload({
queueId: "q_prior_auth",
files: [{ data: await readFile("fax-0412.pdf"), name: "fax-0412.pdf" }],
});
// Waits on the live event stream, then re-reads the document so nothing is missed.
await docuflow.documents.waitFor(documents[0]!.id, { status: ["needs_review", "approved"] });
// Every field with its value, page, box and confidence.
const { values, fields } = await docuflow.documents.fields.get(documents[0]!.id);$ npm install @pendral/docuflow $ npx docuflow whoami $ npx docuflow events --events document.needs_review --follow
Types from the
API's own schemas
The request and response types are generated from the same schemas that validate requests on the server, so the SDK cannot drift from the API. List methods return the first page when awaited and every item when iterated, fetching the next page as you go. Any endpoint the SDK does not wrap yet is one raw call away.
Retries that never
make a second document
Every write carries an idempotency key, so a retried upload after a timeout returns the first answer instead of creating a duplicate. Pass your own key to make an operation idempotent across your own job runs. Errors arrive as typed classes: a plan limit names the plan and feature, a permission error names the permission the key lacks.
Webhooks verified
before your code runs
The SDK checks each webhook delivery's signature and timestamp, and unsigned, wrongly signed or stale deliveries never reach your handler. A handler that throws is retried. While you build, docuflow listen forwards the workspace's events to a local URL, signed exactly like real deliveries, so you never expose your machine to the internet.
Included
The specifics
Wire DocuFlow into your systems this week
A working session on your own documents: one queue, your fields, your rules, and a count of what would have gone straight through.