Keeping identity separate from authorization is what lets one person act for more than one company, or hold different roles in different parts of the same company, without duplicating their login.
Customer versus Associate
The two resources answer two different questions.
- Customer: who is this person? It holds the authentication credentials (email, password, external identity) and the personal profile. A Customer exists independently of any company.
- Associate: what may this person do for this company? It links an existing Customer to a Business Unit and assigns one or more Associate Roles that define their permissions there.
{
"customer": {
"typeId": "customer",
"id": "f8a4e2c1-1111-2222-3333-444455556666"
},
"associateRoleAssignments": [
{
"associateRole": {
"typeId": "associate-role",
"key": "buyer"
},
"inheritance": "Disabled"
}
]
}
Because the Customer and the membership are separate, the same Customer can be added as an Associate to several Business Units. Each membership carries its own role assignments, so a person can be a buyer in one company and an administrator in another while authenticating with a single account.
The provisioning sequence
Adding a buyer to a company is a three-step sequence, and the order matters.
- Create the Associate Roles the organization needs. Roles must exist before they can be assigned, so this comes first. Role design is covered on the next page.
- Create the Customer for the person, or reuse an existing one if they already authenticate with commercetools.
- Add the Customer as an Associate to the Business Unit, assigning one or more roles.
addAssociate update action on the Business Unit. The customer is a reference to the existing Customer, and each entry in associateRoleAssignments references an Associate Role by its key.POST /{projectKey}/business-units/key=horizon-hotels HTTP/1.1
Content-Type: application/json
{
"version": 1,
"actions": [
{
"action": "addAssociate",
"associate": {
"customer": {
"typeId": "customer",
"id": "f8a4e2c1-1111-2222-3333-444455556666"
},
"associateRoleAssignments": [
{
"associateRole": {
"typeId": "associate-role",
"key": "buyer"
}
}
]
}
}
]
}
This sequencing is also enforced in the Merchant Center: the Business Unit creation flow requires Associate Roles to exist before you can add Associates. If you plan a Business Unit setup without first defining roles, you will be blocked at the associate-assignment step. This is the setup-sequencing dependency introduced in Module 1.
Worked example: Horizon Hotels procurement staff
Horizon Hotels is a flat Company (modeled in Module 1) with a small procurement team that reorders a known set of products. Map its people to resources as follows.
- Maria, the procurement lead, and Tom, a buyer on her team, each need a login. Model each as a Customer.
- Both act for Horizon Hotels, so each Customer is added as an Associate of the
horizon-hotelsBusiness Unit. - Maria also manages her team, so her Associate carries two role assignments: a buyer role and an administrator role. Tom's Associate carries only the buyer role.
Maria and Tom each authenticate as a single Customer, but their Associate memberships give them different permissions inside Horizon Hotels. No resource is duplicated: the roles are defined once and assigned to each Associate as needed.
Key takeaways
- The Customer is the authentication identity; the Associate is that Customer's membership of a Business Unit with assigned roles.
- An Associate references exactly one Customer, but one Customer can be an Associate of many Business Units.
- Provision in order: create Associate Roles, then the Customer, then add the Customer as an Associate with role assignments.
- The
addAssociateupdate action references the Customer and assigns roles by theirkey. - An Associate can hold up to five role assignments in a single Business Unit, and their permissions are the sum of those roles.