Skip to content

DSN API: resend without a second check

A network drops, a timeout expires, and your software no longer knows whether the file arrived. The Idempotency-Key header settles this: send the same request again with the same key, and the API neither recomputes nor counts it.

Every processing call carries an Idempotency-Key header: an opaque value of 1 to 128 characters (ASCII letters, digits, hyphen and underscore), unique to that submission. A UUID works. This key has nothing to do with your API key.

  • Situation, with the same key
    First submission
    Response
    200, or 202 for a deferred response.
    What you do
    On a 200, store the document: the API keeps no copy. On a 202, read the report at the address given.
  • Situation, with the same key
    The same request, already complete
    Response
    204, with no document, calculation or counting.
    What you do
    Reuse the first response you stored. Lost it? Send again with a new key: the document is recomputed, at no extra charge.
  • Situation, with the same key
    The same request, still running
    Response
    409, code deja_en_cours.
    What you do
    Wait, then try again.
  • Situation, with the same key
    Different content
    Response
    409, code idempotence_conflit.
    What you do
    Generate a new key: this is a different submission.

Good habits

  • Generate the key once per submission, before the first attempt, and keep it until the submission has succeeded.
  • Reuse it for every retry of the same submission. A new key on each attempt would make idempotency useless.
  • Store the first response as soon as you receive it. The 204 confirms the work is done; it does not return the document.
  • In a batch, each file carries its own key.

The limits of the receipt

The idempotency receipt lasts 900 seconds at most. It applies to the same workspace and the same mode, test or production, even with another API key. After that, or exceptionally earlier (for example during a service update), the same request is treated as a new submission. Counting does not suffer: billing retains the maximum number of declared individuals per establishment and per declared month, and rechecking the same DSN does not raise that maximum.

DSNLint Connect generates this key for you. The --idempotence option sets the submission’s UUID when you want to replay it yourself: --idempotence format=UUID for the simple check, --idempotence UUID for the other functions and for uploading a batch file, always a version 4 UUID. Connect never retries a submission on its own.

See what the API guarantees

DSN API keys: test, production, revocation
Previous section
Webhooks: the end-of-batch notice
Next section