Skip to main content
Design your webhook integration to handle the realities of distributed systems: retries, out-of-order delivery, and duplicate events.

Implement Idempotency

Use the eventId field to ensure you process each event exactly once, even if Smartcar retries delivery or you reprocess from your queue.

Why Idempotency Matters

  • Smartcar retries failed deliveries with the same eventId
  • Your queue worker might process the same message multiple times
  • Prevents duplicate database updates or notifications
  • Enables safe reprocessing of historical events

Implementation Strategies

Retention period: Store processed eventId values for at least 7 days to handle all retries and late reprocessing scenarios.

Handle Out-of-Order Delivery

Webhook events are delivered concurrently and may arrive out of order. Never assume events arrive in chronological sequence.

Use Timestamps for Freshness

Always check if incoming data is newer than your current stored state:

Why Order Matters

Events sent at different times may experience different network latencies, causing them to arrive out of sequence.
If an older event fails initially and is retried later, it might arrive after newer events that succeeded on first attempt.
Smartcar delivers events concurrently for performance. Events sent milliseconds apart might arrive in reverse order.

Timestamp-Based Updates


Handle Retries Gracefully

Smartcar automatically retries failed deliveries up to 3 times with exponential backoff.

Retry Identification

Each delivery attempt receives a unique deliveryId, but the eventId remains constant:

Processing Strategy

1

Check for duplicate eventId

Use idempotency check to skip already-processed events
2

Process the payload

Perform your business logic
3

Mark as processed

Store the eventId to prevent reprocessing
4

Return 200

Acknowledge successful processing
Don’t trigger retries manually. If you return a 2xx status code and then discover an issue, you cannot ask Smartcar to retry. The delivery is considered successful.

Transactional Processing

Ensure database updates and idempotency tracking happen atomically:

Recovery Strategies

Dead Letter Queue

Route persistently failing events to a dead letter queue for manual investigation:

Circuit Breaker

Stop processing if downstream dependencies are failing:

Next Steps

Monitoring

Track idempotency hits and processing failures

VEHICLE_ERROR Events

Handle error notifications and resolution tracking

Delivery Behavior

Understanding retry policies

Testing

Test retry scenarios