Zones
A Zone is used to define a ShippingRate for a set of locations.
A maximum number of 100 Zones can be created per Project. Learn more about this limit.
Representations
Zone
idString | Unique identifier of the Zone. |
versionInt | Current version of the Zone. |
keyString | User-defined unique identifier of the Zone. MinLength:2MaxLength: 256Pattern: ^[A-Za-z0-9_-]+$ |
nameString | Name of the Zone. |
descriptionString | Description of the Zone. |
locationsArray of Location | List of locations that belong to the Zone. |
createdAt | Date and time (UTC) the Zone was initially created. |
createdByBETA | IDs and references that created the Zone. |
lastModifiedAt | Date and time (UTC) the Zone was last updated. |
lastModifiedByBETA | IDs and references that last modified the Zone. |
{"id": "ebe01381-82be-4e63-9993-d1eb8f8e588b","version": 1,"name": "US","key": "us-zone","locations": [{"country": "US"}],"createdAt": "2015-01-21T09:22:04.275Z","lastModifiedAt": "2015-01-21T09:22:04.275Z"}
ZoneDraft
keyString | User-defined unique identifier for the Zone. MinLength:2MaxLength: 256Pattern: ^[A-Za-z0-9_-]+$ |
nameString | Name of the Zone. |
descriptionString | Description of the Zone. |
locationsArray of Location | List of locations that belong to the Zone. |
{"name": "US","locations": [{"country": "US"}]}
ZonePagedQueryResponse
PagedQueryResult with results containing an array of Zone.
limitInt | Number of results requested. Default:20Maximum: 500 |
offsetInt | Number of elements skipped. Default:0Maximum: 10 000 |
countInt | Actual number of results returned. |
totalInt | 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 |
resultsArray of Zone | Zones matching the query. |
{"limit": 20,"offset": 0,"count": 3,"total": 3,"results": [{"id": "ebe01381-82be-4e63-9993-d1eb8f8e588b","version": 1,"name": "US Mainland","locations": [{"country": "US"}],"createdAt": "2015-01-21T09:22:04.275Z","lastModifiedAt": "2015-01-21T09:22:04.275Z"},{"id": "ebe01381-82be-4e63-9993-d1eb8f8e5abc","version": 1,"name": "US Hawaii and Alaska","locations": [{"country": "US","state": "Hawaii"},{"country": "US","state": "Alaska"}],"createdAt": "2015-01-21T09:22:05.275Z","lastModifiedAt": "2015-01-21T09:22:05.275Z"},{"id": "5cb532be-c680-43ab-ba14-b664bb03dc35","version": 3,"name": "Europe","locations": [{"country": "DE"},{"country": "IT"},{"country": "FR"},{"country": "ES"}],"createdAt": "2015-01-21T09:22:04.266Z","lastModifiedAt": "2016-01-26T10:56:32.504Z"}]}
ZoneReference
idString | Unique identifier of the referenced Zone. |
typeId | "zone"References a Zone. |
objZone | Contains the representation of the expanded Zone. Only present in responses to requests with Reference Expansion for Zones. |
ZoneResourceIdentifier
ResourceIdentifier to a Zone. Either id or key is required. If both are set, an InvalidJsonInput error is returned.
Location
A geographical location representing a country and optionally a state within this country. A location can only be assigned to one Zone.
country | Country code of the geographic location. Pattern:^[A-Z]{2}$ |
stateString | State within the country. |
Get Zone
Get Zone by ID
view_orders:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
idString |
|
expand | The parameter can be passed multiple times. |
application/jsoncurl --get https://api.{region}.commercetools.com/{projectKey}/zones/{id} -i \--header "Authorization: Bearer ${BEARER_TOKEN}"
{"id": "ebe01381-82be-4e63-9993-d1eb8f8e588b","version": 1,"name": "US","key": "us-zone","locations": [{"country": "US"}],"createdAt": "2015-01-21T09:22:04.275Z","lastModifiedAt": "2015-01-21T09:22:04.275Z"}
Get Zone by Key
view_orders:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
keyString |
|
expand | The parameter can be passed multiple times. |
application/jsoncurl --get https://api.{region}.commercetools.com/{projectKey}/zones/key={key} -i \--header "Authorization: Bearer ${BEARER_TOKEN}"
{"id": "ebe01381-82be-4e63-9993-d1eb8f8e588b","version": 1,"name": "US","key": "us-zone","locations": [{"country": "US"}],"createdAt": "2015-01-21T09:22:04.275Z","lastModifiedAt": "2015-01-21T09:22:04.275Z"}
Query Zones
view_orders:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
where | The parameter can be passed multiple times. |
sort | The parameter can be passed multiple times. |
expand | The parameter can be passed multiple times. |
limitInt | Number of results requested. Default: 20 |
offsetInt | Number of elements skipped. Default: 0 |
withTotalBoolean | Controls the calculation of the total number of query results. Set to Default: true |
var.<varName>String | Predicate parameter values. The parameter can be passed multiple times. |
application/jsoncurl --get https://api.{region}.commercetools.com/{projectKey}/zones -i \--header "Authorization: Bearer ${BEARER_TOKEN}"
{"limit": 20,"offset": 0,"count": 3,"total": 3,"results": [{"id": "ebe01381-82be-4e63-9993-d1eb8f8e588b","version": 1,"name": "US Mainland","locations": [{"country": "US"}],"createdAt": "2015-01-21T09:22:04.275Z","lastModifiedAt": "2015-01-21T09:22:04.275Z"},{"id": "ebe01381-82be-4e63-9993-d1eb8f8e5abc","version": 1,"name": "US Hawaii and Alaska","locations": [{"country": "US","state": "Hawaii"},{"country": "US","state": "Alaska"}],"createdAt": "2015-01-21T09:22:05.275Z","lastModifiedAt": "2015-01-21T09:22:05.275Z"},{"id": "5cb532be-c680-43ab-ba14-b664bb03dc35","version": 3,"name": "Europe","locations": [{"country": "DE"},{"country": "IT"},{"country": "FR"},{"country": "ES"}],"createdAt": "2015-01-21T09:22:04.266Z","lastModifiedAt": "2016-01-26T10:56:32.504Z"}]}
Check if Zone exists
Check if Zone exists by ID
Checks if a Zone exists for a given id. Returns a 200 OK status if the Zone exists or a 404 Not Found otherwise.
view_orders:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
idString |
|
curl --head https://api.{region}.commercetools.com/{projectKey}/zones/{id} -i \--header "Authorization: Bearer ${BEARER_TOKEN}"
Check if Zone exists by Key
Checks if a Zone exists for a given key. Returns a 200 OK status if the Zone exists or a 404 Not Found otherwise.
view_orders:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
keyString |
|
curl --head https://api.{region}.commercetools.com/{projectKey}/zones/key={key} -i \--header "Authorization: Bearer ${BEARER_TOKEN}"
Check if Zone exists by Query Predicate
Checks if a Zone exists for a given Query Predicate. Returns a 200 OK status if any Zones match the Query Predicate or a 404 Not Found otherwise.
view_orders:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
where | The parameter can be passed multiple times. |
curl --head https://api.{region}.commercetools.com/{projectKey}/zones -i \--header "Authorization: Bearer ${BEARER_TOKEN}"
Create Zone
manage_orders:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
expand | The parameter can be passed multiple times. |
application/jsonapplication/jsoncurl https://api.{region}.commercetools.com/{projectKey}/zones -i \--header "Authorization: Bearer ${BEARER_TOKEN}" \--header 'Content-Type: application/json' \--data-binary @- << DATA{"name" : "US","locations" : [ {"country" : "US"} ]}DATA
{"id": "ebe01381-82be-4e63-9993-d1eb8f8e588b","version": 1,"name": "US","key": "us-zone","locations": [{"country": "US"}],"createdAt": "2015-01-21T09:22:04.275Z","lastModifiedAt": "2015-01-21T09:22:04.275Z"}
Update Zone
Update Zone by ID
manage_orders:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
idString |
|
expand | The parameter can be passed multiple times. |
application/jsonversionInt | Expected version of the Zone on which the changes should be applied. If the expected version does not match the actual version, a ConcurrentModification error will be returned. |
actionsArray of ZoneUpdateAction | Update actions to be performed on the Zone. |
application/jsoncurl https://api.{region}.commercetools.com/{projectKey}/zones/{id} -i \--header "Authorization: Bearer ${BEARER_TOKEN}" \--header 'Content-Type: application/json' \--data-binary @- << DATA{"version" : 1,"actions" : [ {"action" : "changeName","name" : "New Name"} ]}DATA
{"id": "ebe01381-82be-4e63-9993-d1eb8f8e588b","version": 1,"name": "US","key": "us-zone","locations": [{"country": "US"}],"createdAt": "2015-01-21T09:22:04.275Z","lastModifiedAt": "2015-01-21T09:22:04.275Z"}
Update Zone by Key
manage_orders:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
keyString |
|
expand | The parameter can be passed multiple times. |
application/jsonversionInt | Expected version of the Zone on which the changes should be applied. If the expected version does not match the actual version, a ConcurrentModification error will be returned. |
actionsArray of ZoneUpdateAction | Update actions to be performed on the Zone. |
application/jsoncurl https://api.{region}.commercetools.com/{projectKey}/zones/key={key} -i \--header "Authorization: Bearer ${BEARER_TOKEN}" \--header 'Content-Type: application/json' \--data-binary @- << DATA{"version" : 1,"actions" : [ {"action" : "changeName","name" : "New Name"} ]}DATA
{"id": "ebe01381-82be-4e63-9993-d1eb8f8e588b","version": 1,"name": "US","key": "us-zone","locations": [{"country": "US"}],"createdAt": "2015-01-21T09:22:04.275Z","lastModifiedAt": "2015-01-21T09:22:04.275Z"}
Update actions
Set Key
actionString | "setKey" |
keyString | If 2MaxLength: 256Pattern: ^[A-Za-z0-9_-]+$ |
{"action": "setKey","key": "keyString"}
Change Name
actionString | "changeName" |
nameString | New name of the Zone. |
{"action": "changeName","name": "changedName"}
Set Description
actionString | "setDescription" |
descriptionString | Description of the Zone. |
{"action": "setDescription","description": "new ZoneDescription"}
Add Location
actionString | "addLocation" |
location | Location to be added to the Zone. |
{"action": "addLocation","location": {"country": "AT"}}
Remove Location
actionString | "removeLocation" |
location | Location to be removed from the Zone. |
{"action": "removeLocation","location": {"country": "AT"}}
Delete Zone
Delete Zone by ID
manage_orders:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
idString |
|
versionInt | Last seen version of the resource. |
expand | The parameter can be passed multiple times. |
application/jsoncurl -X DELETE https://api.{region}.commercetools.com/{projectKey}/zones/{id}?version={version} -i \--header "Authorization: Bearer ${BEARER_TOKEN}"
{"id": "ebe01381-82be-4e63-9993-d1eb8f8e588b","version": 1,"name": "US","key": "us-zone","locations": [{"country": "US"}],"createdAt": "2015-01-21T09:22:04.275Z","lastModifiedAt": "2015-01-21T09:22:04.275Z"}
Delete Zone by Key
manage_orders:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
keyString |
|
versionInt | Last seen version of the resource. |
expand | The parameter can be passed multiple times. |
application/jsoncurl -X DELETE https://api.{region}.commercetools.com/{projectKey}/zones/key={key}?version={version} -i \--header "Authorization: Bearer ${BEARER_TOKEN}"
{"id": "ebe01381-82be-4e63-9993-d1eb8f8e588b","version": 1,"name": "US","key": "us-zone","locations": [{"country": "US"}],"createdAt": "2015-01-21T09:22:04.275Z","lastModifiedAt": "2015-01-21T09:22:04.275Z"}