This document gives an overview of the characteristics and common features of the API.

The HTTP API of the commercetools™ platform provides an interface for programmatic access to the data stored on the commercetools™ platform and the associated functionality. While it can be used directly, for experimentation or custom integration solutions, we recommend taking a look at our available client libraries and SDKs, which usually provide a more comfortable development experience.

In order to provide the best possible SLA and minimal latency, the commercetools platform™ API is being provided in two different regions:
Europe and United States.
These regions are completely isolated from each other and no data is transferred between them.

Platform accounts created for one region are not valid for the other one; so a signup is required for each region individually:

In case you need advice in which region your project should be located, please get in touch with us.


The HTTP API for projects on the commercetools™ platform is currently provided at the following URLs that is assumed to be prepended to all endpoints in the specific APIs:


In addition to the alternative scopes listed for each API operation, the scope manage_project:{projectKey} is always an implied valid scope. It grants full API access for all operations within that specific project.


The majority of the services consume and produce standard application/json payloads for the time being. Please use Content-type: application/json in your HTTP header when you are sending POST requests to our APIs so that the payload is encoded correctly. Consumers of JSON responses should ignore any unrecognized fields encountered in JSON objects of responses, or deal with them in a way that does not cause the client application to crash. The services will assume clients behave properly in that manner and thus consider the addition of new fields to be backwards-compatible with respect to existing clients. Clients should also not rely on the presence of undocumented fields. Fields that are returned by a service but are not documented can be renamed or disappear at any time without prior notice.


Many resources contain a string field id which uniquely identifies a resource. The ID is generated server-side on resource creation.

Some resources have a string field key which also uniquely identifies a resource. The key identifier is always assigned to a resource by the client.

Update Guarantees

Depending on the API request the platform provides different guarantees for which the update will be applied.

Strong Consistency

Each resource provides read-after-write consistency. It means that when you update an entity, wait for the successful response, and then read the same entity, you will see the changes you just made.

Eventual Consistency

Some updates will not be visible right after the update. For example, if you change a discount, the update on the discount itself provides read-after-write consistency. But the prices on all affected products are updated with a delay. When you read a price just after having changed the discount, you may read the old discount value. If you wait a bit, and retrieve the price again, you will read the new value.

After updating a product, the Product Projection Search index will be updated with a delay. A search result right after an update may not reflect this last update. When trying later, the search index will be updated.

These delayed updates provide an Eventual Consistency guarantee. It means that after a while, what you can read reflect all past updates.

These delays can vary depending on the amount of data to update. We provide our best efforts to keep these latencies as small as possible.

Optimistic Concurrency Control

Many resources exposed on the API employ optimistic concurrency control to prevent lost updates when making changes to existing data concurrently. Such resources carry around a version. When sending (partial) updates to such resources, the expected version of a resource needs to be a part in the representation sent with the request. The HTTP response body contains the new version of the resource.

A client must wait for the new version before sending follow-up requests, trying to guess the next version is considered bad practice.

Note that the current API deliberately does not use ETag + If-Match headers for the purpose of optimistic concurrency control. Future versions of the API may support ETags together with If-None-Match headers for the purpose of reducing network traffic.

In case of version mismatch, the API delivers a 409 HTTP status (Conflict).


All API access is over HTTPS. API authorization uses ↗ OAuth2 bearer tokens. See the section on authorization for details.

Query Features

Common query features include filtering, sorting, paging and reference expansion. Certain aspects of these features are standardized across all parts of the API as described in the following sections.

Single Resource Query Response

Query responses for single resources only return a single, top-level JSON object.


For query responses of requests supporting paging via limit and offset, the following common top-level fields are returned:


If queries support ad-hoc filtering of resources through flexible predicates, they do so via the where query parameter that accepts a single (possibly compound) predicate to determine whether a specific resource representation should be included in the result.

The structure of predicates and the names of the fields follow the structure and naming of the fields in the documented response representation of the query results.

Examples of predicates:

// Compare a field's value to a given value
name = "Peter"
age < 42
age > 42
age <= 42
age >= 42
age <> 42

// Combine any two conditional expressions in a logical conjunction / disjunction
name = "Peter" and age < 42
name = "Peter" or age < 42

// Negate any other conditional expression
not (name = "Peter" and age < 42)

// Check whether a field's value is or is not contained in
// a specified set of values.
age in (42, 43, 44)
age not in (42, 43, 44)

// to be noted: 'in' is much more efficient than several '='
// prefer:
name in ("Peter", "Barbara")
// to:
name = "Peter" or name = "Barbara"

// Check whether an array contains all or any of a set of values
tags contains all ("a", "b", "c")
tags contains any ("a", "b", "c")

// Check whether an array is empty
tags is empty

// Check whether a field exists & has a non-null value
name is defined
name is not defined

// Descend into nested objects
dog(age < 7 and name = "Beethoven")

// Descend into nested arrays of objects
cities(zip > 10000 and zip < 20000)

A query endpoint usually restricts predicates to only be allowed on a specified subset of a resource representation’s fields. The documentation of the endpoint will therefore list fields that can be used for constructing predicates.

If multiple predicates are specified via multiple where query parameters, the individual predicates are combined in a logical conjunction, just as if they had been specified in a single where query parameter and combined with and.

Note: The encoding of the predicates is UTF-8 and the predicate must be URL-encoded in the HTTP request.

Example predicate for a Product

# decoded predicate
masterData(current(slug(en="peter-42") and name(en="Peter")))

# URL-encoded predicate


A query endpoint that supports sorting does so through the sort query parameter. The provided value must be a valid sort expression.
The default sort direction is ASC. The allowed sort paths are typically listed on the specific query endpoints.

Here are some examples of sort expressions:

  name desc
  dog.age asc

If multiple sort expressions are specified via multiple sort parameters, they are combined into a composed sort where the results are first sorted by the first expression, followed by equal values being sorted according to the second expression, and so on.

Note: The sorting is case sensitive.


Queries on collections of resources can optionally provide paging functionality through limit and offset query parameters, thereby allowing clients to request a certain page of the complete query result.


The maximum number of results to return from a query can be set using the limit query parameter. Allowed is a value between 1 and 500. The default limit on most query endpoints is 20.


The offset into the results matching the query can be set using the offset query parameter. An offset of 0 is the default value indicating that no results should be skipped.

Note: When iterating on all elements from an endpoint (for example to import/export all products), using offset for that is not appropriate:

In cases where you want to iterate over all elements while avoiding offset you can follow this alternative approach instead:

The following pseudo-code demonstrates how to iterate on all elements returned by an endpoint, using chunks from 100 elements at each iteration:

lastId = null
continue = true
while (continue) {
  if (lastId == null)
    response = client.get(endpoint + "?limit=100&sort=id")
    response = client.get(endpoint + "?limit=100&sort=id&query=id%3E" + lastId) // "id%3E" is "id >" encoded
  results = response.results
  continue = (results.size == 100)
  lastId =
  // do something with result

Resource Timestamps

Many resources exposed on the API contain the createdAt and the lastModifiedAt timestamps. Those timestamps are automatically set by the server on creation or on modification of the resource. They can be used as predicates and for sorting in queries.

Reference Expansion

Reference expansion is a feature of the resources listed in the table below that enables clients to request server-side expansion of Reference resources, thereby reducing the number of required client-server roundtrips to obtain the data that a client needs for a specific use-case.

Reference expansion can be used when creating, updating, querying and deleting these resources.

Endpoints supporting Reference Expansion on creation, update, query and delete
Carts CartDiscounts Categories Channels
Customers CustomerGroups DiscountCodes State
Inventory Messages Orders Products
ProductDiscounts ProductProjections ProductTypes Reviews
ShippingMethods TaxCategories Types Zone

The JSON snippet below is taken from an Example-Product representation that contains two references: one to an Example-Product-Type and one to an Example-TaxCategory:

  "id": "<example-product-id>",
  "version": 4,
  "productType": {
    "typeId": "product-type",
    "id": "<example-product-type-id>"
  "taxCategory": {
    "typeId": "tax-category",
    "id": "<example-tax-category-id>"

Without Reference Expansion you’ll get such a representation as response from the query endpoints.
With Reference Expansion you’ll get the expanded objects embedded into the product by an additional obj field as shown in the following JSON snippet:

  "id": "<example-product-id>",
  "version": 4,
  "productType": {
    "typeId": "product-type",
    "id": "<example-product-type-id>"
    "obj": {
        "id": "<example-product-type-id>",
        "version": 4,
        "name": "Example Product Type",
        "description": "example Product Type to showcase Reference Expansion",
        "classifier": "Complex",
        "attributes": [
  "taxCategory": {
    "typeId": "tax-category",
    "id": "<tax-category-id>"
    "obj": {
        "id": "<tax-category-id>",
        "version": 2,
        "name": "Standard tax category",
        "rates": [
            "name": "5% US",
            "amount": 0.05,
            "includedInPrice": false,
            "country": "US",
            "id": "zJJ5KIGH"
            "name": "19% MwSt",
            "amount": 0.19,
            "includedInPrice": true,
            "country": "DE",
            "id": "893f_nXJ"

A query endpoint that supports reference expansion does so by providing an expand query parameter which can be used to specify one or more expansion paths.

Expansion path defines the full path to the reference in a resource. Expansion path format:

The query for the Example Product introduced before including expansion path would like this:

Expanding the Example Product</a>


Please find another example for expansion paths in our Product Bundle Tutorial.

The expansion path can also point to references in expanded objects.

Note that expansion of references does not cause requests to fail if not all of the references can be expanded (e.g. because the referenced resource cannot be found). The server will try to expand as much as possible but never beyond what the client requested. It is up to the client to decide which referenced resources it deems as critical for completing a specific use-case, e.g. by either treating it as an error or by simply not rendering / returning the missing information.

Partial Updates

For partial updates to existing resources, a common approach used by the HTTP API is to accept a custom patch format in the form of a list of resource-specific actions that need to be processed. The request method for partial update requests is usually POST, but PATCH might also be supported in the future.

The general request representation (patch format) of a partial update request is as follows:

Example Request

  "id": "a136fd9e-bc29-4d05-813f-350b248aefd8",
  "version": 1,
  "actions": [
      "action": "setTitle",
      "title": "My title"
      "action": "setText",
      "text": "My text"

The concrete actions that can be used on a specific resource are documented together with the resource.

All actions provided in a specific resource’s patch format are generally freely combinable in a single request. Furthermore, such update requests only succeed or fail as a whole, i.e. unless explicitly stated otherwise, the result of all actions sent in the request is applied to a resource or none at all, if any of the actions fail.

Not all updates or state transitions of a resource may be freely composable with one another in a single HTTP request. For those updates, other endpoints may be provided to handle only a specific update or state transition in a single HTTP request.

comments powered by Disqus