Use idempotency keys for API uploads
Protect one-shot uploads with a UUID-v4 idempotency key, distinguish replay from in-flight work, and reject accidental reuse for different bytes.
Last reviewed
Dosya idempotency applies to the one-shot PUT /api/upload/file route. Send a UUID-v4 value in X-Dosya-Idempotency-Key; multipart session routes have their own part-number resume contract.

Before you start
- Generate one fresh UUID v4 for one logical upload and persist it with that job until the result is verified.
- Keep workspace, folder, raw filename, and
Content-Lengthunchanged across retries; these values form the request fingerprint. - The request body must be replayable before automatic retry is enabled.
Steps
- Create a UUID v4 such as
3fa85f64-5717-4562-b3fc-2c963f66afa6and associate it with the local source path and intended destination. - Send
PUT /api/upload/file?file_name=report.pdf&folder_id=folder_idwith the exactContent-Length, bearer key, body, andX-Dosya-Idempotency-Key. - On HTTP 201, store the returned file receipt. The server retains a completed idempotency record for 86,400 seconds, so a matching retry can recover the response.
- After an ambiguous transport failure, repeat the identical request with the identical key. HTTP 200 plus
X-Dosya-Idempotent-Replay: truemeans Dosya returned the earlier result without a second file. - For HTTP 409 with
Retry-After: 5, another matching request is still in progress. Wait and retry; abandoned in-progress ownership can be taken over after 600 seconds. - For 409 with code
idempotency_key_reused, stop. The key was paired with a different workspace, folder, raw filename, or declared length; generate a new key only for a genuinely new upload.

Expected result
The first accepted upload returns 201. An identical replay returns the same logical result with status 200 and the replay header, while a mismatched fingerprint is refused rather than creating uncertain data.
Troubleshooting
The body cannot be replayed. Spool it to a temporary file before the first request or disable automatic retries.
The response is 409 without the reuse code. Honor Retry-After: 5; do not create a new key while the original operation may still finish.
The file bytes changed but length did not. Use X-Dosya-Sha256 as an integrity check and a new idempotency key for the new logical upload.
Related guides
Was this helpful?
Loading helpfulness results…
Voting saves a necessary ballot cookie for up to 180 days so you can change your answer.
Questions and replies
Ask about the steps in this guide. Questions are reviewed before publication.
Keep account details, credentials and private files out of public questions. Use private support for those.
Loading questions…
Sign in to your Dosya account to ask a question.