[go: up one dir, main page]

Stores

Stores let you model the context your customers shop in.

Stores can be used to model, for example, physical retail locations, brand stores, or regions. They allow to define what subset of resources within a project is available in the context of a store.

Currently, a Store can hold Carts, Orders, Shopping Lists, Customers, and Products. For managing the availability of product assortments for your store, use Product Selections. Additional settings like languages or channels for inventory and pricing can be defined in the Store and used to query Product Projections that only contain localized values, inventory data and Prices that are suitable for the Store.

Permissions can be granted for particular Stores only.

For example, with an OAuth Scope like manage_orders:acme-inc:luxury-brand, an API Client can only access Carts and Orders within the Luxury Brand Store, but not within the Budget Brand Store.
Composable Commerce provides Store-scoped API methods to access resources within a specified Store only.
Learn more about Stores in our self-paced Stores and Channels module.

Representations

Store

id
String

Unique ID of the Store.

version
Int

Current version of the Store.

key
String

User-defined unique and immutable identifier for the Store.

MinLength2MaxLength256Pattern^[A-Za-z0-9_-]+$
name

Name of the Store.

languages
Array of Locale

Languages configured for the Store.

countries
Array of StoreCountry

Countries defined for the Store.

distributionChannels
Array of ChannelReference

Product Distribution Channels allowed for the Store.

MaxItems100
supplyChannels
Array of ChannelReference

Inventory Supply Channels allowed for the Store.

MaxItems100
productSelections

Controls availability of Products for this Store via Product Selections:

  • Leave empty if all Products in the Project should be available in this Store.
  • If only inactive Product Selections with IndividualExclusion ProductSelectionMode are provided, all the Products are available in this Store.
  • If all the Product Selections provided are inactive and there's at least a Product Selection of mode Individual, no Product is available in this Store.
  • If at least an active Product Selection is provided, only active Product Selections are considered to compute the availlability in this Store.
MaxItems100
custom

Custom fields for the Store.

createdAt

Date and time (UTC) the Store was initially created.

createdByBETA

IDs and references that created the Store.

lastModifiedAt

Date and time (UTC) the Store was last updated.

lastModifiedByBETA

IDs and references that last modified the Store.

StoreCountry

StoreDraft

key
String

User-defined unique and immutable identifier for the Store. Keys can only contain alphanumeric characters, underscores, and hyphens.

MinLength2MaxLength256Pattern^[A-Za-z0-9_-]+$
name

Name of the Store.

languages
Array of Locale
Languages defined in Project. Only languages defined in the Project can be used.
countries
Array of StoreCountry

Countries defined for the Store.

distributionChannels
ResourceIdentifier of a Channel with ProductDistribution ChannelRoleEnum.
MaxItems100
supplyChannels
ResourceIdentifier of a Channel with InventorySupply ChannelRoleEnum.
MaxItems100
productSelections

Controls availability of Products for this Store via active/inactive Product Selections:

  • Leave empty if all Products in the Project should be available in this Store.
  • If only inactive Product Selections with IndividualExclusion ProductSelectionMode are provided, all the Products are available in this Store.
  • If all the Product Selections provided are inactive and there's at least a Product Selection of mode Individual, no Product is available in this Store.
  • If at least an active Product Selection is provided, only active Product Selections are considered to compute the availability in this Store.
MaxItems100
custom

Custom fields for the Store.

StorePagedQueryResponse

PagedQueryResult with results containing an array of Store.
limit
Int
Default20Minimum0Maximum500
offset
Int
Number of elements skipped.
Default0Maximum10000
count
Int

Actual number of results returned.

total
Int
Total number of results matching the query. This number is an estimation that is not strongly consistent. This field is returned by default. For improved performance, calculating this field can be deactivated by using the query parameter withTotal=false. When the results are filtered with a Query Predicate, total is subject to a limit.
results
Array of Store
Stores matching the query.

StoreReference

id
String
Unique ID of the referenced Store.
typeId
store

Type of referenced resource.

obj
Contains the representation of the expanded Store. Only present in responses to requests with Reference Expansion for Stores.

StoreKeyReference

key
String
Unique and immutable key of the referenced Store.
typeId
store

Type of referenced resource.

StoreResourceIdentifier

ResourceIdentifier to a Store. Either id or key is required. If both are set, an InvalidJsonInput error is returned.
id
String
Unique ID of the referenced Store. Required if key is absent.
key
String
Unique key of the referenced Store. Required if id is absent.
typeId
store
Type of referenced resource. If given, it must match the expected ReferenceTypeId of the referenced resource.

ProductSelectionSetting

productSelection

Reference to a ProductSelection.

active
Boolean
If true, all Products assigned to this Product Selection are part of the Store's assortment.

ProductSelectionSettingDraft

productSelection

Resource Identifier of a ProductSelection.

active
Boolean
Set to true if all Products assigned to the Product Selection should become part of the Store's assortment.
Defaultfalse

Get Store

Get Store by ID

GET
https://api.{region}.commercetools.com/{projectKey}/stores/{id}
OAuth 2.0 Scopes:
view_stores:{projectKey}
Path parameters:
region
String
Region in which the Project is hosted.
projectKey
String
key of the Project.
id
String
id of the Store.
Query parameters:
expand
The parameter can be passed multiple times.
Response:
200

Store

as
application/json
Request Example:cURL
curl --get https://api.{region}.commercetools.com/{projectKey}/stores/{id} -i \
--header "Authorization: Bearer ${BEARER_TOKEN}" 
200 Response Example: Storejson
{
  "id": "c2f93299-c967-44af-8c2a-d2220bf39eb2",
  "version": 1,
  "key": "random-key-12314",
  "name": {
    "en": "big store"
  },
  "languages": [],
  "countries": [],
  "distributionChannels": [],
  "supplyChannels": [],
  "productSelections": [],
  "createdAt": "1971-01-01T00:00:00.001Z",
  "lastModifiedAt": "1972-01-01T00:00:00.001Z"
}

Get Store by Key

GET
https://api.{region}.commercetools.com/{projectKey}/stores/key={key}
OAuth 2.0 Scopes:
view_stores:{projectKey}
Path parameters:
region
String
Region in which the Project is hosted.
projectKey
String
key of the Project.
key
String
key of the Store.
Query parameters:
expand
The parameter can be passed multiple times.
Response:
200

Store

as
application/json
Request Example:cURL
curl --get https://api.{region}.commercetools.com/{projectKey}/stores/key={key} -i \
--header "Authorization: Bearer ${BEARER_TOKEN}" 
200 Response Example: Storejson
{
  "id": "c2f93299-c967-44af-8c2a-d2220bf39eb2",
  "version": 1,
  "key": "random-key-12314",
  "name": {
    "en": "big store"
  },
  "languages": [],
  "countries": [],
  "distributionChannels": [],
  "supplyChannels": [],
  "productSelections": [],
  "createdAt": "1971-01-01T00:00:00.001Z",
  "lastModifiedAt": "1972-01-01T00:00:00.001Z"
}

Query Stores

GET
https://api.{region}.commercetools.com/{projectKey}/stores
OAuth 2.0 Scopes:
view_stores:{projectKey}
Path parameters:
region
String
Region in which the Project is hosted.
projectKey
String
key of the Project.
Query parameters:
where
The parameter can be passed multiple times.
sort
The parameter can be passed multiple times.
expand
The parameter can be passed multiple times.
limit
Int
Default: 20
Minimum: 0
Maximum: 500
offset
Int
Number of elements skipped.
Default: 0
Maximum: 10000
withTotal
Boolean
Controls the calculation of the total number of query results. Set to false to improve query performance when the total is not needed.
Default: true
var.<varName>
String
The parameter can be passed multiple times.
Response:
200

StorePagedQueryResponse

as
application/json
Request Example:cURL
curl --get https://api.{region}.commercetools.com/{projectKey}/stores -i \
--header "Authorization: Bearer ${BEARER_TOKEN}" 
200 Response Example: StorePagedQueryResponsejson
{
  "limit": 20,
  "offset": 0,
  "count": 2,
  "total": 2,
  "results": [
    {
      "id": "c2f93299-c967-44af-8c2a-d2220bf39eb2",
      "version": 1,
      "key": "random-key-12314",
      "name": {
        "en": "big store"
      },
      "languages": [],
      "countries": [],
      "distributionChannels": [],
      "supplyChannels": [],
      "productSelections": [],
      "createdAt": "1971-01-01T00:00:00.001Z",
      "lastModifiedAt": "1972-01-01T00:00:00.001Z"
    },
    {
      "id": "c2f93209-c967-44af-8c2a-d2220bf39eb2",
      "version": 1,
      "key": "random-key-1234314",
      "name": {
        "en": "second store"
      },
      "languages": [],
      "countries": [],
      "distributionChannels": [],
      "supplyChannels": [],
      "productSelections": [],
      "createdAt": "1973-01-01T00:00:00.001Z",
      "lastModifiedAt": "1973-01-01T00:00:00.001Z"
    }
  ]
}

Check if Store exists

Check if Store exists by ID

HEAD
https://api.{region}.commercetools.com/{projectKey}/stores/{id}
Checks if a Store exists with the provided id. Returns a 200 status if the Store exists, or a 404 status otherwise.
OAuth 2.0 Scopes:
view_states:{projectKey}
Path parameters:
region
String
Region in which the Project is hosted.
projectKey
String
key of the Project.
id
String
id of the Store.
Response:
200
Request Example:cURL
curl --head https://api.{region}.commercetools.com/{projectKey}/stores/{id} -i \
--header "Authorization: Bearer ${BEARER_TOKEN}" 

Check if Store exists by Key

HEAD
https://api.{region}.commercetools.com/{projectKey}/stores/key={key}
Checks if a Store exists with the provided key. Returns a 200 status if the Store exists, or a 404 status otherwise.
OAuth 2.0 Scopes:
view_stores:{projectKey}
Path parameters:
region
String
Region in which the Project is hosted.
projectKey
String
key of the Project.
key
String
key of the Store.
Response:
200
Request Example:cURL
curl --head https://api.{region}.commercetools.com/{projectKey}/stores/key={key} -i \
--header "Authorization: Bearer ${BEARER_TOKEN}" 

Check if Store exists by Query Predicate

HEAD
https://api.{region}.commercetools.com/{projectKey}/stores
Checks if one or more Stores exist for the provided query predicate. Returns a 200 status if any Stores match the query predicate, or a 404 status otherwise.
OAuth 2.0 Scopes:
view_stores:{projectKey}
Path parameters:
region
String
Region in which the Project is hosted.
projectKey
String
key of the Project.
Query parameters:
where
Query Predicates on Stores are limited to Text, Enum, Boolean, Number, Date, Time, and DateTime attribute types.
The parameter can be passed multiple times.
Response:
200
Request Example:cURL
curl --head https://api.{region}.commercetools.com/{projectKey}/stores -i \
--header "Authorization: Bearer ${BEARER_TOKEN}" 

Create Store

POST
https://api.{region}.commercetools.com/{projectKey}/stores
OAuth 2.0 Scopes:
manage_stores:{projectKey}
Path parameters:
region
String
Region in which the Project is hosted.
projectKey
String
key of the Project.
Query parameters:
expand
The parameter can be passed multiple times.
Request Body:StoreDraftasapplication/json
Response:
201

Store

as
application/json
Request Example:cURL
curl https://api.{region}.commercetools.com/{projectKey}/stores -i \
--header "Authorization: Bearer ${BEARER_TOKEN}" \
--header 'Content-Type: application/json' \
--data-binary @- << DATA 
{
  "key" : "random-key-123",
  "name" : {
    "en" : "main store"
  }
}
DATA
201 Response Example: Storejson
{
  "id": "c2f93299-c967-44af-8c2a-d2220bf39eb2",
  "version": 1,
  "key": "random-key-12314",
  "name": {
    "en": "big store"
  },
  "languages": [],
  "countries": [],
  "distributionChannels": [],
  "supplyChannels": [],
  "productSelections": [],
  "createdAt": "1971-01-01T00:00:00.001Z",
  "lastModifiedAt": "1972-01-01T00:00:00.001Z"
}

Specific error codes:

Update Store

Update Store by ID

POST
https://api.{region}.commercetools.com/{projectKey}/stores/{id}
OAuth 2.0 Scopes:
manage_stores:{projectKey}
Path parameters:
region
String
Region in which the Project is hosted.
projectKey
String
key of the Project.
id
String
id of the Store.
Query parameters:
expand
The parameter can be passed multiple times.
Request Body:
application/json
version
Int
Expected version of the Store on which the changes should be applied. If the expected version does not match the actual version, a ConcurrentModification error will be returned.
actions
Array of StoreUpdateAction

Update actions to be performed on the Store.

Response:
200

Store

as
application/json
Request Example:cURL
curl https://api.{region}.commercetools.com/{projectKey}/stores/{id} -i \
--header "Authorization: Bearer ${BEARER_TOKEN}" \
--header 'Content-Type: application/json' \
--data-binary @- << DATA 
{
  "version" : 1,
  "actions" : [ {
    "action" : "setName",
    "name" : {
      "en" : "New Name"
    }
  } ]
}
DATA
200 Response Example: Storejson
{
  "id": "c2f93299-c967-44af-8c2a-d2220bf39eb2",
  "version": 1,
  "key": "random-key-12314",
  "name": {
    "en": "big store"
  },
  "languages": [],
  "countries": [],
  "distributionChannels": [],
  "supplyChannels": [],
  "productSelections": [],
  "createdAt": "1971-01-01T00:00:00.001Z",
  "lastModifiedAt": "1972-01-01T00:00:00.001Z"
}

Update Store by Key

POST
https://api.{region}.commercetools.com/{projectKey}/stores/key={key}
OAuth 2.0 Scopes:
manage_stores:{projectKey}
Path parameters:
region
String
Region in which the Project is hosted.
projectKey
String
key of the Project.
key
String
key of the Store.
Query parameters:
expand
The parameter can be passed multiple times.
Request Body:
application/json
version
Int
Expected version of the Store on which the changes should be applied. If the expected version does not match the actual version, a ConcurrentModification error will be returned.
actions
Array of StoreUpdateAction

Update actions to be performed on the Store.

Response:
200

Store

as
application/json
Request Example:cURL
curl https://api.{region}.commercetools.com/{projectKey}/stores/key={key} -i \
--header "Authorization: Bearer ${BEARER_TOKEN}" \
--header 'Content-Type: application/json' \
--data-binary @- << DATA 
{
  "version" : 1,
  "actions" : [ {
    "action" : "setName",
    "name" : {
      "en" : "New Name"
    }
  } ]
}
DATA
200 Response Example: Storejson
{
  "id": "c2f93299-c967-44af-8c2a-d2220bf39eb2",
  "version": 1,
  "key": "random-key-12314",
  "name": {
    "en": "big store"
  },
  "languages": [],
  "countries": [],
  "distributionChannels": [],
  "supplyChannels": [],
  "productSelections": [],
  "createdAt": "1971-01-01T00:00:00.001Z",
  "lastModifiedAt": "1972-01-01T00:00:00.001Z"
}

Update actions

Set Name

This update action produces the StoreNameSet Message.
action
String
"setName"
name

Value to set.

Example: json
{
  "action": "setName",
  "name": {
    "en": "New Name"
  }
}

Set Languages

This update action produces the StoreLanguagesChanged Message. Adding a language other than the ones defined in the Project returns a ProjectNotConfiguredForLanguages error.
action
String
"setLanguages"
languages
Array of Locale

Value to set.

Example: json
{
  "action": "setLanguages",
  "languages": [
    "en"
  ]
}

Set Countries

This update action produces the StoreCountriesChanged Message.
action
String
"setCountries"
countries
Array of StoreCountry

New value to set.

Example: json
{
  "action": "setCountries",
  "countries": [
    {
      "code": "DE"
    },
    {
      "code": "IT"
    }
  ]
}

Add Country

This update action produces the StoreCountriesChanged Message. It has no effect if the given country is already present in a Store.
action
String
"addCountry"
country
Value to append to countries.
Example: json
{
  "action": "addCountry",
  "country": {
    "code": "DE"
  }
}

Remove Country

This update action produces the StoreCountriesChanged Message. It has no effect if a given country is not present in a Store.
action
String
"removeCountry"
country
Value to remove from countries.
Example: json
{
  "action": "removeCountry",
  "country": {
    "code": "DE"
  }
}

Set Distribution Channels

This update action produces the StoreDistributionChannelsChanged Message.
Setting a Channel without the ProductDistribution ChannelRoleEnum returns a MissingRoleOnChannel error.
action
String
"setDistributionChannels"
distributionChannels
Value to set. If not defined, the Store's distributionChannels are unset.
MaxItems100
Example: json
{
  "action": "setDistributionChannels",
  "distributionChannels": [
    {
      "typeId": "channel",
      "id": "12345"
    }
  ]
}

Add Distribution Channel

This update action produces the StoreDistributionChannelsChanged Message. It has no effect if a given distribution channel is already present in a Store.
Adding a Channel without the ProductDistribution ChannelRoleEnum returns a MissingRoleOnChannel error.
action
String
"addDistributionChannel"
distributionChannel

Value to append.

Example: json
{
  "action": "addDistributionChannel",
  "distributionChannel": {
    "typeId": "channel",
    "id": "12345"
  }
}

Remove Distribution Channel

This update action produces the StoreDistributionChannelsChanged Message.
action
String
"removeDistributionChannel"
distributionChannel
Value to remove. ResourceIdentifier of a Channel with the ProductDistribution ChannelRoleEnum.
Example: json
{
  "action": "removeDistributionChannel",
  "distributionChannel": {
    "typeId": "channel",
    "id": "12345"
  }
}

Set Supply Channels

Setting a supply channel produces the StoreSupplyChannelsChanged Message.
Setting a Channel without the InventorySupply ChannelRoleEnum returns a MissingRoleOnChannel error.
action
String
"setSupplyChannels"
supplyChannels
Value to set. If not defined, the Store's supplyChannels are unset.
MaxItems100
Example: json
{
  "action": "setSupplyChannels",
  "supplyChannels": [
    {
      "typeId": "channel",
      "id": "12345"
    }
  ]
}

Add Supply Channel

This action has no effect if a given supply channel is already present in a Store.

Adding a supply channel produces the StoreSupplyChannelsChanged Message.
Adding a Channel without the InventorySupply ChannelRoleEnum returns a MissingRoleOnChannel error.
action
String
"addSupplyChannel"
supplyChannel

Value to append.

Example: json
{
  "action": "addSupplyChannel",
  "supplyChannel": {
    "typeId": "channel",
    "id": "12345"
  }
}

Remove Supply Channel

This update action produces the StoreSupplyChannelsChanged Message.
action
String
"removeSupplyChannel"
supplyChannel
Value to remove. ResourceIdentifier of a Channel with the InventorySupply ChannelRoleEnum.
Example: json
{
  "action": "removeSupplyChannel",
  "supplyChannel": {
    "typeId": "channel",
    "id": "12345"
  }
}

Add Product Selection

To make all included Products available to your customers of a given Store, add the Product Selections to the respective Store. This action has no effect if the given Product Selection is already present in the Store and has the same active flag.
action
String
"addProductSelection"
productSelection

Product Selection to add to the Store either activated or deactivated.

active
Boolean
Set to true to make all Products assigned to the referenced Product Selection available in the Store.
Defaultfalse
Example: json
{
  "action": "addProductSelection",
  "productSelection": {
    "typeId": "product-selection",
    "id": "e7ba4555-b1bb-483d-92d8-2c4a10778427"
  },
  "active": false
}

A Store can incorporate multiple Product Selections, which is useful if a Product Selection is shared between Stores. For example, you may want to create a shared Product Selection as your base catalog which is supplemented by individual Product Selections for each Store.

A Store without any Product Selection includes all Products of a Project.

The number of Product Selections configured for a Store is limited to 100.

Remove Product Selection

This action has no effect if the given Product Selection is not in the Store.

action
String
"removeProductSelection"
productSelection

Value to remove. The removed Product Selection is made offline.

Example: json
{
  "action": "removeProductSelection",
  "productSelection": {
    "typeId": "product-selection",
    "id": "e7ba4555-b1bb-483d-92d8-2c4a10778427"
  }
}

Set Product Selections

Instead of adding or removing Product Selections individually, you can also change all the Store's Product Selections in one go using this update action. The Store will only contain the Product Selections specified in the request.
action
String
"setProductSelections"
productSelections

Value to set.

  • If provided, Product Selections for which active is set to true are available in the Store.
  • If not provided or provided as empty array, the action removes all Product Selections from this Store, meaning all Products in the Project are available in this Store.
MaxItems100
Example: json
{
  "action": "setProductSelections",
  "productSelections": [
    {
      "productSelection": {
        "typeId": "product-selection",
        "id": "e7ba4555-b1bb-483d-92d8-2c4a10778427"
      },
      "active": false
    },
    {
      "productSelection": {
        "typeId": "product-selection",
        "id": "a7ba45e5-b1c2-482d-94d5-2c1a10118426"
      },
      "active": true
    }
  ]
}
The number of Product Selections configured for a Store is limited to 100.

Change Product Selection Active

ProductSelection in a Store can be activated or deactivated using this update action.
action
String
"changeProductSelectionActive"
productSelection

Current Product Selection of the Store to be activated or deactivated.

active
Boolean
Set to true if all Products assigned to the Product Selection should become part of the Store's assortment.
Defaultfalse
Example: json
{
  "action": "changeProductSelectionActive",
  "productSelection": {
    "typeId": "product-selection",
    "id": "e7ba4555-b1bb-483d-92d8-2c4a10778427"
  },
  "active": true
}

Set Custom Type

action
String
"setCustomType"
type
Defines the Type that extends the Store with Custom Fields. If absent, any existing Type and Custom Fields are removed from the Store.
fields
Sets the Custom Fields fields for the Store.
Example: json
{
  "action": "setCustomType",
  "type": {
    "id": "{{type-id}}",
    "typeId": "type"
  },
  "fields": {
    "exampleStringField": "TextString"
  }
}

Set CustomField

action
String
"setCustomField"
name
String
Name of the Custom Field.
value
If value is absent or null, this field will be removed if it exists. Removing a field that does not exist returns an InvalidOperation error. If value is provided, it is set for the field defined by name.
Example: json
{
  "action": "setCustomField",
  "name": "exampleStringField",
  "value": "TextString"
}

Delete Store

Delete Store by ID

DELETE
https://api.{region}.commercetools.com/{projectKey}/stores/{id}
OAuth 2.0 Scopes:
manage_stores:{projectKey}
Path parameters:
region
String
Region in which the Project is hosted.
projectKey
String
key of the Project.
id
String
id of the Store.
Query parameters:
version
Int

Last seen version of the resource.

expand
The parameter can be passed multiple times.
Response:
200

Store

as
application/json
Request Example:cURL
curl -X DELETE https://api.{region}.commercetools.com/{projectKey}/stores/{id}?version={version} -i \
--header "Authorization: Bearer ${BEARER_TOKEN}"
200 Response Example: Storejson
{
  "id": "c2f93299-c967-44af-8c2a-d2220bf39eb2",
  "version": 1,
  "key": "random-key-12314",
  "name": {
    "en": "big store"
  },
  "languages": [],
  "countries": [],
  "distributionChannels": [],
  "supplyChannels": [],
  "productSelections": [],
  "createdAt": "1971-01-01T00:00:00.001Z",
  "lastModifiedAt": "1972-01-01T00:00:00.001Z"
}

Delete Store by Key

DELETE
https://api.{region}.commercetools.com/{projectKey}/stores/key={key}
OAuth 2.0 Scopes:
manage_stores:{projectKey}
Path parameters:
region
String
Region in which the Project is hosted.
projectKey
String
key of the Project.
key
String
key of the Store.
Query parameters:
version
Int

Last seen version of the resource.

expand
The parameter can be passed multiple times.
Response:
200

Store

as
application/json
Request Example:cURL
curl -X DELETE https://api.{region}.commercetools.com/{projectKey}/stores/key={key}?version={version} -i \
--header "Authorization: Bearer ${BEARER_TOKEN}"
200 Response Example: Storejson
{
  "id": "c2f93299-c967-44af-8c2a-d2220bf39eb2",
  "version": 1,
  "key": "random-key-12314",
  "name": {
    "en": "big store"
  },
  "languages": [],
  "countries": [],
  "distributionChannels": [],
  "supplyChannels": [],
  "productSelections": [],
  "createdAt": "1971-01-01T00:00:00.001Z",
  "lastModifiedAt": "1972-01-01T00:00:00.001Z"
}