Idempotency
Network failures happen after the server has already accepted a request. Without protection, a retry uploads the document again, creates a second job and bills twice. Send an Idempotency-Key header and Deskew will replay the original response instead.
curl https://api.deskew.dev/v1/extract \ -H "Authorization: Bearer $DESKEW_API_KEY" \ -H "Idempotency-Key: 7c9e6679-7425-40de-944b-e07fc1f90ae7" \ -F "file=@invoice.pdf" \ -F "output=json"How it works
Section titled “How it works”- On the first request with a given key, Deskew stores the status code and body of its response (
200with the result, or202with the job) together with a hash of the request. - A repeat request with the same key within 24 hours returns that stored response unchanged, with the header
Idempotent-Replayed: true. No new job is created and nothing is billed. - After 24 hours the key is forgotten and the request is processed as new.
The request hash covers the file bytes and every extraction option (output, tables, quality, schema, …). pdf_password is excluded from the hash, so a retry that corrects a password is still the same request.
Mismatches
Section titled “Mismatches”Reusing a key with a different file or different options is an error:
{ "error": { "type": "invalid_request_error", "code": "idempotency_conflict", "message": "Idempotency-Key was already used with a different request.", "doc_url": "https://docs.deskew.dev/errors#idempotency_conflict" }}It is returned with status 409. Generate a new key for a genuinely new request.
Choosing keys
Section titled “Choosing keys”- Use a UUID v4 or another random value with at least 128 bits of entropy.
- Generate the key before the first attempt and reuse it on every retry of that attempt.
- Keys are scoped to the project, so two projects can use the same value without colliding.
- Only
POST /v1/extractsupports idempotency keys.GETrequests are naturally safe to retry;DELETE /v1/jobs/:idis a no-op once the job is no longer running.
Replays and async jobs
Section titled “Replays and async jobs”If the original response was a 202, the replay is the same 202 with the same job id, even if the job has since completed. Follow it with GET /v1/jobs/:id as usual.