Skip to main content

Idempotency

PDFCanon supports idempotency keys to allow safe retries of normalization requests without risk of double-processing.

How it works

Pass an Idempotency-Key header with any POST /api/normalize request. If a request with the same key has already been processed, PDFCanon returns the original response rather than re-processing the document.

curl -X POST https://api.pdfcanon.com/api/normalize \
-H "X-Api-Key: pdfn_your_api_key_here" \
-H "Idempotency-Key: order-12345-normalize-v1" \
-H "Content-Type: application/pdf" \
--data-binary @invoice.pdf \
-o normalized-invoice.pdf

Key requirements

  • Keys must be unique per request
  • Keys are scoped to your API key (two different API keys can use the same idempotency key value)
  • Keys are valid for 24 hours after first use
  • Maximum key length is 255 characters

Use a value that is naturally unique to the logical operation, such as a database record ID plus a version suffix:

{entity_type}-{entity_id}-{operation}-{version}

Example: submission-order-9918-normalize-v2

Behaviour on collision

ScenarioResponse
Same key, same body, first requestProcess normally, return result
Same key, same body, subsequent requestReturn cached result (HTTP 200)
Same key, different bodyHTTP 409 — idempotency key conflict
Expired key (>24h), same keyTreat as a new request

Next steps