Business Units and Associates APIs overview

Ask about this Page
Copy for AI
View as Markdown

How to work with the APIs for Business Units and Associates.

This page describes rules that apply across the Business Units and Associates APIs. For what Business Units, Associates, Associate Roles, Permissions, and Approval Rules are and how they behave, see the Business Units and Associates overview.
Use the commercetools CLI to work with this API from your terminal or AI coding agent.

APIs

ResourcePurposeReference
Business UnitsCompanies and Divisions, their Associates, Stores, and addresses.Business Units
Associate RolesGroups of Permissions assigned to Associates.Associate Roles
Associate endpointsAccess B2B resources as an Associate, with Permission checks.Associate Carts, Associate Quotes, Associate Quote Requests, Associate Orders, Associate Business Units, Associate Shopping Lists
Approval RulesConditions and approver tiers for Order approval.Approval Rules
Approval FlowsThe approval process of one Order.Approval Flows
Business Unit SearchSearch Business Units for back-office use.Business Unit Search
Me endpointsAccess B2B resources and Business Units as the signed-in Associate, with Permission checks.My Business Units, My Carts, My Quotes, My Quote Requests, My Orders

Data model

The Business Units and Associates resources are stored as the entities in this section. The section describes the relationships and identifiers of each entity, using names that REST and GraphQL share. For the complete field list of an entity, follow the link to its type. For naming differences between the two APIs, see Differences between REST and GraphQL.

Entity relationships

The following diagram shows the main entities and how they relate. A Business Unit embeds its Associates, and each Associate embeds its role assignments. Approval Rules belong to a Business Unit, an Approval Flow embeds the rules that matched an Order, and B2B resources refer to the Business Unit. The table that follows lists every relationship, including the parent unit and the Business Unit of an Approval Flow.

The following table lists each relationship, including references that other resources hold to a Business Unit:

FromToCardinalityKindRule
Business UnitBusiness Unit, through parentUnit and topLevelUnitMany to oneReference by keyOnly a Division has a parentUnit. The topLevelUnit is of type Company. For the maximum number of levels and Divisions, see Limits.
Business UnitAssociate, through associatesOne to manyEmbeddedAssociates aren't a standalone resource. The platform fills inheritedAssociates, as described in Eventual consistency. For the maximum number of Associates, see Limits.
AssociateCustomer, through customerMany to oneReferenceOne Customer can be an Associate in several Business Units.
AssociateAssociate Role AssignmentOne to manyEmbeddedFor the maximum number per Associate, see Limits.
Associate Role AssignmentAssociate RoleMany to oneReference by keyThe inheritance property decides whether child Business Units inherit the assignment. See Inheritance.
Business UnitStore, through storesMany to manyReference by keyPresent only when storeMode is Explicit. With FromParent, the Stores appear in inheritedStores.
Business UnitCustomer Group AssignmentOne to manyEmbeddedFor the maximum number per Business Unit, see Limits.
Approval RuleBusiness UnitMany to oneReference by keyA rule belongs to one Business Unit.
Approval RuleAssociate Role, through requesters and approversMany to manyReference by keyThe requesters are the roles whose Orders the rule applies to. The approvers are the roles that approve. See Approval Rule.
Approval FlowBusiness UnitMany to oneReference by keyA flow belongs to one Business Unit.
Approval FlowOrder, through orderOne to oneReferenceAn Approval Flow tracks the approval of one Order.
Approval FlowApproval Rule, through rulesMany to manyEmbeddedThe rules that matched the Order. A flow embeds at least one rule, and a rule can appear in many flows.
B2B resourceBusiness Unit, through businessUnitMany to oneReference by keyA B2B resource has its businessUnit field set. See B2B resources.

Keys and identifiers

  • Business Unit and Associate Role: have an id and a mandatory key. The key is unique and immutable.
  • Approval Rule: has an id and an optional key, which is unique within its Business Unit.
  • Approval Flow: has an id only.
  • Associate: has no id of its own. The endpoints address an Associate by the id of its Customer, in the associateId URL parameter.

Working with the APIs

Associate Roles and Permissions

Associates can be assigned specific roles through an AssociateRoleAssignment, which grants an Associate Role to an Associate within a Business Unit.
Sellers can make roles assignable by Buyers using the buyerAssignable property of an Associate Role.

Permission naming convention

The naming convention for Permissions represents the action allowed for a given resource type. Most Permission names consist of the action name, either the My or Others keyword and the resource type (for example, UpdateMyOrders, ViewOthersCarts). Permissions with the My keyword grant access to an Associate's own resources, while Others Permissions provide access to resources belonging to other Associates.

Distinct 'My' and 'Others' Permissions

Others Permissions don't imply My Permissions. This behavior allows for maximum flexibility in modeling complex B2B use cases. For instance, granting an Associate the CreateMyCarts Permission alongside ViewOthersCarts and CreateOrdersFromOthersCarts Permissions enables the setup described in Buyers create Carts and colleagues place the Orders.

B2B resources

A B2B resource has its businessUnit field set. You can access B2B resources through the general endpoints, the me endpoints, or the associate endpoints, and the endpoint type decides whether and how Permissions are validated.

Through the general endpoints

When accessing resources using the general endpoint, the API has no knowledge of the Associate behind the API call. Therefore, no Associate Role Permissions are validated. As such, the general endpoints are intended for a Seller that wants to manage access and permissions without Associate Role enforcement.

Example use case: back office operations, customer support.

Through the me endpoint

When using the me endpoints, the API can derive which Associate is behind a given API call using the password flow token. This allows the API to check whether the Associate has the right level of Permissions to perform actions on a given resource. However, the me endpoint can only grant access to the Associate's own resources, and not to resources that belong to other Associates.
Example use case: mobile app for Buyers to make purchases.

Through the associate endpoint

The associate endpoints require an Associate to be specified as a URL parameter along with a Business Unit. This Business Unit is what the Associate's Permissions are checked against. These endpoints are designed specifically for Sellers that want to provide controlled access for their Buyers using the Permissions.
The endpoints do verify the Permissions according to the URL parameters, but they don't validate the URL parameters against the scopes. Because of this, these endpoints should only be called from a middleware that's trusted.

Example use case: B2B storefront using trusted middleware.

Permission evaluation

Permission evaluations and requirements differ based on the endpoint type. The following table provides an overview of the types of Permissions required depending on which method is used to access a resource.

Endpoint typePermission evaluationAdditional requirements
General endpointsNoneIf customerId and businessUnit are both present on the resource, then the Customer must be an Associate of the Business Unit.
me endpoints for B2B resources (for example, My Carts)My PermissionsIf customerId and businessUnit are both present on the resource, then the Customer must be an Associate of the Business Unit.
me endpoints for Business Units (My Business Units)Business Unit PermissionsThe Customer must be an Associate of the Business Unit.
associate endpoints for B2B resourcesMy, Others PermissionsThe Associate must be a member of the Business Unit.
associate endpoints for Business UnitsBusiness Unit PermissionsThe Associate must be a member of the Business Unit.

On the me endpoints

The me endpoints validate that the acting Associate has sufficient Permissions on a given B2B resources. In addition, the Associate must be a Customer on the resource and be an Associate of the referenced Business Unit.
The me endpoints do not validate View Permissions. Therefore, an Associate can view all resources available on the me endpoints, regardless of their Permissions.

Removing an Associate from a Business Unit does not revoke their access to the Carts, Orders, Quotes, and Quote Requests associated with it. The Associate must also be explicitly removed from the entity to fully restrict their access.

My Business Unit

When interacting with Business Units using the My Business Unit endpoints, the API performs validations on certain actions to ensure that the Associate has the correct Business Unit Permissions.
PermissionRequired for
AddChildUnitsCreating and assigning a new child unit to a parent unit.
UpdateAssociateschangeAssociate, removeAssociate update actions, and creating an Associate for a BusinessUnit.
UpdateParentUnitchangeParentUnit update action.
UpdateBusinessUnitDetailsUpdate actions not related to Associate management, or hierarchical changes (such as changeParentUnit).

My Carts

For B2B Carts, the My Carts endpoints perform validations to ensure that the Associate has the correct CartPermissions.
PermissionRequired for
CreateMyCartsCreating a Cart.
UpdateMyCartsUpdating a Cart.
DeleteMyCartsDeleting a Cart.
Additionally, the Customer on the Cart must be an Associate of the referenced Business Unit.

My Quotes

For B2B Quotes, the My Quotes endpoints perform validations to ensure that the Associate has the correct QuotePermissions.
PermissionRequired for
AcceptMyQuotesAccepting a Quote.
DeclineMyQuotesDeclining a Quote.
RenegotiateMyQuotesRenegotiating a Quote.

My Quote Requests

For B2B Quote Requests, the My Quote Requests endpoints perform validations to ensure that the Associate has the correct QuoteRequestPermissions.
PermissionRequired for
CreateMyQuoteRequestsFromMyCartsCreating a Quote Request.
UpdateMyQuoteRequestsUpdating a Quote Request.

My Orders

For B2B Orders, the My Orders endpoints perform validations to ensure that the Associate has the correct OrderPermissions.
PermissionRequired for
CreateMyOrdersFromMyCartsCreating an Order from a Cart and Creating an Order in Store from a Cart.
CreateMyOrdersFromMyQuotesCreating an Order from a Quote.

On the associate endpoints

The associate endpoints validate that the acting Associate has sufficient Permissions on a given resource. In addition, the Associate must have access to the referenced Business Unit. In contrast to the me endpoints, the associate endpoints can also provide access to resources that do not belong to the Associate directly. For example, the ViewOthersCarts Permission allows an Associate to view B2B Carts where the Customer on the Cart is another Associate.

Associate Carts

For B2B Carts, the Associate Carts endpoints perform validations to ensure that the Associate has the correct Cart Permissions.
PermissionRequired for
ViewMyCarts or ViewOthersCartsGetting a Cart.
CreateMyCarts or CreateOthersCartsCreating a Cart.
UpdateMyCarts or UpdateOthersCartsUpdating a Cart.
DeleteMyCarts or DeleteOthersCartsDeleting a Cart.

Associate Quotes

For B2B Quotes, the Associate Quotes endpoints perform validations to ensure that the Associate has the correct Quote Permissions.
PermissionRequired for
ViewMyQuotes or ViewOthersQuotesGetting a Quote.
AcceptMyQuotes or AcceptOthersQuotesAccepting a Quote.
DeclineMyQuotes or DeclineOthersQuotesDeclining a Quote.
RenegotiateMyQuotes or RenegotiateOthersQuotesRenegotiate a Quote.
ReassignMyQuotes or ReassignOthersQuotesReassigning a Quote.

Associate Quote Requests

For B2B Quote Requests, the Associate Quote Requests endpoints perform validations to ensure that the Associate has the correct Quote Request Permissions.
PermissionRequired for
ViewMyQuoteRequests or ViewOthersQuoteRequestsGetting a Quote Request.
CreateMyQuoteRequestsFromMyCarts or CreateQuoteRequestsFromOthersCartsCreating a Quote Request.
UpdateMyQuoteRequests or UpdateOthersQuoteRequestsUpdating a Quote Request.

Associate Orders

For B2B Orders, the Associate Orders endpoints perform validations to ensure that the Associate has the correct Order Permissions.
PermissionRequired for
ViewMyOrders or ViewOthersOrdersGetting an Order.
CreateMyOrders or CreateOthersOrdersCreating an Order.
UpdateMyOrders or UpdateOthersOrdersUpdating an Order.

Associate Business Units

The Associate Business Unit endpoints perform validations to ensure that the Associate has the correct Business Unit Permissions.
PermissionRequired for
AddChildUnitsCreating and assigning a new child unit to a parent unit.
UpdateAssociatesaddAssociate, setAssociates, changeAssociate, and removeAssociate update actions.
UpdateParentUnitchangeParentUnit update action.
UpdateBusinessUnitDetailsUpdate actions not related to Associate management, or hierarchical changes (such as changeParentUnit).

Associate Shopping Lists

For B2B Shopping Lists, the Associate Shopping Lists endpoints perform validations to ensure that the Associate has the correct Shopping List Permissions.
PermissionRequired for
ViewMyShoppingLists or ViewOthersShoppingListsGetting a Shopping List.
CreateMyShoppingLists or CreateOthersShoppingListsCreating a Shopping List.
UpdateMyShoppingLists or UpdateOthersShoppingListsUpdating a Shopping List.
DeleteMyShoppingLists or DeleteOthersShoppingListsDeleting a Shopping List.

Inheritance

The inheritance behavior is determined by the inheritance property of individual AssociateRoleAssignments together with the AssociateMode of a Business Unit.

Conditions for inheritance

When the AssociateMode of a Business Unit is set to Explicit, the Business Unit is not allowed to inherit any Associates. In this case, only Associates defined directly on the Business Unit can act on its behalf. With the ExplicitAndFromParent AssociateMode, the Business Unit can have both directly assigned Associates and inherited ones from a parent unit.

For a Business Unit to inherit Associates from a parent unit, the following two conditions must be met:

  • The AssociateMode of the Business Unit must be set to ExplicitAndFromParent, allowing the Business Unit to inherit Associates.
  • A parent unit of the Business Unit must have at least one Associate with an inheritable role, meaning that the inheritance property of the AssociateRoleAssignment is set to Enabled.
The following diagram illustrates how Business Units with ExplicitAndFromParent AssociateMode inherit Associates from parents, whilst a Business Unit with Explicit AssociateMode does not.

Prevent inheritance

By setting the AssociateMode of a Business Unit to Explicit, the inheritance mechanism will be disabled for all Associates of that unit. To prevent the inheritance of a single Associate, disable the inheritance property for all assigned roles of that Associate. This ensures that the Associate is not inherited by any child Business Units. If an Associate is both inherited and explicitly defined in the same Associate Role, the explicitly defined AssociateRoleAssignment determines inheritance.

Stores and Approval Rules

A Division can also inherit Stores and Approval Rules from a parent. The StoreMode, AssociateMode, and ApprovalRuleMode of a Business Unit work the same way: a Company has no parent, so its modes are explicit, and a Division inherits by default.

Approval Rule

The conditions of an Approval Rule are written as an Order Predicate in the predicate field. For worked examples of approver hierarchies, see Approval Rules. For the maximum number of tiers in an approver hierarchy, see Limits.

Approver hierarchy

An Approval Rule is made of at least one tier in the ApproverHierarchy. Each tier must be composed of at least one ApproverConjunction that contains at least one ApproverDisjunction holding the RuleApprovers. An ApproverConjunction is a condition with the logical operator AND: all of its ApproverDisjunctions must be met. An ApproverDisjunction is a condition with the logical operator OR: any one of its RuleApprovers can approve. For what the AND and OR conditions mean in the approval process, see Business Units and Associates overview.

Buyer portal

The Approval Rules and Approval Flows APIs are designed to be called from a Buyer portal.
A Buyer portal acts on behalf of an Associate. To have the platform check the Associate's Permissions on each call, use the associate endpoints from trusted middleware.

Business Unit status

Business Units are Active by default. An Inactive Business Unit can only be edited using the general endpoints. For the default status of Business Units that Buyers create, see My Business Units. For the effect of the status on inheritance and on new Carts, Orders, Quote Requests, and Quotes, see Business Unit status.

Company-specific products, prices, and discounts B2B B2X

When placing an Order, the Cart's customerId has to reference an Associate in the Business Unit that represents the customer. To ensure that you apply the correct pricing, reference the customer-specific Channel in the distributionChannel of the Cart's Line Item Drafts. Without specifying the Channel, the base price is selected instead of the customer-specific price.
To use Standalone Prices, set the ProductPriceMode to Standalone and create Prices for every Channel.
Creating a Store and Channel per price band is not recommended for checkout flows that use the My Carts and My Orders APIs. It allows the Customer to select the Channel and, therefore, the pricing option for their Orders. For the alternative, see Volume-based price bands. External prices and taxes are not supported with those APIs.

Differences between REST and GraphQL

The entities and field names are the same in both APIs, with the following exceptions:

  • Where REST returns a key reference, GraphQL returns the reference in a field with the Ref suffix and the expanded object in the field without it. For example, GraphQL has storesRef and stores. This applies to these fields:
    • Business Unit: stores, parentUnit, and topLevelUnit.
    • Associate: customer.
    • AssociateRoleAssignment, RuleApprover, and RuleRequester: associateRole.
    • Inherited role assignment: source.
    • Approval Flow: order and businessUnit.
    • Approval Rule: businessUnit.
  • GraphQL has one BusinessUnit type for Companies and Divisions. The unitType field tells them apart, while REST has the Company and Division types.
  • GraphQL returns inheritedStores as InheritedStore objects with a storeRef and the expanded store.
  • The ancestors, shippingAddresses, billingAddresses, defaultShippingAddress, and defaultBillingAddress fields exist in GraphQL only. They return the ancestors of a Business Unit and its expanded addresses.
  • The deprecated roles field of an Associate exists in REST only.
  • The storeMode field of a Business Unit and the status field of an Approval Flow are strings in GraphQL. In REST, they are the BusinessUnitStoreMode and ApprovalFlowStatus enums. The inheritance field of an AssociateRoleAssignment uses the AssociateInheritanceMode enum, which is AssociateRoleInheritanceMode in REST.
  • GraphQL has no Business Unit Search query. To change the Business Unit Search status in GraphQL, use the changeBusinessUnitSearchStatus Project update action.
For the GraphQL types, see the Business Units, Associate Roles, Approval Rules, Approval Flows, and As Associate GraphQL references.

Eventual consistency

Eventual consistency of inherited Associates

The inheritedAssociates array of a Business Unit contains the Associates that are inherited. In cases where inheritance applies, this property is automatically populated by a background task. It is updated each time an Associate in a parent Business Unit is added, updated, or removed. However, since this process is subject to eventual consistency, changes in inherited roles might have a delayed effect on role evaluations.

Messages and events

Business Units and Associate Roles send Messages when they are created or deleted, and when their data changes, for example their Associates, Stores, status, or Permissions. Approval Rules send Messages when they are created and when their data changes. Approval Flows send Messages when they are created, approved, rejected, and completed. For the full lists, see Business Unit and Associate Role Messages and Approval Rule and Approval Flow Messages. Business Unit Search doesn't have its own Messages.

Limits

Business Units can be organized hierarchically up to a maximum of 5 levels, with the top level being a Business Unit of type Company. Each top-level Business Unit can have a maximum of 4 000 Divisions, including all direct and indirect children. These are soft limits that can be increased per Project after a performance impact review. See Limit increase guidance.
Each Business Unit can have up to 2 000 Associates, and each Associate can have up to 5 AssociateRoleAssignments.
BETA Each Business Unit can have up to 500 Customer Groups.
Business Unit Search indexes up to 10 000 addresses and up to 50 Custom Fields per Business Unit.

With up to five levels per Approval Rule, an Order can pass through a maximum of five sequential approval stages. Each level corresponds to an approval stage, starting from the initial stage at the first level to the final approval at the fifth level.

For the full list of limits, see Business Units and Business Unit Search on the Limits page.