The My Business Units API provides access to Business Units associated with a specific user.
Get My BusinessUnit
Get My BusinessUnit by ID
id. Returns a 200 status if the Business Unit exists and the Customer has access to it, or a ResourceNotFound error otherwise.manage_my_business_units:{projectKey}customer_id:{id}regionString ​ | Region in which the Project is hosted. |
projectKeyString ​ | key of the Project. |
idString ​ | id of the BusinessUnit. |
expandString ​ | Expanding a Customer reference (for example, associates[*].customer or inheritedAssociates[*].customer) is not permitted and returns an Unauthorized error.The parameter can be passed multiple times. |
application/jsoncurl --get https://api.{region}.commercetools.com/{projectKey}/me/business-units/{id} -i \
--header "Authorization: Bearer ${BEARER_TOKEN}" {
"id": "2a3baa00-44fa-4ab8-bec7-933c31e18dcc",
"version": 5,
"createdAt": "2022-04-19T15:36:17.510Z",
"lastModifiedAt": "2022-04-20T15:41:55.816Z",
"name": "commercetools",
"unitType": "Company",
"key": "commercetools",
"status": "Active",
"storeMode": "Explicit",
"stores": [],
"topLevelUnit": {
"typeId": "business-unit",
"key": "commercetools"
},
"addresses": [],
"shippingAddressIds": [],
"billingAddressIds": [],
"associates": [],
"associateMode": "Explicit",
"inheritedAssociates": [],
"approvalRuleMode": "Explicit"
}Get My BusinessUnit by Key
key. Returns a 200 status if the Business Unit exists and the Customer has access to it, or a ResourceNotFound error otherwise.manage_my_business_units:{projectKey}customer_id:{id}regionString ​ | Region in which the Project is hosted. |
projectKeyString ​ | key of the Project. |
keyString ​ | key of the BusinessUnit. |
expandString ​ | Expanding a Customer reference (for example, associates[*].customer or inheritedAssociates[*].customer) is not permitted and returns an Unauthorized error.The parameter can be passed multiple times. |
application/jsoncurl --get https://api.{region}.commercetools.com/{projectKey}/me/business-units/key={key} -i \
--header "Authorization: Bearer ${BEARER_TOKEN}" {
"id": "2a3baa00-44fa-4ab8-bec7-933c31e18dcc",
"version": 5,
"createdAt": "2022-04-19T15:36:17.510Z",
"lastModifiedAt": "2022-04-20T15:41:55.816Z",
"name": "commercetools",
"unitType": "Company",
"key": "commercetools",
"status": "Active",
"storeMode": "Explicit",
"stores": [],
"topLevelUnit": {
"typeId": "business-unit",
"key": "commercetools"
},
"addresses": [],
"shippingAddressIds": [],
"billingAddressIds": [],
"associates": [],
"associateMode": "Explicit",
"inheritedAssociates": [],
"approvalRuleMode": "Explicit"
}Query My BusinessUnits
200 status if successful, or a ResourceNotFound error otherwise.manage_my_business_units:{projectKey}customer_id:{id}regionString ​ | Region in which the Project is hosted. |
projectKeyString ​ | key of the Project. |
whereString ​ | Use to filter query responses. For more information, see Query Predicates. The parameter can be passed multiple times. |
sortString ​ | Use to sort query results. For more information, see Sorting. The parameter can be passed multiple times. |
expandString ​ | Expanding a Customer reference (for example, associates[*].customer or inheritedAssociates[*].customer) is not permitted and returns an Unauthorized error.The parameter can be passed multiple times. |
limitInt32 ​ | Number of results requested. Default: 20​Minimum: 0​Maximum: 500​ |
offsetInt32 ​ | Number of elements skipped. Default: 0​Maximum: 10000​ |
withTotalBoolean ​ | 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 ​ | Predicate parameter values. The parameter can be passed multiple times. |
BusinessUnitPagedQueryResponse
asapplication/jsoncurl --get https://api.{region}.commercetools.com/{projectKey}/me/business-units -i \
--header "Authorization: Bearer ${BEARER_TOKEN}" {
"limit": 20,
"offset": 0,
"count": 1,
"total": 1,
"results": [
{
"id": "2a3baa00-44fa-4ab8-bec7-933c31e18dcc",
"version": 5,
"createdAt": "2022-04-19T15:36:17.510Z",
"lastModifiedAt": "2022-04-20T15:41:55.816Z",
"name": "commercetools",
"unitType": "Company",
"key": "commercetools",
"status": "Active",
"storeMode": "Explicit",
"stores": [],
"topLevelUnit": {
"typeId": "business-unit",
"key": "commercetools"
},
"addresses": [],
"shippingAddressIds": [],
"billingAddressIds": [],
"associates": [],
"associateMode": "Explicit",
"inheritedAssociates": [],
"approvalRuleMode": "Explicit"
}
]
}Check if My BusinessUnit exists
Check if My BusinessUnit exists by ID
id. Returns a 200 status if the BusinessUnit exists and the Customer has access to it, or a ResourceNotFound error otherwise.manage_my_business_units:{projectKey}customer_id:{id}regionString ​ | Region in which the Project is hosted. |
projectKeyString ​ | key of the Project. |
idString ​ | id of the BusinessUnit. |
curl --head https://api.{region}.commercetools.com/{projectKey}/me/business-units/{id} -i \
--header "Authorization: Bearer ${BEARER_TOKEN}" Check if My BusinessUnit exists by Key
key. Returns a 200 status if the Business Unit exists and the Customer has access to it, or a ResourceNotFound error otherwise.manage_my_business_units:{projectKey}customer_id:{id}regionString ​ | Region in which the Project is hosted. |
projectKeyString ​ | key of the Project. |
keyString ​ | key of the BusinessUnit. |
curl --head https://api.{region}.commercetools.com/{projectKey}/me/business-units/key={key} -i \
--header "Authorization: Bearer ${BEARER_TOKEN}" Check if My BusinessUnit exists by Query Predicate
200 status if any BusinessUnits match the Query Predicate and the Customer has access to them, or a ResourceNotFound error otherwise.manage_my_business_units:{projectKey}customer_id:{id}regionString ​ | Region in which the Project is hosted. |
projectKeyString ​ | key of the Project. |
whereString ​ | Use to filter query responses. For more information, see Query Predicates. The parameter can be passed multiple times. |
curl --head https://api.{region}.commercetools.com/{projectKey}/me/business-units -i \
--header "Authorization: Bearer ${BEARER_TOKEN}" Create My BusinessUnit
AddChildUnits Permission in the parent unit. If the required Permission is missing, an AssociateMissingPermission error is returned.manage_my_business_units:{projectKey}customer_id:{id}regionString ​ | Region in which the Project is hosted. |
projectKeyString ​ | key of the Project. |
expandString ​ | Expanding a Customer reference (for example, associates[*].customer or inheritedAssociates[*].customer) is not permitted and returns an Unauthorized error.The parameter can be passed multiple times. |
application/jsonapplication/jsoncurl https://api.{region}.commercetools.com/{projectKey}/me/business-units -i \
--header "Authorization: Bearer ${BEARER_TOKEN}" \
--header 'Content-Type: application/json' \
--data-binary @- << DATA
{
"name" : "commercetools",
"unitType" : "Company",
"key" : "commercetools"
}
DATA{
"id": "2a3baa00-44fa-4ab8-bec7-933c31e18dcc",
"version": 5,
"createdAt": "2022-04-19T15:36:17.510Z",
"lastModifiedAt": "2022-04-20T15:41:55.816Z",
"name": "commercetools",
"unitType": "Company",
"key": "commercetools",
"status": "Active",
"storeMode": "Explicit",
"stores": [],
"topLevelUnit": {
"typeId": "business-unit",
"key": "commercetools"
},
"addresses": [],
"shippingAddressIds": [],
"billingAddressIds": [],
"associates": [],
"associateMode": "Explicit",
"inheritedAssociates": [],
"approvalRuleMode": "Explicit"
}Create Associate for My BusinessUnit
UpdateAssociates Permission can use this endpoint to create a new Customer and associate it with the Business Unit.
If the required Permission is missing, an AssociateMissingPermission error is returned.manage_my_business_units:{projectKey}regionString ​ | Region in which the Project is hosted. |
projectKeyString ​ | key of the Project. |
businessUnitKeyString ​ | key of the BusinessUnit. |
application/jsonapplication/jsoncurl https://api.{region}.commercetools.com/{projectKey}/in-business-unit/key={businessUnitKey}/me/customers -i \
--header "Authorization: Bearer ${BEARER_TOKEN}" \
--header 'Content-Type: application/json' \
--data-binary @- << DATA
{
"version" : 2,
"customer" : {
"email" : "<random>@example.com",
"password" : "secret123",
"firstName" : "John",
"lastName" : "Doe"
},
"associateRoleAssignments" : [ {
"associateRole" : {
"key" : "buyer-role"
}
} ]
}
DATA{
"customer": {
"addresses": [],
"email": "johndoe@example.com",
"firstName": "John",
"id": "some_123_id",
"isEmailVerified": false,
"lastName": "Doe",
"password": "****aGg=",
"version": 1,
"createdAt": "2015-07-06T13:22:33.339Z",
"lastModifiedAt": "2015-07-06T13:22:33.339Z",
"authenticationMode": "Password",
"stores": [],
"shippingAddressIds": [],
"billingAddressIds": [],
"customerGroupAssignments": []
}
}Update My BusinessUnit
Update My BusinessUnit by ID
id. Returns a 200 status if the Business Unit exists and the Customer has access to it, or a ResourceNotFound error otherwise.manage_my_business_units:{projectKey}customer_id:{id}regionString ​ | Region in which the Project is hosted. |
projectKeyString ​ | key of the Project. |
idString ​ | id of the BusinessUnit. |
expandString ​ | Expanding a Customer reference (for example, associates[*].customer or inheritedAssociates[*].customer) is not permitted and returns an Unauthorized error.The parameter can be passed multiple times. |
application/jsonversion​Int64​ | Expected version of the BusinessUnit 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 MyBusinessUnitUpdateAction​ | Update actions to be performed on the BusinessUnit. |
application/jsoncurl https://api.{region}.commercetools.com/{projectKey}/me/business-units/{id} -i \
--header "Authorization: Bearer ${BEARER_TOKEN}" \
--header 'Content-Type: application/json' \
--data-binary @- << DATA
{
"version" : 3,
"actions" : [ {
"action" : "addAddress",
"address" : {
"streetName" : "Any Street",
"streetNumber" : "1337",
"postalCode" : "11111",
"city" : "Any City",
"country" : "US"
}
} ]
}
DATA{
"id": "2a3baa00-44fa-4ab8-bec7-933c31e18dcc",
"version": 5,
"createdAt": "2022-04-19T15:36:17.510Z",
"lastModifiedAt": "2022-04-20T15:41:55.816Z",
"name": "commercetools",
"unitType": "Company",
"key": "commercetools",
"status": "Active",
"storeMode": "Explicit",
"stores": [],
"topLevelUnit": {
"typeId": "business-unit",
"key": "commercetools"
},
"addresses": [],
"shippingAddressIds": [],
"billingAddressIds": [],
"associates": [],
"associateMode": "Explicit",
"inheritedAssociates": [],
"approvalRuleMode": "Explicit"
}Update My BusinessUnit by Key
key. Returns a 200 status if the Business Unit exists and the Customer has access to it, or a ResourceNotFound error otherwise.manage_my_business_units:{projectKey}customer_id:{id}regionString ​ | Region in which the Project is hosted. |
projectKeyString ​ | key of the Project. |
keyString ​ | key of the BusinessUnit. |
expandString ​ | Expanding a Customer reference (for example, associates[*].customer or inheritedAssociates[*].customer) is not permitted and returns an Unauthorized error.The parameter can be passed multiple times. |
application/jsonversion​Int64​ | Expected version of the BusinessUnit 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 MyBusinessUnitUpdateAction​ | Update actions to be performed on the BusinessUnit. |
application/jsoncurl https://api.{region}.commercetools.com/{projectKey}/me/business-units/key={key} -i \
--header "Authorization: Bearer ${BEARER_TOKEN}" \
--header 'Content-Type: application/json' \
--data-binary @- << DATA
{
"version" : 3,
"actions" : [ {
"action" : "addAddress",
"address" : {
"streetName" : "Any Street",
"streetNumber" : "1337",
"postalCode" : "11111",
"city" : "Any City",
"country" : "US"
}
} ]
}
DATA{
"id": "2a3baa00-44fa-4ab8-bec7-933c31e18dcc",
"version": 5,
"createdAt": "2022-04-19T15:36:17.510Z",
"lastModifiedAt": "2022-04-20T15:41:55.816Z",
"name": "commercetools",
"unitType": "Company",
"key": "commercetools",
"status": "Active",
"storeMode": "Explicit",
"stores": [],
"topLevelUnit": {
"typeId": "business-unit",
"key": "commercetools"
},
"addresses": [],
"shippingAddressIds": [],
"billingAddressIds": [],
"associates": [],
"associateMode": "Explicit",
"inheritedAssociates": [],
"approvalRuleMode": "Explicit"
}Update actions
Add Address
UpdateBusinessUnitDetails Permission. If the required Permission is missing, an AssociateMissingPermission error is returned.action​String​ | "addAddress" |
address​BaseAddress​ | The address to add to addresses. |
{
"action": "addAddress",
"address": {
"id": "exampleAddress",
"key": "exampleKey",
"title": "My Address",
"salutation": "Mr.",
"firstName": "Example",
"lastName": "Person",
"streetName": "Example Street",
"streetNumber": "4711",
"additionalStreetInfo": "Backhouse",
"postalCode": "80933",
"city": "Exemplary City",
"region": "Exemplary Region",
"state": "Exemplary State",
"country": "DE",
"company": "My Company Name",
"department": "Sales",
"building": "Hightower 1",
"apartment": "247",
"pOBox": "2471",
"phone": "+49 89 12345678",
"mobile": "+49 171 2345678",
"email": "mail@example.com",
"fax": "+49 89 12345679",
"additionalAddressInfo": "no additional Info",
"externalId": "Information not needed"
}
}Add Billing Address Identifier
UpdateBusinessUnitDetails Permission. If the required Permission is missing, an AssociateMissingPermission error is returned.action​String​ | "addBillingAddressId" |
addressId​String​ | ID of the address to add as a billing address. Either addressId or addressKey is required. |
addressKey​String​ | Key of the address to add as a billing address. Either addressId or addressKey is required. |
{
"action": "addBillingAddressId",
"addressId": "{{addressId}}"
}Add Shipping Address Identifier
UpdateBusinessUnitDetails Permission. If the required Permission is missing, an AssociateMissingPermission error is returned.action​String​ | "addShippingAddressId" |
addressId​String​ | ID of the address to add as a shipping address. Either addressId or addressKey is required. |
addressKey​String​ | Key of the address to add as a shipping address. Either addressId or addressKey is required. |
{
"action": "addShippingAddressId",
"addressId": "{{addressId}}"
}Change Address
UpdateBusinessUnitDetails Permission. If the required Permission is missing, an AssociateMissingPermission error is returned.action​String​ | "changeAddress" |
addressId​String​ | ID of the address to change. Either addressId or addressKey is required. |
addressKey​String​ | Key of the address to change. Either addressId or addressKey is required. |
address​BaseAddress​ | New address to set. |
{
"action": "changeAddress",
"addressId": "{{addressId}}",
"address": {
"id": "exampleAddress",
"key": "exampleKey",
"title": "My Address",
"salutation": "Mr.",
"firstName": "Example",
"lastName": "Person",
"streetName": "Example Street",
"streetNumber": "4711",
"additionalStreetInfo": "Backhouse",
"postalCode": "80933",
"city": "Exemplary City",
"region": "Exemplary Region",
"state": "Exemplary State",
"country": "DE",
"company": "My Company Name",
"department": "Sales",
"building": "Hightower 1",
"apartment": "247",
"pOBox": "2471",
"phone": "+49 89 12345678",
"mobile": "+49 171 2345678",
"email": "email@example.com",
"fax": "+49 89 12345679",
"additionalAddressInfo": "no additional Info",
"externalId": "Information not needed"
}
}Change Associate
UpdateAssociates Permission. If the required Permission is missing, an AssociateMissingPermission error is returned.action​String​ | "changeAssociate" |
associate​ | The Associate to add. |
{
"action": "changeAssociate",
"associate": {
"customer": {
"typeId": "customer",
"id": "some-customer-id"
},
"associateRoleAssignments": [
{
"associateRole": {
"typeId": "associate-role",
"key": "admin"
},
"inheritance": "Enabled"
},
{
"associateRole": {
"typeId": "associate-role",
"key": "buyer"
}
}
]
}
}Change Name
UpdateBusinessUnitDetails Permission. If the required Permission is missing, an AssociateMissingPermission error is returned.action​String​ | "changeName" |
name​String​ | New name to set. |
{
"action": "changeName",
"name": "commercetools"
}Change Parent Unit
UpdateParentUnit Permission. If the required Permission is missing, an AssociateMissingPermission error is returned.action​String​ | "changeParentUnit" |
parentUnit​ | New parent unit of the Business Unit. The new parent unit must have the same top-level unit as the old parent unit. |
{
"action": "changeParentUnit",
"parentUnit": {
"typeId": "business-unit",
"key": "commercetools"
}
}Remove Address
UpdateBusinessUnitDetails Permission. If the required Permission is missing, an AssociateMissingPermission error is returned.action​String​ | "removeAddress" |
addressId​String​ | ID of the address to be removed. Either addressId or addressKey is required. |
addressKey​String​ | Key of the address to be removed. Either addressId or addressKey is required. |
{
"action": "removeAddress",
"addressId": "{{addressId}}"
}Remove Associate
UpdateAssociates Permission. If the required Permission is missing, an AssociateMissingPermission error is returned.action​String​ | "removeAssociate" |
customer​ | Associate to remove. |
{
"action": "removeAssociate",
"customer": {
"typeId": "customer",
"id": "some-customer-id"
}
}Remove Billing Address Identifier
UpdateBusinessUnitDetails Permission. If the required Permission is missing, an AssociateMissingPermission error is returned.action​String​ | "removeBillingAddressId" |
addressId​String​ | ID of the billing address to be removed. Either addressId or addressKey is required. |
addressKey​String​ | Key of the billing address to be removed. Either addressId or addressKey is required. |
{
"action": "removeBillingAddressId",
"addressId": "{{addressId}}"
}Remove Shipping Address Identifier
UpdateBusinessUnitDetails Permission. If the required Permission is missing, an AssociateMissingPermission error is returned.action​String​ | "removeShippingAddressId" |
addressId​String​ | ID of the shipping address to be removed. Either addressId or addressKey is required. |
addressKey​String​ | Key of the shipping address to be removed. Either addressId or addressKey is required. |
{
"action": "removeShippingAddressId",
"addressId": "{{addressId}}"
}Set Address CustomField
UpdateBusinessUnitDetails Permission. If the required Permission is missing, an AssociateMissingPermission error is returned.action​String​ | "setAddressCustomField" |
addressId​String​ | ID of the address to be extended. |
name​String​ | Name of the Custom Field. |
value​ | If value is absent or null, this field will be removed if it exists.
Trying to remove a field that does not exist will fail with an InvalidOperation error.
If value is provided, it is set for the field defined by name. |
{
"action": "setAddressCustomField",
"name": "exampleStringField",
"value": "TextString",
"addressId": "{{address-id}}"
}Set Custom Type in Address
UpdateBusinessUnitDetails Permission. If the required Permission is missing, an AssociateMissingPermission error is returned.action​String​ | "setAddressCustomType" |
type​ | Defines the Type that extends the address with Custom Fields.
If absent, any existing Type and Custom Fields are removed from the address. |
fields​ | Object containing the Custom Fields fields for the
address.Required if at least one Custom Field is defined as required in the fieldDefinitions of the referenced Type. |
addressId​String​ | ID of the address to be extended. |
{
"action": "setAddressCustomType",
"type": {
"id": "{{type-id}}",
"typeId": "type"
},
"fields": {
"exampleStringField": "TextString"
},
"addressId": "{{address-id}}"
}Set ContactEmail
UpdateBusinessUnitDetails Permission. If the required Permission is missing, an AssociateMissingPermission error is returned.action​String​ | "setContactEmail" |
contactEmail​String​ | Email to set.
If contactEmail is absent or null, the existing contact email, if any, will be removed. |
{
"action": "setContactEmail",
"contactEmail": "contact@example.com"
}Set CustomField
UpdateBusinessUnitDetails Permission. If the required Permission is missing, an AssociateMissingPermission error is returned.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.
Trying to remove a field that does not exist will fail with an InvalidOperation error.
If value is provided, it is set for the field defined by name. |
{
"action": "setCustomField",
"name": "exampleStringField",
"value": "TextString"
}Set Custom Type
UpdateBusinessUnitDetails Permission. If the required Permission is missing, an AssociateMissingPermission error is returned.action​String​ | "setCustomType" |
type​ | Defines the Type that extends the BusinessUnit with Custom Fields.
If absent, any existing Type and Custom Fields are removed from the BusinessUnit. |
fields​ | Object containing the Custom Fields fields for the BusinessUnit.
Required if at least one Custom Field is defined as required in the fieldDefinitions of the referenced Type. |
{
"action": "setCustomType",
"type": {
"id": "{{type-id}}",
"typeId": "type"
},
"fields": {
"exampleStringField": "TextString"
}
}Set Default Billing Address ID
UpdateBusinessUnitDetails Permission. If the required Permission is missing, an AssociateMissingPermission error is returned.action​String​ | "setDefaultBillingAddress" |
addressId​String​ | ID of the address to add as a billing address. Either addressId or addressKey is required. |
addressKey​String​ | Key of the address to add as a billing address. Either addressId or addressKey is required. |
{
"action": "setDefaultBillingAddress",
"addressId": "{{addressId}}"
}Set Default Shipping Address ID
UpdateBusinessUnitDetails Permission. If the required Permission is missing, an AssociateMissingPermission error is returned.action​String​ | "setDefaultShippingAddress" |
addressId​String​ | ID of the address to add as a shipping address. Either addressId or addressKey is required. |
addressKey​String​ | Key of the address to add as a shipping address. Either addressId or addressKey is required. |
{
"action": "setDefaultShippingAddress",
"addressId": "{{addressId}}"
}Representations
MyBusinessUnitDraft
key​String​ | User-defined unique identifier for the BusinessUnit. MinLength:Â2​MaxLength: 256​Pattern: ^[A-Za-z0-9_-]+$​ |
unitType​ | Type of the Business Unit indicating its position in a hierarchy. |
name​String​ | Name of the Business Unit. |
contactEmail​String​ | Email address of the Business Unit. |
addresses​Array of BaseAddress​ | Addresses used by the Business Unit. |
shippingAddresses​Array of Int​ | Indexes of entries in addresses to set as shipping addresses.
The shippingAddressIds of the Customer will be replaced by these addresses. |
defaultShippingAddress​Int​ | Index of the entry in addresses to set as the default shipping address. |
billingAddresses​Array of Int​ | Indexes of entries in addresses to set as billing addresses.
The billingAddressIds of the Customer will be replaced by these addresses. |
defaultBillingAddress​Int​ | Index of the entry in addresses to set as the default billing address. |
custom​ | Custom Fields for the Business Unit. |
CompanyDraft
unitType​ | CompanyType of the Business Unit indicating its position in a hierarchy. |
DivisionDraft
unitType​ | DivisionType of the Business Unit indicating its position in a hierarchy. |
parentUnit​ | The parent unit of this Division. Can be a Company or a Division. |
MyBusinessUnitAssociateDraft
version​Int64​ | Expected version of the BusinessUnit on which the changes should be applied.
If the expected version does not match the actual version, a ConcurrentModification error will be returned. |
customer​ | Customer to create and assign to the Business Unit. |
associateRoleAssignments​Array of AssociateRoleAssignmentDraft​ | Roles assigned to the new Associate within a Business Unit. Can only contain AssociateRoles with the MinItems: buyerAssignable property set to true.1​ |