---
schema_version: "1"
id: 855d662da7c5e637b4a2aa82748492c8db95d9e8dcda05f98179e2139d5f42b0
title: Roles
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/commerce-cloud/commerce-api/references/generated-api-specs/roles.md
canonical_url: https://developer.salesforce.com/docs/commerce/commerce-api/references/roles
source_site: developer.salesforce.com
content_type: documentation
content_hash: 0ee621cefd4763319a54afa3c3437d8d43fe613bd18ceb254210d513ebc04df9
products:
  - B2C Commerce API
  - Salesforce APIs
---
Roles

# Roles

[Download API specification](https://developer.salesforce.com/static/commercecloud/commerce-api/roles/roles-oas-v1-public.yaml)

## API Overview

The Roles API provides endpoints for managing access roles and their associated users and permissions within Salesforce Commerce Cloud.

### Overview

This API allows administrators to create, retrieve, update, and delete access roles. It also supports managing user assignments to roles, retrieving and setting role permissions, and searching for users within a specific role.

### Key Features

*   **Role Management**: Create, retrieve, and delete access roles
*   **Permission Management**: Get and set permissions for access roles
*   **User Assignment**: Assign and unassign users to/from roles
*   **User Search**: Search for users assigned to a specific role using complex queries

### Searchable Attributes (User Search)

The following attributes can be used in user search queries within a role:

*   `login`: The user login identifier (String)
*   `email`: The user email address (String)
*   `firstName`: The user first name (String)
*   `lastName`: The user last name (String)
*   `externalId`: The external identifier (String)
*   `lastLoginDate`: The date of last login (Date)

### Sortable Attributes (User Search)

Search results can be sorted by:

*   `login`: Sort by user login
*   `email`: Sort by email address
*   `firstName`: Sort by first name
*   `lastName`: Sort by last name
*   `externalId`: Sort by external identifier
*   `lastLoginDate`: Sort by last login date

### Use Cases

*   **Access Control**: Define and manage role-based access control for Business Manager
*   **User Management**: Assign users to appropriate roles for their job functions
*   **Permission Auditing**: Review and update role permissions
*   **Compliance**: Ensure proper access controls are in place

### Authentication

This API requires OAuth 2.0 authentication with the appropriate scopes:

*   `sfcc.roles` - Read access to role resources
*   `sfcc.roles.rw` - Read and write access to role resources

### Best Practices

1.  Use the Administrator role carefully as permission changes are limited for system roles
2.  Review role permissions regularly for security compliance
3.  Use the user search endpoint for efficient user-role lookups
4.  Avoid deleting roles that have active user assignments

**Version:** 1.0.0

## Servers

*   `https://{shortCode}.api.commercecloud.salesforce.com/merchant/roles/v1`
    *   `shortCode (default 123456gf)`

## Security

*   `AmOAuth2` (oauth2) OAuth 2.0 security scheme for Admin API access using Account Manager. Requires appropriate scopes for role management operations.
    *   OAuth flow clientCredentials (tokenUrl: https://account.demandware.com/dw/oauth2/access\_token)
    *   Scope sfcc.roles: Read access to role resources
    *   Scope sfcc.roles.rw: Read and write access to role resources

## Operations

### GET Get Roles

`GET /organizations/{organizationId}/roles`

Operation ID: `getRoles`. Security: AmOAuth2 (sfcc.roles, sfcc.roles.rw).

Retrieves all access roles with no filtering.

#### Parameters

*   `organizationId` (path, OrganizationId, required) An identifier for the organization the request is being made by
    
    _Example_
    
    ```
    f_ecom_zzxy_prd
    ```
    
*   `expand` (query, array of string, style: form, explode: false) The list of resource types to include in the response.  
    Items: Allowed values: `users`, `permissions`. Example: `users`.
*   `select` (query, Select)
    
    _Example: select_
    
    ```
    (**)
    ```
    
*   `limit` (query, integer (int32)) Number of records to retrieve per request. Must be between 1 (minimum) and 200 (maximum). Defaults to 25.  
    Default: `25`. Minimum: 1. Maximum: 200.
*   `offset` (query, integer (int32)) Used to retrieve the results based on a particular resource offset.  
    Default: `0`. Minimum: 0.

#### Responses

*   **200** Returns the collection of access roles
    
    Media type: `application/json`. Schema: `RoleSearch`.
    
    _Example: RoleSearchResult_ Role search result
    
    Example of a role search response. By default, only IDs are returned.
    
    ```
    {
      "limit": 3,
      "offset": 0,
      "total": 3,
      "data": [
        {
          "id": "Administrator"
        },
        {
          "id": "CustomManager"
        },
        {
          "id": "ContentEditor"
        }
      ]
    }
    ```
    
    _Example: RoleSearchExpandUsersResult_ Role search with expand users
    
    Example of a role search response with `expand=users` and `select=(**)`. All role fields are returned and each role includes its full users.
    
    ```
    {
      "limit": 3,
      "offset": 0,
      "total": 3,
      "data": [
        {
          "id": "Administrator",
          "description": "Full administrative access to Business Manager",
          "userCount": 2,
          "userManager": true,
          "users": [
            {
              "login": "admin-user",
              "email": "admin@example.com",
              "firstName": "John",
              "lastName": "Doe",
              "externalId": "ext-12345",
              "disabled": false,
              "locked": false,
              "lastLoginDate": "2024-10-14",
              "passwordExpirationDate": "2025-01-14T00:00:00.000Z",
              "passwordModificationDate": "2024-10-14T10:00:00.000Z",
              "preferredDataLocale": "en-US",
              "preferredUiLocale": "en-US",
              "roles": [
                "Administrator"
              ]
            }
          ]
        },
        {
          "id": "CustomManager",
          "description": "Custom manager role for site operations",
          "userCount": 5,
          "userManager": false,
          "users": [
            {
              "login": "manager-user",
              "email": "manager@example.com",
              "firstName": "Alice",
              "lastName": "Brown",
              "externalId": "ext-11111",
              "disabled": false,
              "locked": false,
              "lastLoginDate": "2024-12-01",
              "passwordExpirationDate": "2025-03-01T00:00:00.000Z",
              "passwordModificationDate": "2024-12-01T09:00:00.000Z",
              "preferredDataLocale": "en-US",
              "preferredUiLocale": "en-US",
              "roles": [
                "CustomManager"
              ]
            }
          ]
        },
        {
          "id": "ContentEditor",
          "description": "Content editing access",
          "userCount": 8,
          "userManager": false,
          "users": [
            {
              "login": "editor-user",
              "email": "editor@example.com",
              "firstName": "Jane",
              "lastName": "Smith",
              "externalId": "ext-67890",
              "disabled": false,
              "locked": false,
              "lastLoginDate": "2024-11-20",
              "passwordExpirationDate": "2025-02-20T00:00:00.000Z",
              "passwordModificationDate": "2024-11-20T08:30:00.000Z",
              "preferredDataLocale": "en-US",
              "preferredUiLocale": "en-US",
              "roles": [
                "ContentEditor"
              ]
            }
          ]
        }
      ]
    }
    ```
    
    _Example: RoleSearchExpandPermissionsResult_ Role search with expand permissions
    
    Example of a role search response with `expand=permissions` and `select=(**)`. All role fields are returned and each role includes its full permissions.
    
    ```
    {
      "limit": 3,
      "offset": 0,
      "total": 3,
      "data": [
        {
          "id": "Administrator",
          "description": "Full administrative access to Business Manager",
          "userCount": 2,
          "userManager": true,
          "permissions": {
            "module": {
              "organization": [
                {
                  "name": "jobschedules",
                  "application": "bm",
                  "system": true,
                  "type": "module",
                  "value": "ACCESS"
                },
                {
                  "name": "customreports",
                  "application": "bm",
                  "system": false,
                  "type": "module",
                  "value": "ACCESS"
                }
              ],
              "site": [
                {
                  "name": "library_content",
                  "application": "bm",
                  "system": true,
                  "type": "module",
                  "values": {
                    "SiteGenesis": "ACCESS",
                    "RefArch": "READONLY"
                  }
                }
              ]
            },
            "functional": {
              "organization": [
                {
                  "name": "Delete_All_Catalogs",
                  "type": "functional",
                  "value": "ACCESS"
                }
              ],
              "site": [
                {
                  "name": "ViewOrders",
                  "type": "functional",
                  "values": {
                    "SiteGenesis": "ACCESS"
                  }
                }
              ]
            },
            "locale": {
              "unscoped": [
                {
                  "localeId": "default",
                  "type": "locale",
                  "value": "ACCESS"
                },
                {
                  "localeId": "en",
                  "type": "locale",
                  "value": "ACCESS"
                }
              ]
            },
            "webdav": {
              "unscoped": [
                {
                  "folder": "/catalogs/apparel-catalog",
                  "type": "webdav",
                  "value": "ACCESS"
                }
              ]
            }
          }
        },
        {
          "id": "CustomManager",
          "description": "Custom manager role for site operations",
          "userCount": 5,
          "userManager": false,
          "permissions": {
            "module": {
              "site": [
                {
                  "name": "library_content",
                  "application": "bm",
                  "system": true,
                  "type": "module",
                  "values": {
                    "SiteGenesis": "ACCESS"
                  }
                }
              ]
            },
            "locale": {
              "unscoped": [
                {
                  "localeId": "default",
                  "type": "locale",
                  "value": "ACCESS"
                }
              ]
            },
            "webdav": {
              "unscoped": []
            }
          }
        },
        {
          "id": "ContentEditor",
          "description": "Content editing access",
          "userCount": 8,
          "userManager": false,
          "permissions": {
            "module": {
              "site": [
                {
                  "name": "library_content",
                  "application": "bm",
                  "system": true,
                  "type": "module",
                  "values": {
                    "SiteGenesis": "READONLY"
                  }
                }
              ]
            },
            "locale": {
              "unscoped": [
                {
                  "localeId": "default",
                  "type": "locale",
                  "value": "ACCESS"
                },
                {
                  "localeId": "en",
                  "type": "locale",
                  "value": "READONLY"
                }
              ]
            },
            "webdav": {
              "unscoped": []
            }
          }
        }
      ]
    }
    ```
    

### GET Get Role

`GET /organizations/{organizationId}/roles/{roleId}`

Operation ID: `getRole`. Security: AmOAuth2 (sfcc.roles, sfcc.roles.rw).

Retrieves a single access role by its identifier.

#### Parameters

*   `organizationId` (path, OrganizationId, required) An identifier for the organization the request is being made by
    
    _Example_
    
    ```
    f_ecom_zzxy_prd
    ```
    
*   `roleId` (path, string, required) The identifier of the access role.  
    Minimum length: 1. Maximum length: 256. Example: `Administrator`.
*   `expand` (query, array of string, style: form, explode: false) The list of resource types to include in the response.  
    Items: Allowed values: `users`, `permissions`. Example: `users`.

#### Responses

*   **200** Returns the access role details
    
    Media type: `application/json`. Schema: `Role`.
    
    _Example: RoleDetailsResult_ Single role
    
    Example of a single role response. By default, only the ID is returned.
    
    ```
    {
      "id": "Administrator"
    }
    ```
    
    _Example: RoleDetailsExpandUsersResult_ Single role with expand users
    
    Example of a single role response with `expand=users` and `select=(**)`. All role fields are returned including the assigned users.
    
    ```
    {
      "id": "Administrator",
      "description": "Full administrative access to Business Manager",
      "userCount": 2,
      "userManager": true,
      "users": [
        {
          "login": "admin-user",
          "email": "admin@example.com",
          "firstName": "John",
          "lastName": "Doe",
          "externalId": "ext-12345",
          "disabled": false,
          "locked": false,
          "lastLoginDate": "2024-10-14",
          "passwordExpirationDate": "2025-01-14T00:00:00.000Z",
          "passwordModificationDate": "2024-10-14T10:00:00.000Z",
          "preferredDataLocale": "en-US",
          "preferredUiLocale": "en-US",
          "roles": [
            "Administrator"
          ]
        }
      ]
    }
    ```
    
    _Example: RoleDetailsExpandPermissionsResult_ Single role with expand permissions
    
    Example of a single role response with `expand=permissions` and `select=(**)`. All role fields are returned including the full permissions.
    
    ```
    {
      "id": "Administrator",
      "description": "Full administrative access to Business Manager",
      "userCount": 2,
      "userManager": true,
      "permissions": {
        "module": {
          "organization": [
            {
              "name": "jobschedules",
              "application": "bm",
              "system": true,
              "type": "module",
              "value": "ACCESS"
            },
            {
              "name": "customreports",
              "application": "bm",
              "system": false,
              "type": "module",
              "value": "ACCESS"
            }
          ],
          "site": [
            {
              "name": "library_content",
              "application": "bm",
              "system": true,
              "type": "module",
              "values": {
                "SiteGenesis": "ACCESS",
                "RefArch": "READONLY"
              }
            }
          ]
        },
        "functional": {
          "organization": [
            {
              "name": "Delete_All_Catalogs",
              "type": "functional",
              "value": "ACCESS"
            }
          ],
          "site": [
            {
              "name": "ViewOrders",
              "type": "functional",
              "values": {
                "SiteGenesis": "ACCESS"
              }
            }
          ]
        },
        "locale": {
          "unscoped": [
            {
              "localeId": "default",
              "type": "locale",
              "value": "ACCESS"
            },
            {
              "localeId": "en",
              "type": "locale",
              "value": "ACCESS"
            },
            {
              "localeId": "de",
              "type": "locale",
              "value": "READONLY"
            }
          ]
        },
        "webdav": {
          "unscoped": [
            {
              "folder": "/catalogs/apparel-catalog",
              "type": "webdav",
              "value": "ACCESS"
            },
            {
              "folder": "/impex",
              "type": "webdav",
              "value": "ACCESS"
            }
          ]
        }
      }
    }
    ```
    
*   **404** Role not found
    
    Media type: `application/problem+json`. Schema: `ErrorResponse`.
    
    _Example: RoleNotFound_ Role not found
    
    Example of an error when the specified role does not exist
    
    ```
    {
      "title": "Role Not Found",
      "type": "https://api.commercecloud.salesforce.com/documentation/error/v1/errors/role-not-found",
      "detail": "No access role with ID 'nonexistent-role' could be found."
    }
    ```
    

### PUT Create Role

`PUT /organizations/{organizationId}/roles/{roleId}`

Operation ID: `createRole`. Security: AmOAuth2 (sfcc.roles.rw).

Creates a new access role with the specified identifier.

#### Parameters

*   `organizationId` (path, OrganizationId, required) An identifier for the organization the request is being made by
    
    _Example_
    
    ```
    f_ecom_zzxy_prd
    ```
    
*   `roleId` (path, string, required) The identifier of the access role.  
    Minimum length: 1. Maximum length: 256. Example: `Administrator`.

#### Request body (required)

The access role to create

Media type: `application/json`. Schema: `Role`.

_Example: CreateRole_ Create an access role

Example of creating a new access role

```
{
  "id": "CustomManager",
  "description": "Custom manager role for site operations"
}
```

#### Responses

*   **200** The access role was successfully updated
    
    Media type: `application/json`. Schema: `Role`.
    
    _Example: RoleCreated_ Newly created role
    
    Example of a successfully created access role
    
    ```
    {
      "id": "CustomManager",
      "description": "Custom manager role for site operations",
      "userCount": 0,
      "userManager": false
    }
    ```
    
*   **201** The access role was successfully created
    
    Media type: `application/json`. Schema: `Role`.
    
    _Example: RoleCreated_ Newly created role
    
    Example of a successfully created access role
    
    ```
    {
      "id": "CustomManager",
      "description": "Custom manager role for site operations",
      "userCount": 0,
      "userManager": false
    }
    ```
    
*   **400** Bad Request - Invalid role request
    
    Media type: `application/problem+json`. Schema: `ErrorResponse`.
    
    _Example: IdConflict_ ID conflict
    
    Example of an error when the ID in the request body does not match the ID in the URL
    
    ```
    {
      "title": "Id Conflict",
      "type": "https://api.commercecloud.salesforce.com/documentation/error/v1/errors/id-conflict",
      "detail": "The ID in the request body ('DifferentRoleId') doesn't match the ID in the URL ('ScapiTestRole')."
    }
    ```
    
    _Example: RoleAlreadyExists_ Role already exists
    
    Example of an error when trying to create a role that already exists
    
    ```
    {
      "title": "Role Already Exists",
      "type": "https://api.commercecloud.salesforce.com/documentation/error/v1/errors/role-already-exists",
      "detail": "An access role with ID 'ScapiTestRole' already exists. Please delete the existing role before creating a role with the same ID."
    }
    ```
    
    _Example: RoleOperationNotAllowed_ Role operation not allowed
    
    Example of an error when the operation is not allowed for the given role
    
    ```
    {
      "title": "Role Operation Not Allowed",
      "type": "https://api.commercecloud.salesforce.com/documentation/error/v1/errors/role-operation-not-allowed",
      "detail": "The operation isn't allowed for the role with ID 'Administrator'."
    }
    ```
    

### DELETE Delete Role

`DELETE /organizations/{organizationId}/roles/{roleId}`

Operation ID: `deleteRole`. Security: AmOAuth2 (sfcc.roles.rw).

Deletes a single access role.

#### Parameters

*   `organizationId` (path, OrganizationId, required) An identifier for the organization the request is being made by
    
    _Example_
    
    ```
    f_ecom_zzxy_prd
    ```
    
*   `roleId` (path, string, required) The identifier of the access role.  
    Minimum length: 1. Maximum length: 256. Example: `Administrator`.

#### Responses

*   **204** The access role was successfully deleted
*   **404** Role not found
    
    Media type: `application/problem+json`. Schema: `ErrorResponse`.
    
    _Example RoleNotFound: same as GET /organizations/{organizationId}/roles/{roleId} 404 response._ Role not found
    
    Example of an error when the specified role does not exist
    
    _Example: RoleNotFound_ Role not found
    
    Example of an error when the specified role does not exist
    

### GET Get Role Permissions

`GET /organizations/{organizationId}/roles/{roleId}/permissions`

Operation ID: `getRolePermissions`. Security: AmOAuth2 (sfcc.roles, sfcc.roles.rw).

Retrieves the list of permissions assigned to the given role.

#### Parameters

*   `organizationId` (path, OrganizationId, required) An identifier for the organization the request is being made by
    
    _Example_
    
    ```
    f_ecom_zzxy_prd
    ```
    
*   `roleId` (path, string, required) The identifier of the access role.  
    Minimum length: 1. Maximum length: 256. Example: `Administrator`.

#### Responses

*   **200** Returns the role permissions
    
    Media type: `application/json`. Schema: `RolePermissions`.
    
    _Example: RolePermissionsSuccess_ Successful role permissions retrieval
    
    Example of a successful retrieval of role permissions
    
    ```
    {
      "module": {
        "organization": [
          {
            "name": "jobschedules",
            "application": "bm",
            "system": true,
            "type": "module",
            "value": "ACCESS"
          },
          {
            "name": "customreports",
            "application": "bm",
            "system": false,
            "type": "module",
            "value": "ACCESS"
          }
        ],
        "site": [
          {
            "name": "library_content",
            "application": "bm",
            "system": true,
            "type": "module",
            "values": {
              "SiteGenesis": "ACCESS",
              "RefArch": "READONLY"
            }
          }
        ]
      },
      "functional": {
        "organization": [
          {
            "name": "Delete_All_Catalogs",
            "type": "functional",
            "value": "ACCESS"
          }
        ],
        "site": [
          {
            "name": "ViewOrders",
            "type": "functional",
            "values": {
              "SiteGenesis": "ACCESS"
            }
          }
        ]
      },
      "locale": {
        "unscoped": [
          {
            "localeId": "default",
            "type": "locale",
            "value": "ACCESS"
          },
          {
            "localeId": "en",
            "type": "locale",
            "value": "ACCESS"
          },
          {
            "localeId": "de",
            "type": "locale",
            "value": "READONLY"
          }
        ]
      },
      "webdav": {
        "unscoped": [
          {
            "folder": "/catalogs/apparel-catalog",
            "type": "webdav",
            "value": "ACCESS"
          },
          {
            "folder": "/impex",
            "type": "webdav",
            "value": "ACCESS"
          }
        ]
      }
    }
    ```
    
*   **404** Role not found
    
    Media type: `application/problem+json`. Schema: `ErrorResponse`.
    
    _Example RoleNotFound: same as GET /organizations/{organizationId}/roles/{roleId} 404 response._ Role not found
    
    Example of an error when the specified role does not exist
    
    _Example: RoleNotFound_ Role not found
    
    Example of an error when the specified role does not exist
    

### PUT Set Role Permissions

`PUT /organizations/{organizationId}/roles/{roleId}/permissions`

Operation ID: `setRolePermissions`. Security: AmOAuth2 (sfcc.roles.rw).

Assigns permissions to the given role. This will replace the current permission assignments. For the 'Administrator' role only adjustments for custom module permissions will be processed but other given permissions will be ignored.

#### Parameters

*   `organizationId` (path, OrganizationId, required) An identifier for the organization the request is being made by
    
    _Example_
    
    ```
    f_ecom_zzxy_prd
    ```
    
*   `roleId` (path, string, required) The identifier of the access role.  
    Minimum length: 1. Maximum length: 256. Example: `Administrator`.

#### Request body (required)

The permissions to assign to the role

Media type: `application/json`. Schema: `RolePermissions`.

_Example: SetPermissions_ Set role permissions

Example of setting permissions for an access role

```
{
  "module": {
    "organization": [
      {
        "name": "jobschedules",
        "application": "bm",
        "system": true,
        "type": "module",
        "value": "ACCESS"
      }
    ],
    "site": [
      {
        "name": "library_content",
        "application": "bm",
        "system": true,
        "type": "module",
        "values": {
          "SiteGenesis": "ACCESS"
        }
      }
    ]
  },
  "functional": {
    "organization": [
      {
        "name": "Delete_All_Catalogs",
        "type": "functional",
        "value": "ACCESS"
      }
    ]
  }
}
```

#### Responses

*   **200** The permissions were successfully updated
    
    Media type: `application/json`. Schema: `RolePermissions`.
    
    _Example RolePermissionsSuccess: same as GET /organizations/{organizationId}/roles/{roleId}/permissions 200 response._ Successful role permissions retrieval
    
    Example of a successful retrieval of role permissions
    
    _Example: RolePermissionsSuccess_ Successful role permissions retrieval
    
    Example of a successful retrieval of role permissions
    
*   **201** The permissions were successfully assigned
    
    Media type: `application/json`. Schema: `RolePermissions`.
    
    _Example RolePermissionsSuccess: same as GET /organizations/{organizationId}/roles/{roleId}/permissions 200 response._ Successful role permissions retrieval
    
    Example of a successful retrieval of role permissions
    
    _Example: RolePermissionsSuccess_ Successful role permissions retrieval
    
    Example of a successful retrieval of role permissions
    
*   **400** Bad Request - Invalid permissions request
    
    Media type: `application/problem+json`. Schema: `ErrorResponse`.
    
    _Example: InvalidPermissionType_ Invalid permission type
    
    Example of an error when the type of a permission does not match the expected type
    
    ```
    {
      "title": "Invalid Permission Type",
      "type": "https://api.commercecloud.salesforce.com/documentation/error/v1/errors/invalid-permission-type",
      "detail": "The expected permission type is 'module' but provided was 'locale' for permission 'jobschedules(system)' in path 'module.organization'."
    }
    ```
    
    _Example: UnknownPermission_ Unknown permission
    
    Example of an error when a permission ID cannot be resolved
    
    ```
    {
      "title": "Unknown Permission",
      "type": "https://api.commercecloud.salesforce.com/documentation/error/v1/errors/unknown-permission",
      "detail": "Permission 'nonexistent-permission-xyz(system)' for application 'bm' in path 'module.organization' is unknown."
    }
    ```
    
    _Example: InvalidPermissionValue_ Invalid permission value
    
    Example of an error when a permission value is unknown or not supported
    
    ```
    {
      "title": "Invalid Permission Value",
      "type": "https://api.commercecloud.salesforce.com/documentation/error/v1/errors/invalid-permission-value",
      "detail": "Permission 'jobschedules(system)' in path 'module.organization' doesn't support a value of 'INVALID_VALUE'."
    }
    ```
    
*   **404** Role not found
    
    Media type: `application/problem+json`. Schema: `ErrorResponse`.
    
    _Example RoleNotFound: same as GET /organizations/{organizationId}/roles/{roleId} 404 response._ Role not found
    
    Example of an error when the specified role does not exist
    
    _Example: RoleNotFound_ Role not found
    
    Example of an error when the specified role does not exist
    

### POST Search Role Users

`POST /organizations/{organizationId}/roles/{roleId}/user-search`

Operation ID: `searchRoleUsers`. Security: AmOAuth2 (sfcc.roles, sfcc.roles.rw).

Searches for users of the specified access role.

The query attribute specifies a complex query that can be used to narrow down the search. These are the list of searchable attributes:

*   login - String
*   email - String
*   firstName - String
*   lastName - String
*   externalId - String
*   lastLoginDate - Date
*   isLocked - Boolean
*   isDisabled - Boolean

The output of the query can also be sorted. These are the list of sortable attributes:

*   login - String
*   email - String
*   firstName - String
*   lastName - String
*   externalId - String
*   lastLoginDate - Date

#### Parameters

*   `organizationId` (path, OrganizationId, required) An identifier for the organization the request is being made by
    
    _Example_
    
    ```
    f_ecom_zzxy_prd
    ```
    
*   `roleId` (path, string, required) The identifier of the access role.  
    Minimum length: 1. Maximum length: 256. Example: `Administrator`.

#### Request body (required)

The search request document for role users

Media type: `application/json`. Schema: `RoleUserSearchRequest`.

_Example: SearchUsersByLogin_ Search role users by login

Example of searching for users assigned to a role by their login

```
{
  "query": {
    "textQuery": {
      "fields": [
        "login"
      ],
      "searchPhrase": "admin"
    }
  },
  "limit": 25,
  "offset": 0
}
```

_Example: SearchUsersByEmail_ Search role users by email

Example of searching for users assigned to a role by their email

```
{
  "query": {
    "textQuery": {
      "fields": [
        "email"
      ],
      "searchPhrase": "@salesforce.com"
    }
  },
  "limit": 10,
  "offset": 0,
  "sorts": [
    {
      "field": "login",
      "sortOrder": "asc"
    }
  ]
}
```

#### Responses

*   **200** Returns role user search results
    
    Media type: `application/json`. Schema: `RoleUserSearchResult`.
    
    _Example: RoleUserSearchResultSuccess_ Successful role user search result
    
    Example of a successful role user search
    
    ```
    {
      "limit": 1,
      "offset": 0,
      "total": 1,
      "hits": [
        {
          "login": "admin-user",
          "email": "admin@example.com",
          "firstName": "John",
          "lastName": "Doe",
          "externalId": "ext-12345",
          "disabled": false,
          "locked": false,
          "lastLoginDate": "2024-10-14",
          "passwordExpirationDate": "2025-01-14T00:00:00.000Z",
          "passwordModificationDate": "2024-10-14T10:00:00.000Z",
          "preferredDataLocale": "en-US",
          "preferredUiLocale": "en-US",
          "roles": [
            "Administrator"
          ]
        }
      ],
      "query": {
        "textQuery": {
          "fields": [
            "login"
          ],
          "searchPhrase": "admin"
        }
      },
      "sorts": [
        {
          "field": "login",
          "sortOrder": "asc"
        }
      ]
    }
    ```
    
*   **400** Bad Request - Malformed search query or invalid parameters
    
    Media type: `application/problem+json`. Schema: `ErrorResponse`.
    
    _Example: UnqueryableField_ Unqueryable field
    
    Example of an error when an invalid field name is used in the search query
    
    ```
    {
      "title": "Unqueryable Field",
      "type": "https://api.commercecloud.salesforce.com/documentation/error/v1/errors/unqueryable-field",
      "detail": "The field 'nonexistent_field' can't be queried."
    }
    ```
    
    _Example: FieldNotSortable_ Field not sortable
    
    Example of an error when a field that cannot be used for sorting is specified
    
    ```
    {
      "title": "Field Not Sortable",
      "type": "https://api.commercecloud.salesforce.com/documentation/error/v1/errors/field-not-sortable",
      "detail": "The field 'locked' can't be used to sort the results."
    }
    ```
    
*   **404** Role not found
    
    Media type: `application/problem+json`. Schema: `ErrorResponse`.
    
    _Example RoleNotFound: same as GET /organizations/{organizationId}/roles/{roleId} 404 response._ Role not found
    
    Example of an error when the specified role does not exist
    
    _Example: RoleNotFound_ Role not found
    
    Example of an error when the specified role does not exist
    

### GET Get Role Users

`GET /organizations/{organizationId}/roles/{roleId}/users`

Operation ID: `getRoleUsers`. Security: AmOAuth2 (sfcc.roles, sfcc.roles.rw).

Retrieves all users assigned to the specified access role.

#### Parameters

*   `organizationId` (path, OrganizationId, required) An identifier for the organization the request is being made by
    
    _Example_
    
    ```
    f_ecom_zzxy_prd
    ```
    
*   `roleId` (path, string, required) The identifier of the access role.  
    Minimum length: 1. Maximum length: 256. Example: `Administrator`.
*   `select` (query, Select)
    
    _Example: select_
    
    ```
    (**)
    ```
    
*   `limit` (query, integer (int32)) Number of records to retrieve per request. Must be between 1 (minimum) and 200 (maximum). Defaults to 25.  
    Default: `25`. Minimum: 1. Maximum: 200.
*   `offset` (query, integer (int32)) Used to retrieve the results based on a particular resource offset.  
    Default: `0`. Minimum: 0.

#### Responses

*   **200** Returns the collection of users assigned to the role
    
    Media type: `application/json`. Schema: `UserSearch`.
    
    _Example: RoleUserCollectionSuccess_ Successful role user collection
    
    Example of a successful retrieval of users assigned to a role with `select=(**)`
    
    ```
    {
      "limit": 2,
      "offset": 0,
      "total": 2,
      "data": [
        {
          "login": "admin-user",
          "email": "admin@example.com",
          "firstName": "John",
          "lastName": "Doe",
          "externalId": "ext-12345",
          "disabled": false,
          "locked": false,
          "lastLoginDate": "2024-10-14",
          "passwordExpirationDate": "2025-01-14T00:00:00.000Z",
          "passwordModificationDate": "2024-10-14T10:00:00.000Z",
          "preferredDataLocale": "en-US",
          "preferredUiLocale": "en-US",
          "roles": [
            "Administrator"
          ]
        },
        {
          "login": "editor-user",
          "email": "editor@example.com",
          "firstName": "Jane",
          "lastName": "Smith",
          "externalId": "ext-67890",
          "disabled": false,
          "locked": false,
          "lastLoginDate": "2024-11-20",
          "passwordExpirationDate": "2025-02-20T00:00:00.000Z",
          "passwordModificationDate": "2024-11-20T08:30:00.000Z",
          "preferredDataLocale": "en-US",
          "preferredUiLocale": "en-US",
          "roles": [
            "ContentEditor"
          ]
        }
      ]
    }
    ```
    
*   **404** Role not found
    
    Media type: `application/problem+json`. Schema: `ErrorResponse`.
    
    _Example RoleNotFound: same as GET /organizations/{organizationId}/roles/{roleId} 404 response._ Role not found
    
    Example of an error when the specified role does not exist
    
    _Example: RoleNotFound_ Role not found
    
    Example of an error when the specified role does not exist
    

### PUT Assign User to Role

`PUT /organizations/{organizationId}/roles/{roleId}/users/{login}`

Operation ID: `assignUserToRole`. Security: AmOAuth2 (sfcc.roles.rw).

Assigns a user to the specified access role.

#### Parameters

*   `organizationId` (path, OrganizationId, required) An identifier for the organization the request is being made by
    
    _Example_
    
    ```
    f_ecom_zzxy_prd
    ```
    
*   `roleId` (path, string, required) The identifier of the access role.  
    Minimum length: 1. Maximum length: 256. Example: `Administrator`.
*   `login` (path, string, required) The login of the user.  
    Minimum length: 1. Maximum length: 256. Example: `admin-user`.

#### Responses

*   **200** The user was successfully re-assigned to the role
    
    Media type: `application/json`. Schema: `User`.
    
    _Example: UserAssigned_ User assigned to role
    
    Example of a user successfully assigned to an access role
    
    ```
    {
      "login": "admin-user",
      "email": "admin@example.com",
      "firstName": "John",
      "lastName": "Doe",
      "externalId": "ext-12345",
      "disabled": false,
      "locked": false,
      "lastLoginDate": "2024-10-14",
      "passwordExpirationDate": "2025-01-14T00:00:00.000Z",
      "passwordModificationDate": "2024-10-14T10:00:00.000Z",
      "preferredDataLocale": "en-US",
      "preferredUiLocale": "en-US",
      "roles": [
        "Administrator"
      ]
    }
    ```
    
*   **201** The user was successfully assigned to the role
    
    Media type: `application/json`. Schema: `User`.
    
    _Example UserAssigned: same as PUT /organizations/{organizationId}/roles/{roleId}/users/{login} 200 response._ User assigned to role
    
    Example of a user successfully assigned to an access role
    
    _Example: UserAssigned_ User assigned to role
    
    Example of a user successfully assigned to an access role
    
*   **404** Role or user not found
    
    Media type: `application/problem+json`. Schema: `ErrorResponse`.
    
    _Example RoleNotFound: same as GET /organizations/{organizationId}/roles/{roleId} 404 response._ Role not found
    
    Example of an error when the specified role does not exist
    
    _Example: RoleNotFound_ Role not found
    
    Example of an error when the specified role does not exist
    
    _Example: UserNotFound_ User not found
    
    Example of an error when the specified user does not exist
    
    ```
    {
      "title": "User Not Found",
      "type": "https://api.commercecloud.salesforce.com/documentation/error/v1/errors/user-not-found",
      "detail": "No user with login 'nonexistent-user-xyz' could be found."
    }
    ```
    

### DELETE Unassign User from Role

`DELETE /organizations/{organizationId}/roles/{roleId}/users/{login}`

Operation ID: `unassignUserFromRole`. Security: AmOAuth2 (sfcc.roles.rw).

Unassigns a user from the specified access role.

#### Parameters

*   `organizationId` (path, OrganizationId, required) An identifier for the organization the request is being made by
    
    _Example_
    
    ```
    f_ecom_zzxy_prd
    ```
    
*   `roleId` (path, string, required) The identifier of the access role.  
    Minimum length: 1. Maximum length: 256. Example: `Administrator`.
*   `login` (path, string, required) The login of the user.  
    Minimum length: 1. Maximum length: 256. Example: `admin-user`.

#### Responses

*   **204** The user was successfully unassigned from the role
*   **404** Role or user not found
    
    Media type: `application/problem+json`. Schema: `ErrorResponse`.
    
    _Example RoleNotFound: same as GET /organizations/{organizationId}/roles/{roleId} 404 response._ Role not found
    
    Example of an error when the specified role does not exist
    
    _Example UserNotFound: same as PUT /organizations/{organizationId}/roles/{roleId}/users/{login} 404 response._ User not found
    
    Example of an error when the specified user does not exist
    
    _Example: RoleNotFound_ Role not found
    
    Example of an error when the specified role does not exist
    
    _Example: UserNotFound_ User not found
    
    Example of an error when the specified user does not exist
    

## Schemas

### OrganizationId

An identifier for the organization the request is being made by

Type: `string`.

Minimum length: 1. Maximum length: 32. Example: `f_ecom_zzxy_prd`.

### Select

The property selector declaring which fields are included into the response payload. You can specify a single field name, a comma-separated list of names or work with wildcards. You can also specify array operations and filter expressions. The actual selector value must be enclosed within parentheses. For more information, please read the documentation about property selectors [here](https://developer.salesforce.com/docs/commerce/commerce-api/guide/scapi-property-selection.html).

Type: `string`.

Minimum length: 1. Pattern: ^\[(\].\*\[)\]$. Example: `(name,id,variationAttributes.(**))`.

### RoleSearch

Document representing a collection of access roles.

Includes all fields of `PaginatedResultBase`.

*   `data` (_array of Role_, required) The collection of roles.

### Role

Document representing an access role.

*   `id` (_string_) The identifier of the access role.  
    Minimum length: 1. Maximum length: 256. Example: `Administrator`.
*   `description` (_string_) The description of the access role.  
    Maximum length: 4000. Example: `Full administrative access`.
*   `userCount` (_integer (int32)_) The number of users assigned to this role.  
    Example: `5`.
*   `userManager` (_boolean_) Indicates whether this role has user management capabilities.  
    Example: `true`.
*   `permissions` (_RolePermissions_)
*   `users` (_array of User_) The users assigned to the access role. Available through expands.

### ErrorResponse

*   `title` (_string_, required) A short, human-readable summary of the problem type. It will not change from occurrence to occurrence of the problem, except for purposes of localization  
    Maximum length: 256. Example: `You do not have enough credit`.
*   `type` (_string_, required) A URI reference \[RFC3986\] that identifies the problem type. This specification encourages that, when dereferenced, it provide human-readable documentation for the problem type (e.g., using HTML \[W3C.REC-html5-20141028\]). When this member is not present, its value is assumed to be "about:blank". It accepts relative URIs; this means that they must be resolved relative to the document's base URI, as per \[RFC3986\], Section 5.  
    Maximum length: 2048. Example: `NotEnoughMoney`.
*   `detail` (_string_, required) A human-readable explanation specific to this occurrence of the problem.  
    Example: `Your current balance is 30, but that costs 50`.
*   `instance` (_string_) A URI reference that identifies the specific occurrence of the problem. It may or may not yield further information if dereferenced. It accepts relative URIs; this means that they must be resolved relative to the document's base URI, as per \[RFC3986\], Section 5.  
    Maximum length: 2048. Example: `/account/12345/msgs/abc`.

### RolePermissions

Document representing the complete set of permissions for an access role.

*   `module` (_RoleModulePermissions_)
*   `functional` (_RoleFunctionalPermissions_)
*   `locale` (_RoleLocalePermissions_)
*   `webdav` (_RoleWebdavPermissions_)

### RoleUserSearchRequest

Document representing a search request for retrieving users assigned to an access role.

Searchable attributes:

*   login - String
*   email - String
*   firstName - String
*   lastName - String
*   externalId - String
*   lastLoginDate - Date
*   isLocked - Boolean
*   isDisabled - Boolean

Sortable attributes:

*   login - String
*   email - String
*   firstName - String
*   lastName - String
*   externalId - String
*   lastLoginDate - Date

Includes all fields of `SearchRequest`.

### RoleUserSearchResult

Document representing a role user search result. This includes the query, sorts, hits (array of user objects), and pagination information.

Includes all fields of `PaginatedSearchResult`.

*   `hits` (_array of User_, required) The sorted array of search hits (user objects). Can be empty.

### UserSearch

Document representing a collection of users assigned to an access role.

Includes all fields of `PaginatedResultBase`.

*   `data` (_array of User_, required) The collection of users.

### User

Document representing a user.

*   `login` (_string_, required) The login of the user.  
    Minimum length: 1. Maximum length: 256. Example: `admin-user`.
*   `password` (_string_) The password of the user.  
    Maximum length: 256. Example: `password`.
*   `email` (_string_, required) The email address of the user.  
    Maximum length: 256. Example: `admin@example.com`.
*   `firstName` (_string_) The first name of the user.  
    Maximum length: 256. Example: `John`.
*   `lastName` (_string_) The last name of the user.  
    Maximum length: 256. Example: `Doe`.
*   `externalId` (_string_) The external identifier for the user.  
    Maximum length: 256. Example: `ext-12345`.
*   `disabled` (_boolean_) Indicates whether the user is disabled.  
    Example: `false`.
*   `locked` (_boolean_) Indicates whether the user is locked.  
    Example: `false`.
*   `lastLoginDate` (_string (date)_) The date of the user's last login.  
    Example: `2024-10-14`.
*   `passwordExpirationDate` (_string (date-time)_) The date and time when the user's password expires.  
    Example: `2025-01-14T00:00:00.000Z`.
*   `passwordModificationDate` (_string (date-time)_) The date and time when the user's password was last modified.  
    Example: `2024-10-14T10:00:00.000Z`.
*   `preferredDataLocale` (_object_) The preferred data locale for the user.
    
    Includes all fields of `LocaleCode`.
    
*   `preferredUiLocale` (_object_) The preferred UI locale for the user.
    
    Includes all fields of `LocaleCode`.
    
*   `roles` (_array of string_) The list of role identifiers assigned to the user.  
    Items: Maximum length: 256. Example: `Administrator`.

### PaginatedResultBase

Schema defining generic pageable result. Each response schema of a resource requiring pagination should extend this schema. If you use this extend this schema directly, it needs to be defined what data is returned. Allowed names for the data field is `data`.

Includes all fields of `ResultBase`.

*   `offset` (_Offset_, required)

### RoleModulePermissions

Document listing the module permissions assigned to a role, scoped to organization and site levels.

*   `organization` (_array of RoleModulePermission_) Organization-level module permissions. Each entry uses a single `value`.
*   `site` (_array of RoleModulePermission_) Site-level module permissions. Each entry uses a `values` map keyed by site ID.

### RoleFunctionalPermissions

Document listing the functional permissions assigned to a role, scoped to organization and site levels.

*   `organization` (_array of RoleFunctionalPermission_) Organization-level functional permissions. Each entry uses a single `value`.
*   `site` (_array of RoleFunctionalPermission_) Site-level functional permissions. Each entry uses a `values` map keyed by site ID.

### RoleLocalePermissions

Document listing the locale permissions assigned to a role (unscoped).

*   `unscoped` (_array of RoleLocalePermission_) Unscoped locale permissions. A permission for the "default" locale is mandatory.

### RoleWebdavPermissions

Document listing the WebDAV permissions assigned to a role (unscoped).

*   `unscoped` (_array of RoleWebdavPermission_) Unscoped WebDAV permissions.

### SearchRequest

Document representing a search request for retrieving items within the Data API. The query is a potentially complex set of expressions. The fields and expands that each query supports are defined within the search resource.

*   `limit` (_integer (int32)_) Maximum records to retrieve per request, not to exceed 200.  
    Minimum: 1. Maximum: 200. Example: `10`.
*   `query` (_Query_, required)
*   `sorts` (_array of Sort_) The list of sort clauses configured for the search request. Sort clauses are optional. See the description of the search endpoint for details on the default sorting behavior that is used when explicit sorts are not passed.
*   `offset` (_Offset_)

### PaginatedSearchResult

Document representing a generic search result. Each search resource should extend this to define what is returned in the `hits`.

Includes all fields of `PaginatedResultBase`.

*   `query` (_Query_, required)
*   `sorts` (_array of Sort_) The sorting that was applied to the result.
*   `hits` (_array of object_) The sorted array of search hits. Can be empty.

_Example_

```
{
  "limit": 1,
  "hits": [
    {
      "couponId": "coupon1",
      "creationDate": "2019-10-20T12:00:00Z",
      "description": "This coupon is used to give 10% off stuff.",
      "enabled": false,
      "exportedCodeCount": 0,
      "lastModified": "2019-10-30T04:23:59Z",
      "redemptionCount": 3,
      "redemptionLimits": {
        "limitPerCode": 1,
        "limitPerCustomer": 1,
        "limitPerTimeFrame": {
          "limit": 2,
          "redemptionTimeFrame": 24
        }
      },
      "singleCode": "MyCode",
      "systemCodesConfig": {
        "codePrefix": "SG",
        "numberOfCodes": 500000
      },
      "totalCodesCount": 50,
      "type": "single_code"
    }
  ],
  "query": {
    "textQuery": {
      "fields": [
        "id",
        "description"
      ],
      "searchPhrase": "stuff"
    }
  },
  "sorts": [
    {
      "field": "couponId",
      "sortOrder": "desc"
    }
  ],
  "offset": 2,
  "total": 8
}
```

### LocaleCode

A descriptor for a geographical region by both a language and country code. By combining these two, regional differences in a language can be addressed, such as with the request header parameter `Accept-Language` following [RFC 2616](https://tools.ietf.org/html/rfc2616) & [RFC 1766](https://tools.ietf.org/html/rfc1766). This can also just refer to a language code, also RFC 2616/1766 compliant, as a default if there is no specific match for a country. Finally, can also be used to define default behavior if there is no locale specified.

One of: `LanguageCountry`, `LanguageCode`, `DefaultFallback`.

### ResultBase

Schema defining generic list result. Each response schema of a resource requiring a list response should extend this schema. Additionally it needs to be defined what data is returned.

*   `limit` (_integer (int32)_, required) Maximum records to retrieve per request. The limit with its constraints (minimum, maximum, default) is defined by the request parameter `limit` of the endpoint returning this schema.  
    Example: `10`.
*   `total` (_Total_, required)

### Offset

The zero-based index of the first hit/data to include in the result.

Type: `integer (int32)`.

Default: `0`. Minimum: 0. Example: `0`.

### RoleModulePermission

Document representing a single module permission entry.

*   `name` (_string_, required) The related menu action name of the module permission.  
    Minimum length: 1. Maximum length: 256. Example: `jobschedules`.
*   `type` (_string_, required) The permission type. Always "module" for module permissions.  
    Minimum length: 1. Maximum length: 256. Example: `module`.
*   `application` (_string_, required) The permission application (e.g. "bm" for Business Manager, "csc" for Commerce Service Cloud).  
    Minimum length: 1. Maximum length: 256. Example: `bm`.
*   `system` (_boolean_) Indicates whether this is a system menu action. False for custom menu actions.  
    Example: `true`.
*   `value` (_string_) The non domain-specific permission value used in organization scope (e.g. ACCESS, READONLY).  
    Maximum length: 256. Example: `ACCESS`.
*   `values` (_object_) A map of site identifiers to permission values, used in site scope.
    
    Additional properties: `string`.
    
    Maximum length: 256. Example: `ACCESS`.
    
    _Example_
    
    ```
    {
      "SiteGenesis": "ACCESS",
      "RefArch": "ACCESS"
    }
    ```
    

### RoleFunctionalPermission

Document representing a single functional permission entry.

*   `name` (_string_, required) The name of the functional permission.  
    Minimum length: 1. Maximum length: 256. Example: `Delete_All_Catalogs`.
*   `type` (_string_, required) The permission type. Always "functional" for functional permissions.  
    Minimum length: 1. Maximum length: 256. Example: `functional`.
*   `value` (_string_) The non domain-specific permission value used in organization scope (e.g. ACCESS).  
    Maximum length: 256. Example: `ACCESS`.
*   `values` (_object_) A map of site identifiers to permission values, used in site scope.
    
    Additional properties: `string`.
    
    Maximum length: 256. Example: `ACCESS`.
    
    _Example_
    
    ```
    {
      "SiteGenesis": "ACCESS"
    }
    ```
    

### RoleLocalePermission

Document representing a single locale permission entry.

*   `localeId` (_object_, required) The related locale id of the locale permission.
    
    Includes all fields of `LocaleCode`.
    
*   `type` (_string_, required) The permission type. Always "locale" for locale permissions.  
    Minimum length: 1. Maximum length: 256. Example: `locale`.
*   `value` (_string_) The non domain-specific permission value (e.g. ACCESS, READONLY).  
    Maximum length: 256. Example: `ACCESS`.
*   `values` (_object_) A map of domain identifiers to permission values.
    
    Additional properties: `string`.
    
    Maximum length: 256. Example: `ACCESS`.
    

### RoleWebdavPermission

Document representing a single WebDAV permission entry.

*   `folder` (_string_, required) The WebDAV folder path for this permission.  
    Minimum length: 1. Maximum length: 256. Example: `/catalogs/apparel-catalog`.
*   `type` (_string_, required) The permission type. Always "webdav" for WebDAV permissions.  
    Minimum length: 1. Maximum length: 256. Example: `webdav`.
*   `value` (_string_) The non domain-specific permission value (e.g. ACCESS, READONLY).  
    Maximum length: 256. Example: `ACCESS`.
*   `values` (_object_) A map of domain identifiers to permission values.
    
    Additional properties: `string`.
    
    Maximum length: 256. Example: `ACCESS`.
    

### Query

A set of objects that define criteria used to select records. A query can contain one of the following:

*   `MatchAllQuery`

*   Matches all documents.

*   `TermQuery`

*   Matches one or more documents against one or more document fields.

*   `TextQuery`

*   Matches text against one or more fields.

*   `BoolQuery`

*   Allows construction of a logical expression of multiple queries.

*   `FilteredQuery`

*   Allows a filter to be applied to a query.

*   `NestedQuery`

*   Allows you to query on nested documents.
*   _Only supported by some Commerce APIs. For more details, see the endpoint descriptions in the API documentation._

Minimum properties: 1. Maximum properties: 1.

*   `boolQuery` (_BoolQuery_)
*   `filteredQuery` (_FilteredQuery_)
*   `matchAllQuery` (_MatchAllQuery_)
*   `nestedQuery` (_NestedQuery_)
*   `termQuery` (_TermQuery_)
*   `textQuery` (_TextQuery_)

_Example_

```
{
  "filteredQuery": {
    "query": {
      "textQuery": {
        "fields": [
          "couponId"
        ],
        "searchPhrase": "disabled"
      }
    },
    "filter": {
      "termFilter": {
        "field": "enabled",
        "operator": "is",
        "values": [
          false
        ]
      }
    }
  }
}
```

### Sort

Document representing a sort request. Each API has a different default sort configuration that can be modified in the request.

*   `field` (_string_, required) The name of the field to sort on.  
    Maximum length: 256. Example: `couponId`.
*   `sortOrder` (_string_) The sort order to be applied when sorting. When omitted, the default sort order (asc) is used.  
    Allowed values: `asc`, `desc`. Default: `asc`. Example: `asc`.

_Example_

```
{
  "field": "couponId",
  "sortOrder": "desc"
}
```

### LanguageCountry

A concatenated version of the standard Language and Country codes, combined with a hyphen '`-`'.

Type: `string`.

Pattern: ^\[a-z\]\[a-z\]-\[A-Z\]\[A-Z\]$. Example: `en-US`.

### LanguageCode

A two letter lowercase language code conforming to the [ISO 639-1](https://www.iso.org/iso-639-language-codes.html) standard. Additionally, this may be used to submit requests with the header parameter `Accept-Language`, following [RFC 2616](https://tools.ietf.org/html/rfc2616) & [RFC 1766](https://tools.ietf.org/html/rfc1766).

Type: `string`.

Pattern: ^\[a-z\]\[a-z\]$. Example: `en`.

### DefaultFallback

A specialized value indicating the system default values for locales.

Type: `string`.

Default: `default`. Pattern: ^default$. Example: `default`.

### Total

The total number of hits that match the search's criteria. This can be greater than the number of results returned as search results are pagenated.

Type: `integer (int32)`.

Default: `0`. Minimum: 0. Example: `10`.

### BoolQuery

A boolean query allows construction of full logical expression trees that are composed of other queries (usually term queries and text queries). A boolean query has three sets of clauses:

*   `must`, which combines as an `AND` operator.
*   `should`, which combines as an `OR` operator.
*   `must_not`, which combines as a `NOT` operator.

If `must`, `mustNot`, or `should` appear in the same boolean query, they are combined logically using the `AND` operator. For example:

```
(must-1 AND must-1 AND ...)
  AND (should-1 OR should-2 OR ...)
  AND NOT (must_not-1 OR must_not-2 OR ...)
```

*   `must` (_array of Query_) List of queries to be evaluated as an `AND` operator.
*   `mustNot` (_array of Query_) List of queries to be evaluated as a `NOT` operator.
*   `should` (_array of Query_) List of queries to be evaluated as an `OR` operator.

_Example_

```
{
  "value": {
    "must": [
      {
        "textQuery": {
          "fields": [
            "couponId"
          ],
          "searchPhrase": "DEAL"
        }
      },
      {
        "textQuery": {
          "fields": [
            "description"
          ],
          "searchPhrase": "Big bargain deal"
        }
      }
    ],
    "mustNot": [
      {
        "termQuery": {
          "fields": [
            "enabled"
          ],
          "operator": "is",
          "values": [
            false
          ]
        }
      }
    ]
  }
}
```

### FilteredQuery

Allows to filter the result of a possibly complex query using a possibly complex filter.

*   `filter` (_Filter_, required)
*   `query` (_Query_, required)

_Example_

```
{
  "query": {
    "textQuery": {
      "fields": [
        "couponId"
      ],
      "searchPhrase": "disabled"
    }
  },
  "filter": {
    "termFilter": {
      "field": "enabled",
      "operator": "is",
      "values": [
        false
      ]
    }
  }
}
```

### MatchAllQuery

Matches all documents (namespace and document type). This query comes in handy if you just want to filter a search result or really do not have any constraints.

### NestedQuery

Allows you to query nested documents that are part of a larger document. Say, for example, that you have a main product with variations in one big document, and you want to constrain a search to main products that have variations that match multiple constraints.

A `NestedQuery` is only supported by some Commerce APIs. For more details, see the endpoint descriptions in the API documentation.

*   `path` (_string_, required) The path to the nested document.  
    Maximum length: 2048. Example: `order.shippingAddresses`.
*   `query` (_Query_, required)
*   `scoreMode` (_string_) Indicates how scores for matching child objects affect the root parent document’s relevance score.  
    Allowed values: `avg`, `total`, `max`, `none`. Example: `avg`.

_Example_

```
{
  "path": "order.shippingAddresses",
  "query": {
    "boolQuery": {
      "must": [
        {
          "boolQuery": {
            "must": [
              {
                "termQuery": {
                  "fields": [
                    "order.shippingAddresses.firstName"
                  ],
                  "operator": "is",
                  "values": [
                    "John"
                  ]
                }
              }
            ]
          }
        },
        {
          "boolQuery": {
            "must": [
              {
                "termQuery": {
                  "fields": [
                    "order.shippingAddresses.lastName"
                  ],
                  "operator": "is",
                  "values": [
                    "Doe"
                  ]
                }
              }
            ]
          }
        }
      ]
    }
  },
  "scoreMode": "avg"
}
```

### TermQuery

A term query matches one or more values against one or more document fields. A document is considered a hit if one of the values matches exactly with at least one of the given fields. The operator `is` can only take one value, while `one_of` can take multiple values. If multiple fields are specified, they are combined using a logical `OR` operator.

**Limitations:**

*   The `greater` and `less` operators are not supported under certain conditions. Both operators are permitted unless the API documentation states otherwise.
*   A subset of Commerce APIs handle queries with multiple fields differently. If the query has multiple fields, the query is internally handled as a logical `OR` of `DisjointMaxQueries` (with the dismax matching a value against all fields). The dismax makes sure that a document carrying a single term in multiple fields does not get higher scores than a document matching multiple terms in multiple fields.

*   `fields` (_array of Field_, required) The document fields that the values are matched against, combined with the operator.  
    Minimum items: 1.
*   `operator` (_string_, required) Returns the operator to use for the term query.  
    Allowed values: `is`, `one_of`, `is_null`, `is_not_null`, `less`, `greater`, `not_in`, `neq`. Example: `is`.
*   `values` (_array of string | number | boolean | integer_) The values that the fields are compared against, combined with the operator.  
    Items: Example: `myCouponId`.

### TextQuery

A text query is used to match some text (for example, a search phrase possibly consisting of multiple terms) against one or more fields. When multiple fields are provided, the phrase conceptually forms a logical `OR` over the fields. In this case, the terms of the phrase basically have to match within the text, that would result in concatenating all given fields.

*   `fields` (_array of Field_, required) The document fields that the search phrase matches against.  
    Minimum items: 1.
*   `searchPhrase` (_string_, required) A search phrase, which can include multiple terms separated by spaces.  
    Example: `campaign summer`.

_Example_

```
{
  "fields": [
    "couponId"
  ],
  "searchPhrase": "limit"
}
```

### Filter

Contains a set of objects that define criteria used to select records. A filter can contain one of the following:

*   `TermFilter`

*   Matches records where a field (or fields) exactly matches some simple value (including `null`).

*   `RangeFilter`

*   Matches records where a field value lies within a specified range.

*   `Range2Filter`

*   Matches records in a specified range across fields.

*   `QueryFilter`

*   Matches records based on a query.

*   `BoolFilter`

*   Provides filtering of records using a set of filters combined using a logical operator.

Minimum properties: 1. Maximum properties: 1.

*   `boolFilter` (_BoolFilter_)
*   `queryFilter` (_QueryFilter_)
*   `range2Filter` (_Range2Filter_)
*   `rangeFilter` (_RangeFilter_)
*   `termFilter` (_TermFilter_)

### Field

Name of the field. Might be a custom field name prefixed with c\_.

Type: `string`.

Maximum length: 260. Example: `couponId`.

### BoolFilter

Allows you to combine other filters into (possibly recursive) logical expression trees. A boolean filter is composed of a logical operator (`AND`, `OR`, `NOT`) and a list of filters that the operator relates to. Multiple filters can be negated with a single `NOT` operator, even when the filters are combined with the `AND` operator.

*   `filters` (_array of Filter_) A list of filters that are logically combined by an operator.
*   `operator` (_string_, required) The logical operator that is used to combine the filters.  
    Allowed values: `and`, `or`, `not`. Example: `and`.

_Example_

```
{
  "value": {
    "operator": "and",
    "filters": [
      {
        "termFilter": {
          "field": "id",
          "operator": "is",
          "values": [
            "myId"
          ]
        }
      },
      {
        "termFilter": {
          "field": "couponId",
          "operator": "is",
          "values": [
            "couponOne"
          ]
        }
      }
    ]
  }
}
```

### QueryFilter

Wraps any query and allows it to be used as a filter.

*   `query` (_Query_, required)

### Range2Filter

Allows you to restrict a search result to hits where a range defined by specified attributes has a certain relationship to a specified range.

The first range (R1) is defined by a pair of attributes (`fromField` and `toField`) that specify the extent of a range, such as attributes `validFrom` and `validTo`.

The second range (R2) is defined by `fromValue` and `toValue`.

The filter mode specifies the method used to compare the two ranges:

*   `overlap`: R1 overlaps fully or partially with R2.
*   `containing`: R1 contains R2.
*   `contained`: R1 is contained in R2.

The range filter supports several value types, and relies on the natural sorting of the value type for range interpretation. Value ranges can be open-ended, but only at one end of the range. You can configure whether the lower bounds and upper bounds are inclusive or exclusive.

A range 2 filter is useful for general restrictions that can be shared between searches (like a static date range) because the filter result is cached in memory. Range filters are not appropriate if the range is expected to be different for every query (for example, if the user controls the date range down to the hour via a UI control). Range filters are inclusive by default.

*   `filterMode` (_string_) Compare mode: overlap, containing, or contained.  
    Allowed values: `overlap`, `containing`, `contained`. Default: `overlap`. Example: `overlap`.
*   `fromField` (_object_, required) The field name of the field that starts the first range.  
    Example: `validFrom`.
    
    Includes all fields of `Field`.
    
    Example: `validFrom`.
    
*   `fromInclusive` (_boolean_) A flag indicating if the lower bound of the second range is inclusive. To make the lower bound exclusive, set to `false`.  
    Default: `true`. Example: `true`.
*   `fromValue` (_any_) The lower bound of the second range. If not specified, the range is open-ended with respect to the lower bound. You can't leave both the lower and upper bounds open-ended.  
    Example: `2007-01-01T00:00:00.000Z`.
*   `toField` (_object_, required) The field name of the field that ends the first range.  
    Example: `validTo`.
    
    Includes all fields of `Field`.
    
    Example: `validTo`.
    
*   `toInclusive` (_boolean_) A flag indicating if the upper bound of the second range is inclusive. To make the lower bound exclusive, set to `false`.  
    Default: `true`. Example: `true`.
*   `toValue` (_any_) The upper bound of the second range. If not specified, the range is open-ended with respect to the upper bound. You can't leave both the upper and lower bounds open-ended.  
    Example: `2017-01-01T00:00:00.000Z`.

_Example_

```
{
  "fromField": "validFrom",
  "toField": "validTo",
  "filterMode": "overlap",
  "fromValue": "2007-01-01T00:00:00.000Z",
  "toValue": "2017-01-01T00:00:00.000Z"
}
```

### RangeFilter

Allows you to restrict a search result to hits that have values for a given attribute that fall within a given value range. The range filter supports several value types and relies on the natural sorting of the value type for range interpretation. Value ranges can be open-ended, but only at one end of the range. You can configure whether the lower bounds and upper bounds are inclusive or exclusive.

A range filter is useful for general restrictions that can be shared between searches (like a static date range) because the filter result is cached in memory. Range filters are not appropriate if the range is expected to be different for every query (for example, if the user controls the date range down to the hour via a UI control). Range filters are inclusive by default.

*   `field` (_object_, required) The search field.  
    Example: `validFrom`.
    
    Includes all fields of `Field`.
    
    Example: `validFrom`.
    
*   `from` (_string (date-time) | integer | number_) The lower bound of the filter range. If not specified, the range is open-ended with respect to the lower bound. You can't leave both the lower and upper bounds open-ended.
    
    One of: `string (date-time)`, `integer`, `number`.
    
    *   _string (date-time)_
        
        Type: `string (date-time)`.
        
        Example: `2007-01-01T00:00:00.000Z`.
        
    *   _integer_
        
        Type: `integer`.
        
        Example: `1`.
        
    *   _number_
        
        Type: `number`.
        
        Example: `1`.
        
*   `fromInclusive` (_boolean_) A flag indicating if the lower bound of the range is inclusive. To make the lower bound exclusive, set to `false`.  
    Default: `true`. Example: `true`.
*   `to` (_string (date-time) | integer | number_) The upper bound of the filter range. If not specified, the range is open-ended with respect to the upper bound. You can't leave both the upper and lower bounds open-ended.
    
    One of: `string (date-time)`, `integer`, `number`.
    
    *   _string (date-time)_
        
        Type: `string (date-time)`.
        
        Example: `2007-01-02T00:00:00.000Z`.
        
    *   _integer_
        
        Type: `integer`.
        
        Example: `2`.
        
    *   _number_
        
        Type: `number`.
        
        Example: `2`.
        
*   `toInclusive` (_boolean_) A flag indicating if the upper bound of the range is inclusive. To make the upper bound exclusive, set to `false`.  
    Default: `true`. Example: `true`.

### TermFilter

Allows you to restrict a search result to hits that match exactly one of the values configured for the filter. A term filter is useful for general restrictions that can be shared between searches. Use term filters whenever the criteria you filter on is a shared property of multiple searches (for example, like filtering by an order status). Use term filters for fields that have a discrete and small set of values only.

*   `field` (_object_, required) The filter field.
    
    Includes all fields of `Field`.
    
*   `operator` (_string_, required) The operator used to compare the field's values with the given values.  
    Allowed values: `is`, `one_of`, `is_null`, `is_not_null`, `less`, `greater`, `not_in`, `neq`. Example: `is`.
*   `values` (_array of string_) The filter values.  
    Items: Example: `myId`.

_Example_

```
{
  "field": "id",
  "operator": "is",
  "values": [
    "myId"
  ]
}
```