Skip to content

Webhooks: the end-of-batch notice

A webhook saves you from polling the API. When a batch is closed and all its operations have finished, DSNLint calls the address you registered. The call is signed and contains no payroll data: you then read the results from the API, with your key.

Register and designate a destination

A destination is registered once, in Developers › Webhooks, by the owner, an administrator or a developer of the workspace; all members see the list. The address uses HTTPS on a public domain: an IP address, a local domain or a domain that points to a private address is refused. A workspace has at most 20 webhooks, suspended ones included.

The webhook secret is created by DSNLint and shown only once, when it is created or renewed. You then never give an address to the API, only the webhook identifier: 1 to 128 characters, letters, digits, hyphen and underscore.

  • Submission
    Batch of checks, /v1/lots
    How to designate the destination
    The webhook field, at creation.
    Required
    Yes.
  • Submission
    Batch of functions, /v1/lots-fonctions
    How to designate the destination
    The webhook field, at creation.
    Required
    No.
  • Submission
    Deferred response
    How to designate the destination
    Prefer: respond-async; webhook=destination_1
    Required
    No.

The call you receive

A POST request over HTTPS to the registered address, with a JSON body. Redirects are not followed.

  • Header
    X-DSNLint-Signature
    Content
    t=SECONDS,v1=SIGNATURE: the time of sending, in UNIX seconds, and the HMAC-SHA256 signature in hexadecimal.
  • Header
    X-DSNLint-Evenement
    Content
    The event identifier, the same as the id field of the body.

The body is the lot.termine event: id (the event), kind (lot.termine), organisation, key_id (the identifier of the key that created the batch), billing_month (the month of receipt, YYYYMM, not the declared month), individus (always 0), object_id (the batch), completed and failed (operations finished and in technical error, without saying how many DSN files are compliant), and destination (the webhook). It contains no file, no report and no data about an individual.

Verify the signature

  1. Keep the raw body — Read the bytes received before any JSON decoding: re-encoded JSON may differ from the signed body.
  2. Recompute the signature — Compute the HMAC-SHA256 of the t value, a dot and the raw body, keyed with the 32 bytes of the secret, written as 64 hexadecimal characters. Compare the result with v1, in constant time.
  3. Refuse a call that is too old — Refuse the call if t differs from your clock by more than 300 seconds.
  4. Ignore a duplicate — Keep the identifiers of events already processed: the same event can come back. Still answer it with a success, to stop further attempts.

The Developers › Webhooks screen gives a verification example in Node.js.

Answering, and what happens on failure

  • Answer quickly with a 2xx status, preferably 204; the body of your answer is not read. Do any long processing after answering.
  • A redirect, a 4xx or 5xx status, or an answer that is too slow is a failure. DSNLint then tries again up to five times, after waits of at least 1 minute, 5 minutes, 30 minutes, 2 hours and 12 hours, with no guaranteed time, then gives up this notice if the failure persists; the webhook stays active.
  • A new attempt carries the same identifier and the same body, with a new time and a new signature.
  • The screen shows whether each webhook is active or suspended, but not the history of its calls.
The notice does not extend how long results are kept: they can be read during the batch period, at most 300 seconds. After a late new attempt, they may have expired: send the file again with a new idempotency key. It is not billed twice.

Renew the secret

Renewing replaces the old secret at once: the two are never valid at the same time. Install the new secret on your side right after renewing it; a call already prepared may still carry the old signature.

Without a notice: read the batch status

Without a destination, poll the address of the result, or read the technical counters of the batch. With DSNLint Connect: lot etat and lots-fonctions etat. Send back on every read the cookies received with the submission: without them, a read may receive 421 (instance_incorrecte).

See the batch routes in the reference

DSN API: resend without a second check
Previous section
Alerts: Slack, Teams and webhook
Next section