DocPeeldocs

Processing Invoices

This guide walks through a production invoice ingestion pipeline: upload the PDF, extract the structured fields, validate them against your business rules, and push the results into your accounting system.

1. Choose a template

DocPeel ships with the built-in tpl_invoice template that captures common fields: Invoice Number, Vendor, Total, Due Date, Line Items, Tax, etc.

Need custom fields (PO number, GL code, project code)? Create a custom template in the dashboard and pass template_id in the API call.

2. Send the file

import fs from 'fs';

const fileB64 = fs.readFileSync('./invoice.pdf').toString('base64');

const result = await client.extractions.create({
  file:       fileB64,
  fileName:   'invoice.pdf',
  templateId: 'tpl_invoice',
});

3. Validate confidence

Each field has a confidence score (0 – 100). For high-stakes fields like Total or Due Date, treat anything below 90 as needing human review.

const total = result.fields.find(f => f.field === 'Total');
if (!total || total.confidence < 90) {
  await queueForHumanReview(result.id);
} else {
  await postToErp({ amount: parseAmount(total.value), invoiceId: result.id });
}

4. Handle corrections

When a teammate edits a value in the dashboard, DocPeel emits an extraction.corrected webhook so you can sync the corrected version back into your ERP. Always treat the corrected payload as the source of truth.

5. Production checklist

  • Use a separate API key per environment.
  • Store the original file URL and the extraction ID in your database — never just the parsed values.
  • Subscribe to extraction.corrected and re-sync on every event.
  • Set up a low-credits alert in the dashboard.
  • Log request_id from every response for support tickets.