Get All Customer Roles
Retrieves all customer roles in the store. Use a role's label as the roleName when you create or update a customer.
HTTP Request
- URL:
/roles - Method:
GET - Headers:
accessToken: Required. Your API access token.
- Required scope:
READ_CUSTOMERorREAD_WRITE_CUSTOMER
cURL Example
curl --location '<BASE_URL>/roles' \
--header 'accessToken: <ACCESS_TOKEN>'
Response
- 200 OK: The list of roles was returned successfully.
- 400 Bad Request: The access token is missing or invalid, or the token does not have the required scope.
Sample JSON Response
{
"success": true,
"message": "Roles fetched successfully",
"data": [
{
"_id": "663a0aff4587085935a4fb94",
"id": "663a0aff4587085935a4fb94",
"name": "admin",
"label": "Admin",
"active": true,
"permissions": ["ADDRESS", "COMPANY", "CART"],
"defaultPermissions": ["ADDRESS", "COMPANY", "CART"],
"createdAt": "2024-05-07T11:13:02.066Z",
"updatedAt": "2024-05-07T11:13:02.066Z"
},
{
"_id": "663a0aff4587085935a4fb95",
"id": "663a0aff4587085935a4fb95",
"name": "buyer",
"label": "Buyer",
"active": true,
"permissions": ["CART"],
"defaultPermissions": ["CART"],
"createdAt": "2024-05-07T11:13:02.066Z",
"updatedAt": "2024-05-07T11:13:02.066Z"
}
]
}
Response Details
Role Data
| Field | Type | Description |
|---|---|---|
id | String | Unique identifier of the role. The same value is also returned as _id. |
name | String | Internal name of the role, for example admin, buyer or juniorBuyer. |
label | String | Display name of the role, for example Admin, Buyer or Junior Buyer. |
active | Boolean | Whether the role is active. Default is true. |
permissions | Array | Storefront permissions granted to the role. |
defaultPermissions | Array | Permissions the role had when it was created. |
createdAt | String | Date and time the role was created (ISO 8601). |
updatedAt | String | Date and time the role was last updated (ISO 8601). |
Notes
- All roles are returned in one response. This endpoint does not use pagination.