Integration between the ERP and the website usually comes up when an order goes missing or an out-of-stock product is sold. Most failures we see in the field aren’t coding errors but the wrong choice of pattern: data that should be real-time is transferred at night, and data that could be transferred at night is requested from the ERP on every page load. The choice between synchronous API, webhook, message queue and bulk transfer for stock, prices, orders and account information needs to be made so that you can write down the rationale for each data type. System boundaries on the production side differ from general web API patterns; this distinction is covered in the article on data flows between MES and ERP with ISA-95.
Four data characteristics that determine the pattern
If you start the discussion with “which technology should we use”, the first interface the ERP offers gets applied to every flow. Then that interface’s weak spot blows up separately in every flow. Instead, answer four questions for each data flow first:
- Freshness requirement: How old can the data be on the web side? For a product description, a day isn’t a problem; for stock with only a few units left, even minutes mean overselling.
- Frequency and volume of change: A price list changes in bulk a few times a year; stock changes with every shipment and every sale. Frequent, small changes and rare, large changes aren’t carried with the same pattern.
- Tolerance for loss and duplication: A lost order is unacceptable. A stock update carrying an absolute value arriving twice, on the other hand, is harmless.
- Direction and ownership: Does the data flow one way, or can both systems change the same record? Two-way flow requires an ownership rule before a pattern is chosen.
These answers determine most of the pattern. The second filter is the ERP’s own constraints: is there an API, how many users does the concurrent session license allow, when is the maintenance window? The license limit is noticed late in most projects. It turns out expensive.
Synchronous API calls: where they’re enough, where they’re dangerous
In the synchronous pattern, the web application calls the ERP’s API directly while processing the user’s request and waits for the response. When a dealer clicks “add to cart” in a B2B portal, their net price is queried from the ERP at that moment. The data is always current, with no layer in between.
The price is that the availability of the two systems becomes tied together. If the ERP is in nightly maintenance, slow or has hit its license limit, the website also slows down or returns errors. When traffic rises, the load lands directly on the ERP; on campaign day, the accounting users’ screens freeze. This is the picture we see most often in the field: the problem shows up on the web, but the root cause is the ERP’s session pool. A synchronous call is reasonable under these conditions:
- If the query is low-volume and limited to authenticated users (dealer-specific price, account balance).
- If the response can be cached briefly and there’s a meaningful fallback behavior when the ERP is unreachable (“contact your sales representative to confirm the price”).
- If the timeout is clearly defined. A web request shouldn’t wait for the ERP indefinitely.
Going to the ERP on every request for product listing pages opened by anonymous visitors is almost always wrong. The data is kept in a copy on the web side and updated with one of the patterns below. For details on timeout and retry rules, see the API error handling, retry and backoff guide.
Event-based transfer with webhooks
With a webhook, the source system sends a notification to an HTTP endpoint provided by the target system when something changes. Some ERPs and CRMs offer webhooks for events such as “order created” and “stock changed”; payment providers and shipping companies usually deliver status changes this way.
A webhook gives low latency without the cost of polling. But it has three limits, and you’ll run into all three in the field:
- The delivery guarantee depends on the sender. The sender decides how many times and for how long to retry while the receiver is unreachable. If that period runs out, the event is lost.
- There’s no ordering guarantee. Two events for the same record can arrive in reverse order.
- Duplicates are possible. The sender resends an event it didn’t get a response for; the receiver must filter out duplicates.
That’s why you shouldn’t make the webhook the single source of truth. Set it up together with a periodic reconciliation job that catches missed events. The signature verification, deduplication and ordering side of the receiving endpoint is explained in detail in the webhook receiver design guide.
An intermediate layer with a message queue
In the queue pattern, the web and the ERP don’t call each other directly. A message broker such as RabbitMQ, Azure Service Bus or Amazon SQS, or a simple job queue built with a database table, sits in between. The website writes the order to its own database and drops a message on the queue; a consumer process takes the message, transfers it to the ERP and acknowledges the message if successful.
The gain is that the two systems are decoupled in time. Even if the ERP is in maintenance for two hours, the web keeps taking orders; messages pile up and are processed in order when the ERP comes back. The number of consumers is set to the concurrency the ERP can handle, and the ERP is protected under load (queue-based load leveling). For ERPs with a license limit, this setting is the main protection mechanism.
The point often missed is this: writing a record to the database and dropping a message on the queue aren’t a single transaction. The order is saved, the message can’t be sent, and the order never reaches the ERP. Nobody notices either. The common solution is the transactional outbox pattern: the message is written to an outbox table in the same database transaction as the order; a separate process reads this table and passes it to the broker.
BEGIN;
INSERT INTO orders (id, customer_id, total, status)
VALUES (10452, 'C-0193', 18450.00, 'received');
INSERT INTO outbox (aggregate_id, event_type, payload, created_at)
VALUES (10452, 'order.created', '{"order_id":10452}', NOW());
COMMIT;
-- A separate publisher process: reads unsent records from the outbox,
-- passes them to the broker and marks the record as "sent".
Most message brokers provide “at-least-once” delivery; a consumer can receive the same message more than once. The record operation on the ERP side must be made idempotent with an external reference such as the web order number. An order arriving a second time with the same reference doesn’t create a new record. The missing check here is the most common cause of duplicate invoices in the field.
Scheduled bulk transfer and file-based integration
Not all data has to be real-time. For product cards, the category tree, price lists and account cards, a bulk transfer (ETL) that runs nightly or hourly is often the most robust and easiest-to-operate solution. If the ERP has no API or the API license is limited, dropping a CSV/XML file via SFTP is still a valid method. It’s an old method. But it works.
In file-based integration, the breaking points are clear:
- Atomic file delivery: The file is first written under a temporary name (
stock.csv.tmp) and renamed when complete. The receiver doesn’t process a half-written file. When this step is skipped, the typical symptom is “randomly” missing products. - Delta or full list: A full list is simple and self-correcting. A delta reduces volume, but a single missed file creates a permanent inconsistency. If you use deltas, reconcile with a weekly full list.
- Deleted records: If the delta file doesn’t carry deleted products, “ghost” products remain on the web. Carry the deactivation information as an explicit field.
- Character encoding and separators: UTF-8, the decimal separator and the field separator must be written into the agreement. Turkish characters and comma decimals are where things break most often; “1.250,00” is read as one thousand two hundred fifty on one side and as one point two five on the other.
Master data ownership and conflict resolution
The most common problem in two-way synchronization is both systems changing the same field and the last writer overwriting the other. A pattern doesn’t solve this. An ownership rule does: for each data field, a single system with write authority is defined, and the other system only reads that field.
| Data | Owner system | Role of the other system |
|---|---|---|
| Product code, unit, tax | ERP | Web only reads |
| Product description, images, SEO fields | Web / PIM | Not transferred to the ERP |
| Stock quantity | ERP | Web may hold reservations, doesn’t change the quantity |
| Order (creation) | Web | Transferred to the ERP once |
| Order status, invoice | ERP | Reported back to the web |
| Account address | Set by agreement | A change request flow is defined |
Different fields of the same record can have different owners; what matters is that the rule is written down at field level. For fields that can change on both sides, such as an account address, the approach of “create a change request on the web and sync back once it’s approved in the ERP” produces far fewer surprises than the last-write-wins model. An extra warning for stock: if the web side calculates “ERP stock minus open orders”, this deduction must not be made twice at the moment the open order is transferred to the ERP. This error shows stock lower than it is, and sellable products appear “out of stock”.
Comparing patterns and the order of decisions
| Pattern | Latency | Fault tolerance | Typical use |
|---|---|---|---|
| Synchronous API | Instant | Low; an ERP outage is reflected on the web | Dealer-specific price, balance query |
| Webhook | Seconds | Depends on the sender’s retry policy | Payment, shipping, order status |
| Message queue | Seconds–minutes | High; messages pile up rather than getting lost | Order transfer, stock changes |
| Bulk transfer / file | Minutes–hours | High; a full list self-corrects | Product card, price list, account card |
Follow this order when deciding:
- Is data loss unacceptable (orders, collections)? If so, use queue- or outbox-based transfer; don’t make the synchronous call the only mechanism.
- Must the data be current within minutes? If not, bulk transfer is enough. Unnecessary real-time behavior increases operating costs.
- Can the source system publish events? If so, receive events via a webhook or broker, and add periodic reconciliation for missed ones. If not, use short-interval polling with a “last modified time” filter.
- Is the data user-specific and instant (net price, credit limit)? A synchronous call is suitable; define a timeout, a short cache and a fallback behavior.
Real projects don’t have a single pattern; several work together depending on the data type: product cards in a nightly batch, stock via a queue, orders with an outbox, order status with a webhook, dealer prices with a synchronous query. Where there are this many flows, a separate monitoring layer is needed to see which one has quietly stopped; we explain this in the integration monitoring and reconciliation guide. If you need support choosing and implementing a pattern, see the scope on our ERP, CRM and API integrations page; for order and stock flows on the WooCommerce side, the WooCommerce e-commerce solutions page may also be relevant. A general description of basic patterns such as messaging, queues and the idempotent receiver is in Enterprise Integration Patterns; the transactional outbox isn’t from that catalog but a pattern from the later microservices literature.
Frequently asked questions
How often should stock be updated between the ERP and the website?
There’s no single right value; it depends on stock turnover and the cost of overselling. For low-stock, fast-moving products, a change event or short-interval queue-based transfer is needed. For well-stocked products, an hourly bulk transfer is often enough. Agree in writing with the business unit on the oldest acceptable stock information; the interval follows from that number.
Is integration possible if the ERP has no API?
If the ERP can produce XML or CSV, files can be transferred with a method the systems support. Mapping, reprocessing and the rules to apply to missing records are defined in advance. For file-based catalog transfers, see our XML Product, Stock and Price Integration service.
How are conflicts prevented in two-way synchronization?
A single system with write authority is defined for each field; the other system only reads that field. For fields that need to change on both sides, a change request and approval flow is set up instead of direct writes. The last-writer-wins model is acceptable only if the field is unimportant from a business perspective.
If there’s a webhook, is periodic synchronization still needed?
Usually, yes. Webhook delivery depends on the sender’s retry policy; if the receiver is unreachable for a long time, events are lost. An hourly or daily reconciliation job compares records on both sides, catches missed events and prevents inconsistency from becoming permanent.