Quick overview
This sub-workflow receives a single invoice file from another n8n workflow, uploads it to Temlavo for extraction, then polls Temlavo until the document reaches a terminal state and returns a structured result (completed, needs_review, failed) or a recovery safe-stop.
How it works
- Receives one invoice item from a calling workflow, including the binary.invoice file and a temlavo_submission payload with saved idempotency tokens and file metadata.
- Validates the input (file type, size, and required Temlavo submission fields) and prepares a fixed Temlavo API request context.
- Creates a Temlavo document via the Temlavo REST API using an Idempotency-Key header and decides whether to upload, poll, retry after backoff, or stop with a structured recovery response.
- Uploads the invoice bytes to Temlavo using the signed URL and headers provided by the API, then confirms upload completion with Temlavo.
- Polls the Temlavo document status until it becomes completed, needs_review, or failed, applying bounded waits and retry logic for transient API errors.
- Returns a single JSON item to the caller containing the final document payload (and review reasons when applicable) or a temlavo.n8n-safe-stop.v1 object describing how to recover.
Setup
- Register at Temlavo, then open API keys and create a key. Copy the full key shown once; the shortened key hint will not work. In n8n, create an HTTP Header Auth credential: Name
Authorization; Value Bearer followed by your full key, with one space and no quotes.
- Select that credential on the Temlavo API calls (Create Document, Confirm Upload, and Get Document) and leave the signed upload request unauthenticated.
- Import and save this workflow. In the parent, use Execute Sub-workflow with Run once with all items and Wait for Sub-Workflow Completion enabled. Keep this workflow’s trigger on Accept all data. Pass exactly one item containing binary.invoice and the temlavo_submission fields documented in the input sticky note. Save the submission tokens and original file before calling; reuse the same values for retries.
Requirements
- A Temlavo account with an active API key and available usage, an n8n instance, and one PDF, JPEG, or PNG invoice up to 20 MiB per call. The template is free; Temlavo API usage and n8n hosting costs are separate.
Customization
- Use Gmail, Drive, a webhook, or another source in your parent workflow. Map each attachment to binary.invoice. For batches, use Loop Over Items with batch size 1. Route completed results to your next step, needs_review results to human review, and handle failed or recovery-stop outcomes separately.
Additional info
A completed result means no blocking declared check; it does not independently verify accounting correctness. The workflow’s canvas notes explain input fields, retries, timeouts, credential setup, and data retention.