n8n
Run your first invoice in n8n.
Use the published Temlavo template to extract and review invoices from your existing workflow, or connect an invoice source to run it standalone. Connect your API key, pass one invoice, and route the structured result by status. The template handles create, direct upload, confirmation, and bounded polling.
On this page
Connect the n8n template
Published in n8n's template library as Extract and review invoice data with Temlavo in a sub-workflow. Import and save it in your n8n instance. Follow the steps below to call it from a parent workflow, or use the same credential setup with the standalone input instructions.
- Connect your Temlavo API key. Start a trial, then create a key in API keys. In n8n, create an HTTP Header Auth credential with name
Authorizationand valueBearer YOUR_API_KEY, using the full key. Select it on Create Document, Confirm Upload, and Get Document. Leave the signed upload request unauthenticated. - Enable upload recovery. In Create Document, keep the existing headers and add
Temlavo-Upload-Recoverywith valueconfirm-existing. This lets a retry confirm a file that already uploaded. Add it only to Create Document; keep the signed upload request unchanged. - Publish your configured workflow in your n8n instance. In workflow settings, allow only the intended callers, then select Publish. Production parent workflows use this published version. This publishes your configured copy inside your instance.
- Call it from your workflow. Add Execute Sub-workflow, select the saved template, choose Run once with all items, and enable Wait for Sub-Workflow Completion. Keep the template's trigger on Accept all data.
- Pass one saved invoice. Send one item with the file in
binary.invoiceand thetemlavo_submissionfields below. Save the original file, metadata, options, and submission tokens before calling; reuse them for retries. For batches, use Loop Over Items with batch size 1. - Route the result. Branch on
completed,needs_review, orfailed. Handletemlavo.n8n-safe-stop.v1recovery responses separately, and configure On Error → Continue (using error output) on the call node for input or runtime errors.
The template is free; processing uses your Temlavo account's available usage, and n8n hosting costs are separate. Gmail, Drive, webhooks, and other invoice sources stay in your parent workflow. Restrict which workflows can call it in n8n's workflow settings: calls use your Temlavo account and allowance.
Prepare one invoice
Supply one PDF, JPEG, or PNG up to 20 MiB as binary.invoice, plus this JSON. Use the actual filename and MIME type. Replace both placeholder tokens with your own saved opaque values, such as UUIDs, before the first run.
{
"temlavo_submission": {
"idempotency_key": "YOUR_SAVED_SUBMISSION_TOKEN",
"input_ref": "YOUR_SAVED_RETRY_RECORD_TOKEN",
"filename": "invoice.pdf",
"content_type": "application/pdf",
"line_items": "advisory"
}
}Save the identity before the first request. Both tokens must contain 1–128 letters, digits, underscores, or hyphens. Keep the original file, filename, MIME type, options, and tokens together in your private retry storage. Reuse that exact input on a retry; choose new tokens for a new logical invoice. Do not generate a new key on every execution or use invoice numbers, filenames, or email addresses as tokens.
Download a synthetic invoice PDF if you need test input. Use synthetic-itemized.pdf as its filename and application/pdf as its MIME type. Processing it uses your account's processed-page allowance. A live result may differ from the authored example.
Run standalone in your imported copy
Add an invoice source to the same template when you want to run it without a parent workflow. The published template expects incoming data, so clicking Execute Workflow before adding a source will not supply an invoice. Configure the API credential as described above.
- Connect a manual input chain. In your imported copy, disconnect Receive invoice from caller from Validate invoice input. Add Manual Trigger, then your file-source node, then Edit Fields (Set), and connect that to Validate invoice input. Keep its name and all remaining processing nodes and connections unchanged.
- Load the invoice as a file. For the synthetic PDF, use an HTTP Request node: method GET, authentication None, and URL
https://temlavo.com/examples/itemized-v1/invoice.pdf. Under Response, set Response Format to File and Put Output in Field toinvoice. Never attach your Temlavo API key to this download. - Add the saved submission. In Edit Fields, choose JSON Output and add the submission JSON above, with your saved tokens and the file's actual metadata. Enable Include Binary Data so
binary.invoicereaches Validate invoice input. For the sample, use filenamesynthetic-itemized.pdf. Check the node output contains exactly one item with both the file andtemlavo_submissionbefore continuing. - Run and inspect. Execute from Manual Trigger and inspect Return to caller for the final result or recovery response. That node still produces the output item when running standalone. Input or n8n runtime errors fail the execution; inspect and resolve them before retrying the same saved submission.
To use your own source, replace the sample download with a file-reading, Drive, or other source node that supplies binary.invoice and the saved submission. Preserve the actual binary object, not just a binary-storage ID. For automatic runs, use the appropriate source trigger in place of Manual Trigger.
These are input-setup instructions for your imported copy. The published template stays unchanged. Its sub-workflow path has recorded connected verification; this standalone input recipe has not had a separate live n8n verification.
Branch on the extracted result
completed means no declared blocking issue was found. Continue through your own business policy. needs_review retains useful data and actionable checks for unresolved required fields, policy-blocking conflicts or arithmetic failures, or duplicate risk. failed has no usable result; route its stable error code.
The published sub-workflow returns the full API document under document; read accounting values under document.data, including when running standalone. Currency may be inferred by AI from invoice context without customer setup. Within those accounting values, line_items_status reports the AI assessment of complete, partial, or unavailable item extraction. A completed result or arithmetic pass does not independently verify factual correctness or authorize payment.
When the workflow stops for help
Common-path automation handles normal replay and ambiguous upload recovery. Billing recovery, expired capabilities, an authoritative instruction to begin a new logical submission, exhausted retry, or a malformed response ends with a non-secret temlavo.n8n-safe-stop.v1 object for a human or caller to decide. The workflow never rotates keys or creates replacement documents automatically in those states.
Retryable responses use Retry-After when it is a non-negative integer. The verified workflow otherwise uses a bounded five-second fallback: at most three create/confirmation attempts and twenty polls. Retry the published template with your saved submission tokens and original input. The idempotency record lasts seven days; after expiry, an intentional new logical submission and duplicate consequences are a human decision.
Configure document policy
For your own invoices, include this policy in the adapted create body before its request and idempotency key are fixed:
{
"policy": { "required_fields": [], "line_items": "required", "checks": { "duplicate_detection": true } }
}Adapted n8n create requests use the same snake_case policy object as raw HTTP. See all review policy settings for defaults, acceptance behavior and limits.
The official template does not provide first-class controls for every policy member. Validate invoice input accepts a saved line_items mode, sends an empty required_fields list and leaves duplicate detection at the server default. To add required fields or disable duplicate detection, adapt the saved submission and create_body.policy together. Snapshot and reuse the chosen policy with the original bytes and key on every retry.
Changes to the normalized policy conflict under the same live key; equivalent defaults and reordered required fields do not. See idempotency guidance. Route on authenticated status and retain the full document, including warnings, on every result branch.