See llms.txt for all machine-readable content.

Back to Templates

Extract and validate invoice data from PDFs with DeepSeek and webhooks

Quick Overview

This workflow receives invoice PDFs via a secured webhook, extracts the PDF text, uses an OpenAI-compatible chat completion API (DeepSeek by default) to return invoice fields as JSON, validates the extracted values, and responds with a single JSON result indicating whether the invoice is valid or needs review.

How it works

  1. Receives a PDF upload via a POST webhook protected by header authentication.
  2. Checks the uploaded file type and immediately flags non-PDF uploads as needs_review with a reason.
  3. Extracts the PDF text layer and flags scanned or image-only PDFs (no usable text) as needs_review.
  4. Sends the cleaned invoice text to an OpenAI-compatible /chat/completions endpoint (DeepSeek by default) to extract invoice fields as a single JSON object.
  5. Normalizes dates and numbers, validates required fields, totals and line-item math, allowed currencies, and basic date plausibility.
  6. Responds to the webhook with one JSON row containing status (valid or needs_review), issues, and the extracted invoice fields.

Setup

  1. Create and select a Header Auth credential for the webhook (for example, header name X-Api-Key) and configure the source system to send that header when calling the webhook URL.
  2. Create and select an HTTP Header Auth credential for the LLM request (header Authorization: Bearer <API_KEY>) for your OpenAI-compatible provider (DeepSeek by default).
  3. Review and update the values in the Settings step, including allowed_currencies, date_order, llm_base_url, llm_model, and llm_extra_body (set llm_extra_body to {} for providers that don’t support the default DeepSeek-specific fields).
  4. Activate the workflow and test by POSTing a multipart form upload with the PDF in the file field to the production webhook URL.