My Business Unit
This feature is part of Composable Commerce for B2B and will be subject to additional terms and pricing.
The My Business Unit endpoint creates and provides access to Business Units associated with a specific user. The endpoint requires an access token from the password flow or anonymous session flow.
A Business Unit created using the My Business Unit endpoint is Inactive by default. Additionally, there is a restriction on updating Business Unit status using the My Business Unit endpoint. This ensures that a merchant can inspect a Business Unit created by a Customer, assign the appropriate Products and Prices, and activate it only when it is ready to be used. You can change this default configuration through a Project-level setting.
My Business Unit allows Admin Customers to create new Business Units and edit their existing ones. New Customers can also sign-up and create and manage new Business Units.
The My Business Unit endpoint does not support managing the Stores of a Business Unit, changing the Business Unit status, or assigning new Associates. This intentional restriction provides additional security in scenarios when the client application must communicate directly with the Composable Commerce API, for example in the case of mobile applications. If you need to update a field available only on the full Business Unit resource, do so from a trusted, server-side application.
A checkout flow that uses My Business Unit, My Cart, and My Order endpoints has additional limitations. For example, the use of external prices or external taxes is not supported.
Representations
MyBusinessUnitDraft
keyString | User-defined unique identifier for the BusinessUnit. MinLength:2MaxLength: 256Pattern: ^[A-Za-z0-9_-]+$ |
unitType | Type of the Business Unit indicating its position in a hierarchy. |
nameString | Name of the Business Unit. |
contactEmailString | Email address of the Business Unit. |
addressesArray of BaseAddress | Addresses used by the Business Unit. |
shippingAddressesArray of Integer | Indexes of entries in |
defaultShipingAddressInt | Index of the entry in |
billingAddressesArray of Integer | Indexes of entries in |
defaultBillingAddressInt | Index of the entry in |
custom | Custom Fields for the Business Unit. |
CompanyDraft
Draft type to represent the top level of a business. Contains the fields and values of the generic MyBusinessUnitDraft that are used specifically for creating a Company.
unitTypeString | "Company"Top-level Business Unit. Must not have a |
DivisionDraft
Draft type to model divisions that are part of the Company or a higher order Division. Contains the fields and values of the generic MyBusinessUnitDraft that are used specifically for creating a Division.
unitTypeString | "Division"Business Unit with a |
parentUnit | The parent unit of this Division. Can be a Company or a Division. |
MyBusinessUnitAssociateDraft
versionInt | Expected version of the BusinessUnit on which the changes should be applied. If the expected version does not match the actual version, a 409 Conflict error will be returned. |
customer | Customer to create and assign to the Business Unit. |
Get BusinessUnit
Get BusinessUnit by ID
manage_my_business_units:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
idString |
|
expand | The parameter can be passed multiple times. |
200BusinessUnit
curl -X GET https://api.{region}.commercetools.com/{projectKey}/me/business-units/{id} -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
{"id" : "some-id","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" : [ ],"associates" : [ ]}
Get BusinessUnit by Key
manage_my_business_units:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
keyString |
|
expand | The parameter can be passed multiple times. |
200BusinessUnit
curl -X GET https://api.{region}.commercetools.com/{projectKey}/me/business-units/key={key} -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
{"id" : "some-id","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" : [ ],"associates" : [ ]}
Query BusinessUnits
manage_my_business_units:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
where | 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. |
limitInt | Number of results requested. |
offsetInt | Number of elements skipped. |
withTotalBoolean | Controls the calculation of the total number of query results. Set to |
curl -X 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" : "some-id","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" : [ ],"associates" : [ ]} ]}
Create BusinessUnit
Creating a Business Unit using the My Business Unit endpoint automatically assigns the authenticated user to the Business Unit in the Associate Roles of Admin as well as Buyer.
manage_my_business_units:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
expand | The parameter can be passed multiple times. |
201BusinessUnit
curl -X POST 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" : "some-id","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" : [ ],"associates" : [ ]}
Update BusinessUnit
To update a Business Unit using the My Business Unit endpoint, the authenticated user must be an Associate with the Admin role in the Business Unit.
Update BusinessUnit by ID
manage_my_business_units:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
idString |
|
expand | The parameter can be passed multiple times. |
versionInt | Expected version of the BusinessUnit on which the changes should be applied. If the expected version does not match the actual version, a 409 Conflict error will be returned. |
actionsArray of BusinessUnitUpdateAction | Update actions to be performed on the BusinessUnit. |
200BusinessUnit
curl -X POST 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" : "some-id","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" : [ ],"associates" : [ ]}
Update BusinessUnit by Key
manage_my_business_units:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
keyString |
|
expand | The parameter can be passed multiple times. |
versionInt | Expected version of the BusinessUnit on which the changes should be applied. If the expected version does not match the actual version, a 409 Conflict error will be returned. |
actionsArray of BusinessUnitUpdateAction | Update actions to be performed on the BusinessUnit. |
200BusinessUnit
curl -X POST 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" : "some-id","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" : [ ],"associates" : [ ]}
Update actions
Add Address
Adding an address to a Business Unit generates a BusinessUnitAddressAdded Message.
actionString | "addAddress" |
address | The address to add to |
{"action" : "addAddress","address" : {"id" : "exampleAddress","key" : "exampleKey","title" : "My Address","salutation" : "Mr.","firstName" : "Example","lastName" : "Person","streetName" : "Examplary 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
Adding a billing address to a Business Unit generates a BusinessUnitBillingAddressAdded Message.
actionString | "addBillingAddressId" |
addressIdString | ID of the address to add as a billing address. Either |
addressKeyString | Key of the address to add as a billing address. Either |
{"action" : "addBillingAddressId","addressId" : "{{addressId}}"}
Add Shipping Address Identifier
Adding a shipping address to a Business Unit generates a BusinessUnitShippingAddressAdded Message.
actionString | "addShippingAddressId" |
addressIdString | ID of the address to add as a shipping address. Either |
addressKeyString | Key of the address to add as a shipping address. Either |
{"action" : "addShippingAddressId","addressId" : "{{addressId}}"}
Change Address
Changing the address on a Business Unit generates the BusinessUnitAddressChanged Message.
actionString | "changeAddress" |
addressIdString | ID of the address to change. Either |
addressKeyString | Key of the address to change. Either |
address | New address to set. |
{"action" : "changeAddress","addressId" : "{{addressId}}","address" : {"id" : "exampleAddress","key" : "exampleKey","title" : "My Address","salutation" : "Mr.","firstName" : "Example","lastName" : "Person","streetName" : "Examplary 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
Updating the Associate on a Business Unit generates the BusinessUnitAssociateChanged Message.
actionString | "changeAssociate" |
associate | The Associate to add. |
{"action" : "changeAssociate","associate" : {"customer" : {"typeId" : "customer","id" : "some-customer-id"},"roles" : [ "Admin" ]}}
Change Name
Updating the name on a Business Unit generates a BusinessUnitNameChanged Message.
actionString | "changeName" |
nameString | New name to set. |
{"action" : "changeName","name" : "commercetools"}
Change Parent Unit
Changing the parent of a Business Unit generates a BusinessUnitParentUnitChanged Message. The user must be an Associate with the Admin role in the new parent unit.
actionString | "changeParentUnit" |
parentUnit | New parent unit of the Business Unit. |
{"action" : "changeParentUnit","parentUnit" : {"typeId" : "business-unit","key" : "commercetools"}}
Remove Address
Removing the address from a Business Unit generates the BusinessUnitAddressRemoved Message.
actionString | "removeAddress" |
addressIdString | ID of the address to be removed. Either |
addressKeyString | Key of the address to be removed. Either |
{"action" : "removeAddress","addressId" : "{{addressId}}"}
Remove Associate
Removing an Associate from a Business Unit generates a BusinessUnitAssociateRemoved Message.
actionString | "removeAssociate" |
customer | Associate to remove. |
{"action" : "removeAssociate","customer" : {"typeId" : "customer","id" : "some-customer-id"}}
Remove Billing Address Identifier
Removing a billing address from a Business Unit generates a BusinessUnitBillingAddressRemoved Message.
actionString | "removeBillingAddressId" |
addressIdString | ID of the billing address to be removed. Either |
addressKeyString | Key of the billing address to be removed. Either |
{"action" : "removeBillingAddressId","addressId" : "{{addressId}}"}
Remove Shipping Address Identifier
Removing a shipping address from a Business Unit generates a BusinessUnitShippingAddressRemoved Message.
actionString | "removeShippingAddressId" |
addressIdString | ID of the shipping address to be removed. Either |
addressKeyString | Key of the shipping address to be removed. Either |
{"action" : "removeShippingAddressId","addressId" : "{{addressId}}"}
Set Address CustomField
actionString | "setAddressCustomField" |
addressIdString | ID of the |
nameString | Name of the Custom Field. |
value | If |
{"action" : "setAddressCustomField","name" : "ExamplaryStringTypeField","value" : "TextString","addressId" : "{{address-id}}"}
Set CustomType in Address
actionString | "setAddressCustomType" |
type | Defines the Type that extends the |
fields | Sets the Custom Fields fields for the |
addressIdString | ID of the |
{"action" : "setAddressCustomType","type" : {"id" : "{{type-id}}","typeId" : "type"},"fields" : {"examplaryStringTypeField" : "TextString"},"addressId" : "{{address-id}}"}
Set ContactEmail
Setting the contact email on a Business Unit generates a BusinessUnitContactEmailSet Message.
actionString | "setContactEmail" |
contactEmailString | Email to set.
If |
{"action" : "setContactEmail","contactEmail" : "contact@example.com"}
Set CustomField
actionString | "setCustomField" |
nameString | Name of the Custom Field. |
value | If |
{"action" : "setCustomField","name" : "ExamplaryStringTypeField","value" : "TextString"}
Set CustomType
actionString | "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 | Sets the Custom Fields for the BusinessUnit. |
{"action" : "setCustomType","type" : {"id" : "{{type-id}}","typeId" : "type"},"fields" : {"examplaryStringTypeField" : "TextString"}}
Set Default Billing Address ID
Setting the default billing address on a Business Unit generates the BusinessUnitDefaultBillingAddressSet Message.
actionString | "setDefaultBillingAddress" |
addressIdString | ID of the address to add as a billing address. Either |
addressKeyString | Key of the address to add as a billing address. Either |
{"action" : "setDefaultBillingAddress","addressId" : "{{addressId}}"}
Set Default Shipping Address ID
Setting the default shipping address on a Business Unit generates a BusinessUnitDefaultShippingAddressSet Message.
actionString | "setDefaultShippingAddress" |
addressIdString | ID of the address to add as a shipping address. Either |
addressKeyString | Key of the address to add as a shipping address. Either |
{"action" : "setDefaultShippingAddress","addressId" : "{{addressId}}"}
Create Associate for a BusinessUnit by Key
The My Business Unit endpoint does not support assigning existing Customers to a Business Unit.
Use this endpoint to create a new Customer and associate it with the Business Unit.
The user must have the Admin role within the Business Unit to perform this request.
The new Customer is created with an empty set of roles.
manage_my_business_units:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
businessUnitKeyString |
|
curl -X POST 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"}}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"}}