Commerce8 min read

How to Integrate Commercetools with Your Headless CMS

Connect Commercetools to your headless CMS so product teams can sync rich product copy, localized merchandising content, and launch updates to commerce experiences in real time.

Published April 29, 2026
01 β€” Overview

What is Commercetools?

Commercetools is an API-first commerce platform for building custom storefronts, marketplaces, B2B portals, and omnichannel commerce systems. Its main capabilities include product catalogs, carts, orders, pricing, promotions, customer accounts, and checkout flows. It’s widely used by enterprise retail, manufacturing, and B2B teams that need composable commerce instead of a fixed storefront stack.


02 β€” The case for integration

Why integrate Commercetools with a headless CMS?

Commercetools is strong at commerce logic: SKUs, variants, prices, carts, inventory, promotions, and orders. But a product detail page usually needs more than commerce data. You also need buying guides, localized product stories, SEO fields, campaign badges, comparison tables, sustainability claims, and launch content that changes faster than your catalog model should.


03 β€” Architecture

Architecture overview

A typical Sanity and Commercetools integration starts when an editor publishes product content in Sanity Studio. A Sanity webhook, filtered with GROQ, listens for documents like _type == 'productPage' and defined(commercetoolsKey). The webhook can call a Sanity Function, or your own small API route, with the changed document ID. That handler fetches the exact fields Commercetools needs from the Content Lake using GROQ, such as the Commercetools product key, localized name, slug, description, SEO title, badges, and linked campaign references. The handler then authenticates to Commercetools with the Client Credentials flow, using the project key, client ID, client secret, auth host, and API host from your Commercetools project settings. It calls the Commercetools Product API, commonly products/key={key}, reads the current version, and sends update actions such as changeName, setDescription, changeSlug, or custom field updates. From there, the storefront can render price, availability, cart, and promotions from Commercetools, while using Sanity for editorial content, or it can use synced fields inside Commercetools where your commerce workflow requires them. The end user sees one product experience, even though the content and commerce systems stay cleanly separated.


04 β€” Use cases

Common use cases

πŸ›οΈ

Rich product detail pages

Use Commercetools for variants, prices, and carts, while Sanity supplies localized product stories, feature blocks, buying guides, and SEO fields.

🌍

Localized commerce launches

Publish German, French, and US product copy from Sanity, then sync locale-specific names, slugs, and descriptions to Commercetools Product data.

πŸ“¦

Merchandising campaigns tied to SKUs

Reference Commercetools product keys from Sanity campaign pages so promotions, editorial modules, and product grids stay tied to the right catalog items.

🏒

B2B product portals

Combine Commercetools product selections, customer groups, and pricing with Sanity-managed technical specs, compliance documents, and industry-specific content.


05 β€” Implementation

Step-by-step integration

  1. 1

    Create a Commercetools project and API client

    In Commercetools Merchant Center, create or select a project, note the project key, region, auth URL, and API URL, then create an API client under Developer settings. For product updates, grant scopes such as manage_products:{projectKey}. Use narrower scopes in production when possible.

  2. 2

    Install the Commercetools and Sanity packages

    In your sync service, Sanity Function, or framework API route, install @commercetools/sdk-client-v2, @commercetools/platform-sdk, @sanity/client, and node-fetch if your runtime needs it.

  3. 3

    Model product content in Sanity Studio

    Create a productPage schema with fields like commercetoolsKey, title, slug, shortDescription, seoTitle, locale, badges, campaign references, and feature modules. Keep prices, inventory, carts, and orders in Commercetools.

  4. 4

    Create a publish trigger

    Add a Sanity webhook with a GROQ filter such as _type == 'productPage' && defined(commercetoolsKey). Send the document ID to a Sanity Function or webhook handler whenever product content is published or updated.

  5. 5

    Fetch Sanity content and call the Commercetools API

    Use GROQ to fetch only the fields needed for the Commercetools update. Authenticate to Commercetools with the Client Credentials flow, fetch the product by key, include its current version, and send Product update actions.

  6. 6

    Test the storefront path

    Publish a test product in Sanity, verify the Commercetools product version changes, confirm localized fields are correct, and render a page that combines Commercetools price and availability with Sanity product content.



07 β€” Why Sanity

How Sanity + Commercetools works

Build your Commercetools integration on Sanity

Sanity gives you the structured content foundation, real-time event system, and flexible APIs to connect product content with Commercetools cleanly.

Start building free β†’

08 β€” Comparison

CMS approaches to Commercetools

CapabilityTraditional CMSSanity
Product content modelingOften page-oriented, so product copy, feature blocks, and SEO fields can end up mixed into templates or rich text fields.Schema-as-code lets you model product pages, Commercetools keys, locale fields, badges, comparison tables, and campaign references as typed content.
Commercetools sync timingUpdates often depend on scheduled exports, plugins, or manual publishing steps outside the commerce workflow.Webhooks and Functions can react to publish events, fetch fresh content with GROQ, and call the Commercetools Product API without a separate worker.
Field-level payload controlIntegrations may receive full pages or HTML-heavy fields, which makes mapping to Commercetools update actions harder.GROQ can return one purpose-built payload with product key, localized strings, referenced badges, and campaign data in a single query.
Commerce ownership boundariesCommerce and editorial fields can blur, which increases the risk that price, stock, or product copy are edited in the wrong place.Sanity Studio can show editorial fields next to read-only Commercetools identifiers, helping teams keep price, inventory, and orders in Commercetools.
Multi-channel commerce deliveryContent is often shaped for one website first, then adapted later for mobile, marketplaces, or in-store screens.The same structured content can feed storefronts, mobile apps, Commercetools sync jobs, and AI agents through Agent Context.

09 β€” Next steps

Keep building

Explore related integrations to complete your content stack.

Ready to try Sanity?

See how Sanity's Content Operating System powers integrations with Commercetools and 200+ other tools.