When companies connect an e-commerce storefront to an ERP core and an accounting platform, integration failures rarely stem from missing features inside any single product. Most production incidents happen in the transport and contract layer between them: a dropped TCP connection causes a client to submit the same invoice twice, an offset query skips newly inserted warehouse receipts mid-scan, or a slow webhook endpoint triggers cascading retry storms from a payment gateway. Building dependable integrations requires treating REST APIs and webhooks as strict engineering contracts rather than fragile glue scripts.
API Versioning and Drift-Free Pagination Contracts
In enterprise environments, connected tools almost never deploy upgrades on the same schedule. Modifying a JSON field name or changing a data type in place on an active endpoint can break nightly accounting reconciliation jobs without warning.
Versioning should prioritize backward compatibility within a major release. Adding optional response fields is generally safe, whereas breaking schema changes belong behind an explicit major version prefix (such as /v1/ and /v2/) or a versioned request header. Pairing older endpoints with standard Deprecation and Sunset response headers gives downstream teams predictable migration windows.
Equally critical is how list endpoints paginate large transaction tables such as orders, stock movements, or ledger entries:
| Technical Criterion | Offset Pagination (?page=5&limit=50) | Cursor Pagination (?cursor=abc&limit=50) |
|---|
| Query Mechanism | Skips the first N rows in a sorted result set | Anchors to the last seen unique ID or timestamp |
| Stability Under Concurrent Writes | Prone to duplicate or skipped rows as records shift | Preserves exact cursor position without page drift |
| Performance on Large Tables | Degrades as offset grows into hundreds of thousands | Stays consistent by leveraging database indexes directly |
| Arbitrary Page Jumping | Allows jumping directly to any numbered page | Designed for sequential machine-to-machine ingestion |
For scheduled background jobs pulling records from an ERP or order management system, cursor pagination (often called keyset pagination) provides far stronger consistency than offset whenever new transactions arrive during a scan.
Idempotency Keys and RFC 9457 Problem Details
Network timeouts frequently happen after a server has already committed a database transaction but before the HTTP response reaches the caller. If a client retries POST /invoices blindly, the receiving system creates a duplicate financial record.
To make write operations safe to retry, require an Idempotency-Key header (typically a client-generated UUID v4 or deterministic transaction token) on state-changing POST and PATCH requests. The server stores the key alongside a cryptographic hash of the request payload and the serialized response inside a bounded store (for example, with a 24-hour TTL):
- If a retry arrives with the same
Idempotency-Key and identical payload hash, the server replays the original response without re-running business logic. - If the same key is reused with a different payload, the server rejects the request immediately to surface client-side bugs.
- If the original request is still in flight, the server returns
409 Conflict or instructs the caller to wait briefly before retrying.
When requests fail, returning an unstructured string such as "Invalid order" forces downstream integrations to rely on brittle text matching. IETF RFC 9457 (Problem Details for HTTP APIs) defines a uniform application/problem+json response format centered on five standard members: type (a URI identifying the error category), title (a concise human-readable summary), status (the HTTP status code), detail (specific context for the occurrence), and instance (a URI pointing to the specific request trace), plus domain extensions such as invalid_params or retry_after. Automated consumers can then separate permanent validation errors (422) that need human review from transient failures (429, 503) eligible for automatic retry.
HMAC Webhook Verification and Resilient Delivery Loops
Unlike REST polling, webhooks reverse the direction of traffic so source platforms push events as soon as state changes. Drawing from Stripe's official webhook endpoint guidelines, a resilient listener and delivery pipeline should enforce four controls:
- 01Verify HMAC signatures against the raw body: Compute the HMAC-SHA256 digest over the exact unparsed byte payload rather than re-serialized JSON, because any whitespace or key-order difference invalidates the signature. Use a constant-time comparison function to mitigate timing side-channel attacks.
- 02Enforce a strict timestamp tolerance window: Most signed webhook headers include a dispatch timestamp. Reject events older than a short threshold (such as five minutes) to block replay attacks if a payload is intercepted.
- 03Acknowledge with 2xx quickly and queue asynchronously: Once the signature checks out and the raw event is persisted to a durable queue or transactional outbox table, return
200 OK or 202 Accepted immediately. Performing slow ERP lookups or PDF generation inside the HTTP handler risks timeouts, causing the sender to treat successful receipts as failures. - 04Apply exponential backoff with jitter and a Dead Letter Queue (DLQ): On the sender side, failed deliveries (
5xx or timeouts) should retry on an exponentially increasing schedule (for instance, 10 seconds, 30 seconds, 2 minutes, 10 minutes) combined with randomized jitter so recovering endpoints are not overwhelmed by synchronized retry bursts. Events that exhaust the retry budget should move to a DLQ for inspection and manual replay.
When building enterprise integration systems, combining idempotent consumers with signed, queued webhooks keeps order, inventory, and accounting workflows resilient even when events arrive late, out of order, or multiple times.
Scope, Trade-Offs, and Operational Limits
The practices outlined in this guide synthesize official specifications from IETF RFC 9457 and Stripe's webhook engineering documentation with ToanKhonTech's system architecture experience, rather than proprietary benchmarks against a specific ERP vendor. Idempotency guarantees hold only when the idempotency record is committed atomically alongside the target state change or guarded by distributed locking; decoupled checks without concurrency control remain vulnerable to race conditions under parallel bursts. Furthermore, for financial and inventory ledgers, webhooks should act as low-latency triggers rather than the sole source of truth, backed by a scheduled reconciliation job that verifies record totals across connected systems.