Zum Inhalt springen

Apply-Webhooks

Im Webhook-Modus (applyMode = 'webhook') wird ein abgeschlossener Import als HTTP-POST an Ihr Backend zugestellt — HMAC-signiert, dauerhaft wiederholt und in einem Zustellungs-Audit-Log erfasst.

POST /your/apply-endpoint
x-import-event: import.applied
x-import-delivery-id: dlv_4f2…
x-import-timestamp: 1717000000
x-import-signature: t=…,v1=hmac_sha256(body)…
content-type: application/json
{
"event": "import.applied",
"recordId": "rec_…",
"action": "submit",
"rowCount": 128,
"mapping": { "Email": "person.email", "First name": "person.firstName" },
"rows": [{ "person.email": "[email protected]", "person.firstName": "Ada" }]
}

Berechnen Sie einen HMAC-SHA256 über den rohen Anfrage-Body mit Ihrem Zustellungs-Secret und vergleichen Sie ihn in konstanter Zeit mit dem v1-Wert in x-import-signature. Der t=-Wert ist der signierte Zeitstempel — weisen Sie Zustellungen ab, deren Zeitstempel zu alt ist, um Replay-Angriffe abzuschwächen.

import { createHmac, timingSafeEqual } from 'node:crypto';
function verify(rawBody: string, header: string, secret: string): boolean {
const parts = Object.fromEntries(header.split(',').map(kv => kv.split('=')));
const expected = createHmac('sha256', secret).update(`${parts.t}.${rawBody}`).digest('hex');
const got = Buffer.from(parts.v1 ?? '', 'hex');
const exp = Buffer.from(expected, 'hex');
return got.length === exp.length && timingSafeEqual(got, exp);
}

Zustellungen werden mit Backoff wiederholt, bis Ihr Endpunkt 2xx zurückgibt. Verwenden Sie x-import-delivery-id (oder recordId) zum Deduplizieren — derselbe Import kann mehr als einmal zugestellt werden.