Customer Groups
A Customer can be a member of a Customer Group (for example, reseller, gold member). Special prices can be assigned to specific products based on a Customer Group.
A maximum number of 10 000
Customer
Groups can be created per Project. Learn more about this limit.
Learn more about managing Customer Groups in our self-paced Customer Management module.
Representations
CustomerGroup
id String | Unique identifier of the CustomerGroup. |
version Int | Current version of the CustomerGroup. |
key String | User-defined unique identifier for the CustomerGroup. MinLength:2 MaxLength: 256 Pattern: ^[A-Za-z0-9_-]+$ |
name String | Unique name of the CustomerGroup. |
custom | Custom Fields for the CustomerGroup. |
createdAt | Date and time (UTC) the CustomerGroup was initially created. |
createdBy BETA | IDs and references that created the CustomerGroup. |
lastModifiedAt | Date and time (UTC) the CustomerGroup was last updated. |
lastModifiedBy BETA | IDs and references that last modified the CustomerGroup. |
CustomerGroupDraft
key String | User-defined unique identifier for the CustomerGroup. MinLength:2 MaxLength: 256 Pattern: ^[A-Za-z0-9_-]+$ |
groupName String | Unique value which must be different from any value used for |
custom | Custom Fields for the CustomerGroup. |
CustomerGroupPagedQueryResponse
PagedQueryResult with results
containing an array of CustomerGroup.
limit Int | Number of results requested. |
offset Int | Number of elements skipped. |
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 |
results Array of CustomerGroup | CustomerGroups matching the query. |
CustomerGroupReference
Reference to a CustomerGroup.
id String | Unique identifier of the referenced CustomerGroup. |
typeId | "customer-group" References a CustomerGroup. |
obj | Contains the representation of the expanded CustomerGroup. Only present in responses to requests with Reference Expansion for CustomerGroups. |
CustomerGroupResourceIdentifier
ResourceIdentifier to a CustomerGroup. Either id
or key
is required. If both are set, an InvalidJsonInput error is returned.
id String | Unique identifier of the referenced CustomerGroup. Required if |
key String | User-defined unique identifier of the referenced CustomerGroup. Required if |
typeId | "customer-group" References a CustomerGroup. |
Get CustomerGroup
by ID
by Key
view_customers:{projectKey}
view_customer_groups:{projectKey}
region String | Region in which the Project is hosted. |
projectKey String |
|
id String |
|
expand | The parameter can be passed multiple times. |
application/json
curl --get https://api.{region}.commercetools.com/{projectKey}/customer-groups/{id} -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
{"id": "aef9cf41-94ad-4794-8122-62d308900430","version": 2,"name": "Webshop user","createdAt": "2017-01-10T06:51:25.896Z","lastModifiedAt": "2017-01-10T06:51:25.946Z"}
Query CustomerGroups
view_customers:{projectKey}
view_customer_groups:{projectKey}
region String | Region in which the Project is hosted. |
projectKey String |
|
where | Queryable field: The parameter can be passed multiple times. |
/^var[.][a-zA-Z0-9]+$/ Any string parameter matching this regular expression | Predicate parameter values. 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 | Number of results requested. |
offset Int | Number of elements skipped. |
withTotal Boolean | Controls the calculation of the total number of query results. Set to Default: true |
application/json
curl --get https://api.{region}.commercetools.com/{projectKey}/customer-groups -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
{"limit": 20,"offset": 0,"count": 1,"total": 1,"results": [{"id": "aef9cf41-94ad-4794-8122-62d308900430","version": 2,"name": "Webshop user","createdAt": "2017-01-10T06:51:25.896Z","lastModifiedAt": "2017-01-10T06:51:25.946Z"}]}
Check if CustomerGroup exists
by ID
by Key
by Query Predicate
Checks if a CustomerGroup exists for a given id
. Returns a 200 OK
status if the CustomerGroup exists or a 404 Not Found
otherwise.
view_customers:{projectKey}
view_customer_groups:{projectKey}
region String | Region in which the Project is hosted. |
projectKey String |
|
id String |
|
curl --head https://api.{region}.commercetools.com/{projectKey}/customer-groups/{id} -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
Create CustomerGroup
manage_customers:{projectKey}
manage_customer_groups:{projectKey}
region String | Region in which the Project is hosted. |
projectKey String |
|
expand | The parameter can be passed multiple times. |
application/json
application/json
curl https://api.{region}.commercetools.com/{projectKey}/customer-groups -i \--header 'Authorization: Bearer ${BEARER_TOKEN}' \--header 'Content-Type: application/json' \--data-binary @- << DATA{"groupName" : "Webshop user"}DATA
{"id": "aef9cf41-94ad-4794-8122-62d308900430","version": 2,"name": "Webshop user","createdAt": "2017-01-10T06:51:25.896Z","lastModifiedAt": "2017-01-10T06:51:25.946Z"}
Update CustomerGroup
by ID
by Key
manage_customers:{projectKey}
manage_customer_groups:{projectKey}
region String | Region in which the Project is hosted. |
projectKey String |
|
id String |
|
expand | The parameter can be passed multiple times. |
application/json
version Int | Expected version of the CustomerGroup 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 CustomerGroupUpdateAction | Update actions to be performed on the CustomerGroup. |
application/json
curl https://api.{region}.commercetools.com/{projectKey}/customer-groups/{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": "aef9cf41-94ad-4794-8122-62d308900430","version": 2,"name": "Webshop user","createdAt": "2017-01-10T06:51:25.896Z","lastModifiedAt": "2017-01-10T06:51:25.946Z"}
Delete CustomerGroup
by ID
by Key
manage_customers:{projectKey}
manage_customer_groups:{projectKey}
region String | Region in which the Project is hosted. |
projectKey String |
|
id String |
|
version Int | Last seen version of the resource. |
expand | The parameter can be passed multiple times. |
application/json
curl -X DELETE https://api.{region}.commercetools.com/{projectKey}/customer-groups/{id}?version={version} -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
{"id": "aef9cf41-94ad-4794-8122-62d308900430","version": 2,"name": "Webshop user","createdAt": "2017-01-10T06:51:25.896Z","lastModifiedAt": "2017-01-10T06:51:25.946Z"}