commercetools API Extensions: custom business logic turnkey
When cart prices become stale and orders don't reach the ERP, the culprit is often not synchronization but the lack of custom logic in the commercetools lifecycle. The standard platform workflow cannot check minimum order amounts, validate promo codes from external systems, or dynamically recalculate prices. We develop API Extensions (also known as commercetools HTTP extensions) — synchronous HTTP hooks that inject business rules directly into resource creation and update operations without forking the platform. According to commercetools documentation, Extensions allow extending functionality without changing the core. In practice, this means you can implement cart validation, ERP synchronization, and custom discounts in days, not weeks. The service acts as middleware, connecting commercetools with external systems. Typical project cost ranges from $3,000 to $8,000, with most projects completed in 2–5 days. Get a consultation — we'll assess your scenario in one working day.
Key problems solved with API Extensions
Real-time cart validation
A typical case: an online store sells products with floating prices (currency exchange dependency). With every cart update, the Extension requests the current price from an external service and, if the price changed, adjusts the line item. Without this, a customer could pay at an old price. Such validation cut manual interventions by nine-tenths and saved the client over $1,200 monthly. On a project with 50,000 SKUs, response time stayed under 200 ms in 99th percentile.
Automatic order synchronization with ERP
Creating an order in commercetools must instantly reflect in 1C or SAP. An Extension for Order-Create receives the order, converts it to the required format, and sends it via API. If the ERP errors, we do not block order creation — we log it to a queue for retry to avoid losing orders. Implementing such an extension allowed one client to reduce order processing time from 30 minutes to 3 seconds — a 98% reduction. The integration costs around $4,000 and pays for itself within 3 months.
Dynamic promo codes and customer groups
commercetools lacks native support for "promo code only for VIP customers" with external database checking. An Extension analyzes customerGroup and, if needed, adds a discount code via the addDiscountCode action. Everything is atomic — the customer sees the final cart with the applied discount. For a large retailer, this feature generated $2,500 additional monthly revenue from targeted promotions.
How we develop these Extensions: case study of price recalculation from ERP
From a client project — an electronics online store — we implemented price recalculation via API Extensions. The task: prices are stored in ERP, and in commercetools only as cache. With every cart update, line item prices must be synchronized. The store catalog has over 50,000 SKUs, so response time is critical. The solution: an Extension on Node.js + Express:
app.post('/cart-reprice', async (req, res) => { const { resource } = req.body as ExtensionInput; const cart = resource.obj; const skus = cart.lineItems.map(li => li.variant.sku).filter(Boolean); const erpPrices = await fetchErpPrices(skus, cart.customerId); const actions: CartUpdateAction[] = []; for (const lineItem of cart.lineItems) { const erpPrice = erpPrices[lineItem.variant.sku]; if (!erpPrice) continue; const currentCentAmount = lineItem.price.value.centAmount; const erpCentAmount = Math.round(erpPrice * 100); if (currentCentAmount !== erpCentAmount) { actions.push({ action: 'setLineItemPrice', lineItemId: lineItem.id, externalPrice: { value: { centAmount: erpCentAmount, currencyCode: cart.totalPrice.currencyCode } } }); } } res.json({ actions }); }); The Extension receives the cart, fetches prices from ERP, and for each product where the price differs, generates setLineItemPrice. All changes are applied atomically — the customer sees the current total before checkout. This approach cut price update time from minutes to seconds and allowed the client to reduce manual corrections by 90%. Contact us to implement a similar solution.
Process of work
- Requirements analysis — examine business scenarios, identify extension points (Cart-Update, Order-Create, etc.).
- Extension design — describe data schema, branching logic, error handling.
- Implementation — write the service in Node.js/TypeScript or Python, set up authentication via AuthorizationHeader or IAM.
- Testing — use commercetools Playground for debugging, check timeout and edge cases.
- Deployment — configure Cloud Run (with min-instances) or Lambda with Provisioned Concurrency for cold start ≤200ms.
- Monitoring — review logs in Merchant Center, set up alerts for errors and delays.
Scope of work for These Extensions development
- Audit of business scenarios and identification of extension points
- Architecture design (data schema, error handling)
- Implementation in Node.js/TypeScript with authentication
- Testing in commercetools Playground and timeout scenarios
- Deployment on Cloud Run or Lambda with cold start tuning
- Documentation and training for your team
- Monitoring and alerts in Merchant Center
Timeline depending on complexity
| Type of Extension | Complexity | Estimated time |
|---|---|---|
| Cart validation | Low | 1–2 days |
| Price recalculation from ERP | High | 3–5 days |
| Order → ERP integration | Medium | 2–4 days |
| Payment status synchronization | Medium | 2–3 days |
| Custom promo codes | High | 4–6 days |
Exact estimate depends on business rule complexity — contact us, we will analyze your scenario and offer a turnkey solution.
Platform comparison for hosting the Extension
| Platform | Cold start | Cost per month | Management |
|---|---|---|---|
| Cloud Run | ≤200 ms (with min-instances) | ~$100 | Simple |
| AWS Lambda | ≤500 ms (with Provisioned Concurrency) | ~$200 | Complex |
| VPS (Docker) | Instant | ~$50 | Manual |
Common mistakes to avoid in API Extension development
- Ignoring the 2-second timeout. If the Extension makes an external call that may take >1.5s, use an async queue instead of waiting in the handler.
- Missing fallback on error. The ERP may be unavailable — in price recalculation, it's better to return current prices than to reject the operation. Exception: when price is critical (airline tickets).
- Hardcoded access keys. Always use environment variables or Secret Manager.
- Lack of monitoring. Set up logs and alerts to quickly identify issues.
Why choose us?
We have been developing these Extensions for commercetools since this feature was introduced — over 5 years. In that time, we have completed more than 50 projects: from simple validation to complex integrations with ERP and CRM. We guarantee stability — every Extension is covered by tests and undergoes load testing with 99.9% uptime. Our engineers use Repository pattern for code organization and Edge functions to reduce latency. We apply commercetools middleware patterns for reliable integration. Compared to custom background jobs, our Extensions respond in under 200ms, over 10x faster than polling alternatives.
Get a consultation on your scenario — we will analyze and propose a solution. We estimate the project in one working day. Contact us for a consultation.







