Skip to content

Batches and background jobs

Large documents and batches run as background jobs. You get 202 and a job id at once, then poll the job or wait for a webhook.

Background jobs

POST /v1/invoices/validate, /parse and /convert run as a job when you set async=true (query or JSON field), and always when the document is larger than 2 MB. The answer is 202:

{ "id": "…", "object": "job", "type": "validate", "status": "queued", "createdAt": "…", "statusUrl": "/v1/jobs/…" }

The job runs with the same options as the call (store, target, allowDataLoss) and is billed like it.

Batches

POST /v1/batches validates up to 50 documents in one job. It needs the Growth plan (otherwise 402 plan_required) and a key with the validate scope.

curl -X POST https://einvoiceengine.com/v1/batches \
  -H "Authorization: Bearer $EINV_KEY" -H "Content-Type: application/json" \
  -H "Idempotency-Key: batch-2026-11-22-1" \
  -d '{ "operation": "validate", "documents": [
        { "document": "<Invoice …>", "filename": "RE-1001.xml" },
        { "document": "JVBERi0xLjc…", "encoding": "base64", "filename": "RE-1002.pdf" } ] }'
Field Meaning
operation validate (the only operation)
documents 1–50 items
documents[].document XML text, or base64
documents[].encoding utf8 or base64; when omitted, text that starts with < is read as XML, anything else as base64
documents[].filename optional, up to 200 characters; returned with the item's result

The whole JSON body has the same size limit as a single request (10 MB of document data plus base64 overhead). The answer is 202 with type: "batch" and items (the number of documents).

Each document counts as one validation: it is billed when the official validator ran, like POST /v1/invoices/validate. If the monthly quota runs out during a batch, the job fails with quota_exceeded; the documents checked before that stay counted.

Job status

GET /v1/jobs/{id} works with any key of the organization.

{ "id": "…", "object": "job", "type": "batch", "status": "succeeded", "attempts": 1,
  "result": { "items": [ { "index": 0, "filename": "RE-1001.xml", "id": "…", "invoiceId": "…", "status": "invalid",
                           "summary": { "errors": 2, "warnings": 0, "infos": 1 }, "findings": [ … ] } ],
              "summary": { "total": 2, "valid": 1, "invalid": 1 } },
  "error": null, "createdAt": "…", "finishedAt": "…" }
  • status is queued, running, succeeded or failed.
  • For a single document, result is the same body the synchronous call returns.
  • For a batch, a document that could not be checked has status: "error" and error: { code, message }; the other documents are not affected.
  • For a failed job, result is { error: { code, message, details } } and error is the code.
  • Add ?lang=de (or Accept-Language) for explanations in another language; see validation.

Webhooks

Subscribe an endpoint to job.succeeded, job.failed and batch.completed. The payload has the job id, statusUrl and the result's status and counts, never document content. Fetch the findings with GET /v1/jobs/{id}.

Retries and dead letters

  • A job that fails with a server error (5xx) is retried automatically, up to 3 attempts in all, after 10 and 20 seconds.
  • Any other error fails the job at once.
  • A failed job is a dead letter: its encrypted input is kept for 7 days, then deleted. The input of a successful job is deleted when it finishes.
  • GET /v1/failures (scope invoices:read) lists jobs and webhook deliveries that failed in the last 30 days. For jobs, retryableUntil says until when a retry is possible.
  • POST /v1/jobs/{id}/retry (scope keys:write) runs a failed job again within those 7 days. Afterwards, or for a job that did not fail, it returns 409 not_retryable. Documents checked again are billed again.

Failed routed documents work the same way with POST /v1/routed/{id}/retry.