SDK v0.2 — automatic idempotency keys
WebhookClientService now sends an Idempotency-Key header on every call, eliminating a common source of duplicate events during retries.
The @nestarc/webhook-client SDK now generates and sends an Idempotency-Key header automatically for every send() call. If you pass idempotencyKey explicitly, that value is used; otherwise the SDK uses crypto.randomUUID() per send.
Why this matters
Without an idempotency key, a retry that happens to succeed on both attempts can create two downstream events from one logical action. The platform API already supported the Idempotency-Key header with a 24-hour TTL scoped per application and route - the SDK just wasn't sending it by default.
What changed
await webhookClient.send({
eventType: 'order.created',
payload: order,
// idempotencyKey: 'order.created:ord_123', // still recommended for cross-process retries
});For retries that span process restarts or queue workers, continue to pass a stable idempotencyKey so the same logical send reuses the same key across attempts.