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 1 000 Customer Groups can be created per Project. Learn more about this limit.
Representations
CustomerGroup
id String | Unique ID of the Customer Group. |
version Int | Current version of the Customer Group. |
key String | User-defined unique identifier for the Customer Group. |
createdAt | Date and time (UTC) the Customer Group was initially created. |
createdBy BETA | Present on resources created after 1 February 2019 except for events not tracked. |
lastModifiedAt | Date and time (UTC) the Customer Group was last updated. |
lastModifiedBy BETA | Present on resources updated after 1 February 2019 except for events not tracked. |
name String | Unique name of the Customer Group. |
custom | Custom Fields for the Customer Group. |
CustomerGroupDraft
key String | User-defined unique identifier for the Customer Group. Keys can only contain alphanumeric characters, underscores, and hyphens. 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 Customer Group. |
CustomerGroupPagedQueryResponse
PagedQueryResult with results
containing an array of CustomerGroup.
limit Int | Number of results requested in the query request. |
offset Int | Offset supplied by the client or server default. It is the number of elements skipped, not a page number. |
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 ID of the referenced CustomerGroup. |
typeId String | "customer-group" |
obj | Contains the representation of the expanded Customer Group. Only present in responses to requests with Reference Expansion for Customer Groups. |
CustomerGroupResourceIdentifier
id String | Unique ID of the referenced CustomerGroup. Either |
key String | Unique key of the referenced CustomerGroup. Either |
typeId String | "customer-group" |
Get CustomerGroup
Get CustomerGroup by ID
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. |
curl -X GET https://api.{region}.commercetools.com/{projectKey}/customer-groups/{id} -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
Get CustomerGroup by Key
view_customers:{projectKey},
view_customer_groups:{projectKey}
region String | Region in which the Project is hosted. |
projectKey String |
|
key String |
|
expand | The parameter can be passed multiple times. |
curl -X GET https://api.{region}.commercetools.com/{projectKey}/customer-groups/key={key} -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
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 returned. |
offset Int | Number of results skipped. |
withTotal Boolean | Controls the calculation of the total number of query results. Set to |
curl -X GET https://api.{region}.commercetools.com/{projectKey}/customer-groups -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. |
curl -X POST 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
Update CustomerGroup
Update CustomerGroup by ID
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. |
version Int | Expected version of the Customer Group on which the changes should be applied. If the expected version does not match the actual version, a 409 Conflict will be returned. |
actions Array of CustomerGroupUpdateAction | Update actions to be performed on the Customer Group. |
curl -X POST 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
Update CustomerGroup by Key
manage_customers:{projectKey},
manage_customer_groups:{projectKey}
region String | Region in which the Project is hosted. |
projectKey String |
|
key String |
|
expand | The parameter can be passed multiple times. |
version Int | Expected version of the Customer Group on which the changes should be applied. If the expected version does not match the actual version, a 409 Conflict will be returned. |
actions Array of CustomerGroupUpdateAction | Update actions to be performed on the Customer Group. |
curl -X POST https://api.{region}.commercetools.com/{projectKey}/customer-groups/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
Update actions
Change Name
action String | "changeName" |
name String | New name of the Customer Group. |
{"action" : "changeName","name" : "New Name"}
Set Key
key String | If |
action String | "setKey" |
{"action" : "setKey","key" : "newKey"}
Set Custom Type
This action sets or removes the custom type for an existing Customer Group. If present, this action overwrites any existing custom type and fields.
action String | "setCustomType" |
type | If absent, the custom type and any existing CustomFields are removed. |
fields | Valid JSON object, based on the FieldDefinitions of the Type. Sets the custom fields to this value. |
{"action" : "setCustomType","type" : {"id" : "{{type-id}}","typeId" : "type"},"fields" : {"examplaryStringTypeField" : "TextString"}}
Set Custom Field
action String | "setCustomField" |
name String | Name of the Custom Field. |
value Any | Value must be of type Value.
If |
{"action" : "setCustomField","name" : "ExamplaryStringTypeField","value" : "TextString"}
Delete CustomerGroup
Delete CustomerGroup by ID
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. |
version Int | Last seen version of the resource. |
curl -X DELETE https://api.{region}.commercetools.com/{projectKey}/customer-groups/{id}?version={version} -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
Delete CustomerGroup by Key
manage_customers:{projectKey},
manage_customer_groups:{projectKey}
region String | Region in which the Project is hosted. |
projectKey String |
|
key String |
|
expand | The parameter can be passed multiple times. |
version Int | Last seen version of the resource. |
curl -X DELETE https://api.{region}.commercetools.com/{projectKey}/customer-groups/key={key}?version={version} -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'