Comparing B2B and B2C eCommerce API Integrations
An eCommerce business connects its storefront to the systems that manage products, prices, inventory, orders, payments, and delivery. APIs, or application programming…
When your automation needs to respond to changes in another service, the remote service and your code split the work between webhooks and a REST API. The remote service sends a webhook, which is an HTTP request, to notify your code when an event happens, such as a record changing. Your code then calls the service's REST API to read current data or make updates.
Using both together lets your automation react to events right away instead of checking the service on a schedule. To keep that setup reliable, you need to verify incoming requests, handle duplicates and failures, pace your API traffic, and give operators a way to inspect and recover stuck work.
A webhook notifies your automation that a resource changed. The event data, called the payload, may include enough detail for your code to decide what to do. If it does not, your automation calls the API to fetch the resource's current state. Check the provider's event documentation to see what each payload includes and whether it reflects the latest state.
For example, a project service might send an event when someone updates an issue. Your receiver verifies the event, fetches the current issue through the API, and then updates a related record. Calling the API for the current state helps when the webhook payload carries limited details, or when a delayed event might otherwise lead your automation to act on stale data.
Webhooks also cut down on polling, where your code sends scheduled requests to check for changes. GitHub recommends subscribing to webhook events where possible; when you still need to poll, its REST API guidance recommends making efficient requests and paying attention to polling intervals. Subscribing to webhooks does not remove API quotas, and it does not guarantee you will never miss an event. You choose the balance between webhooks and polling based on what delivery and recovery options the provider offers and how costly an undetected change would be.
Your webhook receiver should verify that the request came from the expected sender, save enough data to recover the event, and return a success response. Leave slow work, such as calling another service or waiting for an approval, to a background worker.
A background worker reads saved events and processes them after the incoming HTTP request finishes. Save each event before your receiver responds. If your receiver returns a success code and then loses the event, the sender assumes everything went fine and has no reason to try again. AWS guidance on asynchronous communication describes using durable storage, such as a queue, to hold events safely between receipt and processing.
Every provider sets its own response deadline. GitHub, for example, asks webhook receivers to return a 2xx response within 10 seconds and recommends handling the work asynchronously. That 10-second limit applies to GitHub, so check your provider's contract rather than assuming all services use the same window. When your receiver accepts a request and hands the work to a background process, HTTP 202 Accepted signals that you accepted the request even though processing is not finished yet, as defined in HTTP Semantics.
A webhook URL on its own does not prove that a request came from the expected service. Serve your endpoint over HTTPS and follow the provider's signature-verification steps. GitHub's delivery validation guidance describes checking an HMAC-SHA256 signature against the original payload and comparing signatures with a constant-time method. Because providers use different headers, signing methods, and payload requirements, implement the exact procedure your provider documents.
After a network timeout or dropped connection, your automation may not know whether the remote service finished the request before the link broke. If your code sends the same request again and the first one already succeeded, the remote service can run the action twice.
Idempotency means that repeating an operation produces the same intended state as running it once. HTTP defines PUT and DELETE as idempotent methods, while POST and PATCH carry no such guarantee; the HTTP method reference explains these differences. Even so, how an API behaves in practice depends on how the provider built it.
When your automation might retry an API call, use the provider's documented idempotency-key feature if one exists. If the provider does not offer one, store a unique operation or event identifier and record whether your automation has handled it. Make sure your code checks that record and runs the action safely when two workers pick up the same event at nearly the same time. If your code checks the record in one step and updates it in another, both workers can pass the check before either one marks the work complete.
Treat incoming webhooks the same way. Providers may retry deliveries, so your receiver can see the same event more than once. GitHub sends a delivery identifier that stays the same across retries, which lets your receiver spot duplicates in GitHub integrations. Other providers use different identifiers or delivery rules, so review the provider's delivery semantics when you design the integration.
Cap how many times your workers retry a failed job, or how long they keep trying, and increase the wait between attempts when the provider recommends it. Once a job hits the retry limit, move it to a dead-letter queue, which is a separate holding place for failed work, or route it to another recovery path. Do not keep retrying authentication or validation errors, because those usually require a configuration fix before they will succeed. See common webhook failure categories for ways to separate failures that need different responses.
A sudden burst of webhooks can trigger a matching burst of API calls. Limit how many workers call the API at the same time, and use a queue to spread those requests out. When an API throttles your requests, have your workers follow its documented reset time or Retry-After instructions instead of retrying on a fixed schedule. GitHub's rate-limit documentation explains its specific limits and response guidance; other providers set their own rules.
Webhook events can also arrive late or out of order compared to when the changes happened. GitHub documents these behaviors in its webhook troubleshooting guidance. When order matters, have your workers check the provider's documented timestamps or version information to skip stale events, or call the API to fetch the resource's current state before acting.
To catch changes that the webhook path missed, run a periodic reconciliation check that compares your automation's records with the provider's current data. Keep each check narrow enough to stay within your API limits, and set its frequency based on how quickly the connected records need to match. This check helps you recover missed changes while still accounting for the provider's delivery guarantees.
When something breaks, operators need to trace what happened after a webhook arrived, which API call followed, and where the work stopped. Log event identifiers, receipt and processing times, verification results, attempt counts, and useful error details, while keeping credentials and sensitive payload data out of your logs.
Build controls that let an operator pause or resume processing, adjust worker concurrency, inspect stuck jobs, and replay eligible events. Subscribe only to the event types your automation uses. GitHub recommends selecting only necessary event types and checking both the event type and the action before processing, because providers can add new actions to an existing event over time.
Monitor more than whether your webhook endpoint returned success. Track how long events sit in the queue, how often workers retry, which API calls fail, how many events arrive as duplicates, and how long each action takes. Those numbers help operators tell the difference between delivery problems, rate limits, invalid credentials, and failures in downstream work.
Give Vroni a GitHub issue, bug report, spec, or rough idea. It reads the repo, plans the change, writes code, runs checks, and works toward a review-ready pull request.
Take a look at vroni.com