Use idempotency keys in a PDF processing API

3 November 2026

Hands work at a laptop on a wooden table, with a phone nearby.
Illustrative photograph: laptop work with a phone close by. Cropped and resized. Photo: “Mobile developer at work (Unsplash).jpg” — Parker Byrd parkerabyrd / Wikimedia Commons. · CC0 1.0

Use the same idempotency key when retrying the same authorised PDF batch. Before treating a request as a replay, compare the operation, tenant and payload to the original. If the key now names different work, hold or reject the conflict and preserve the original record. The local exercise demonstrated reuse of successful item results; a real API’s handling of a changed payload still needs a separate test. Batch contract · Batch results

Distinguishing request replay from idempotency key conflict

Idempotency keys protect PDF processing workflows against network dropouts, client retries, and duplicate processing requests. For an API acceptance exercise, distinguish two distinct scenarios when an idempotency key is reused: exact request replay and key conflict.

When a client submits a batch request using an idempotency key—such as SYN-B01-v1 defined in the proposed internal batch contract template batch-contract.json—the proposed API should check whether that key has already been assigned to an identical payload. If the payload hash, item list, and operation match the recorded contract, ask the service to return the original batch identity and the recorded state of each item. Whether this is a cached result, an in-progress status or a completed output depends on the contract and state. Batch contract

A key conflict occurs when a client reuses an active idempotency key with a modified payload. For example, if a retry attempts to alter item instructions, swap input files, or change batch atomicity while retaining SYN-B01-v1, the processing engine cannot reuse stored outputs. Because idempotency keys bind a specific key to a specific, immutable payload contract, an altered payload must be rejected as an idempotency conflict. To process modified items, the client must generate a new unique idempotency key.

Reconciling idempotency behaviour in local synthetic execution

Evaluating idempotency logic requires grounding operational claims within verified environment limits. The first-party execution log batch-results.json records a local synthetic batch run using Python 3.12.14 and pypdf 6.10.0. The execution model records zero network calls, with http_api recorded as NOT_IMPLEMENTED, and authentication and restart durability recorded as NOT_TESTED. Batch contract · Batch results

In the local page-count run, an eight-item batch request (items SYN-I01 through SYN-I08) processes under operation page-count-v1. Initial processing yields 4 succeeded items, 1 retryable failure (SYN-I03), 1 permanent failure (SYN-I04), 1 cancelled item (SYN-I05), and 1 queued item (SYN-I06). Following a second attempt on transient failure SYN-I03, final counts reach 5 succeeded items, 1 permanent failure, 1 cancelled item, and 1 queued item. All 5 successful items (SYN-I01, SYN-I02, SYN-I03, SYN-I07, SYN-I08) produce a verified page count of 3 and matching source SHA-256 hash beee40fa0bfd1f3c5819f6fb919a0c3791100856cc1626d3db0f510d60f58905. Batch contract · Batch results

During the local replay pass, the log records REUSED_SUCCESS for items SYN-I01, SYN-I02, SYN-I03, SYN-I07, and SYN-I08. This demonstrates item-level reuse in the model. It does not show a full HTTP request being replayed or an entire cached response being returned. However, because the test scope is restricted to page-count extraction without HTTP transport or persistent storage tests, durability across system restarts remains an open requirement for future integration testing. Batch results · Batch contract

Worked idempotency decision record and ledger

The decision ledger below outlines the evaluation criteria for batch requests reusing key SYN-B01-v1, citing the proposed contract template and execution records. Batch contract · Batch results

Batch IDIdempotency KeyPayload StateExecution AttemptObserved Outcome / EventDecision StatusNext Required Action
SYN-B01SYN-B01-v1UnmodifiedAttempt 14 Succeeded, 1 Retryable (SYN-I03), 1 Permanent (SYN-I04)Initial ProcessingExecute retry on item SYN-I03
SYN-B01SYN-B01-v1UnmodifiedAttempt 2Final: 5 Succeeded, 1 Permanent (SYN-I04)Partial CompletionReconcile unparseable item SYN-I04
SYN-B01SYN-B01-v1Identical ReplayReplay RequestLogged REUSED_SUCCESS for 5 valid itemsReplay VerifiedReturn recorded outputs to client
SYN-B01SYN-B01-v1Modified PayloadRetry RequestExpected: refuse the same key for changed workProposed test, not executedVerify the original job and outputs were untouched before commissioning a separate operation

Batch results

For the proposed conflict test, change one input under the same key and keep the original reference. Record what the server returns, whether any new processing started, and whether the first batch can still be retrieved. The observations provide no changed-payload request, HTTP status, restart result or evidence of durable key storage. If the changed request is intentional, authorise it as new work, use its own key and preserve the relationship to the first batch. A permanent parse failure on the original is a separate item-level exception. Batch contract · Batch results

Next step for API integration

Audit your client application's retry architecture to ensure that network retry mechanisms resend exact batch payloads with their original idempotency keys, while any payload modification generates a new unique key prior to dispatch.

Part of the Reconcile partial failures in a batch PDF job guide.

Published by Arke Technologies (Pty) Ltd, Johannesburg. Drafted with NotebookLM. Source checks and editing by Kairos (Codex).