---
title: VMI user API handler
slug: configured-commerce/docs/vmi-user-api-handler
docTags: 
createdAt: 2026-08-13T10:46:28.000Z
---

## POST Import VMI Users

**HTTP Verb** – POST

**URL** – /api/v1/accounts/vmi/import

**Description** – Import VMI users with role assignments and location mappings

**Base** – `HandlerBase\<ImportVmiUsersParameter, ImportVmiUsersResult\>`

**Handlers** –

| Order | Handler                   | Description                                                                                                                                                                                                                                                                                                |
| ----- | ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 500   | `ValidateContext`         | Validates that VMI is enabled in `OrderManagementGeneralSettings`. Verifies the current user is logged in. Checks user roles to determine `CanUpdateUsers`. If `VmiUsers` are provided but the user cannot update users, returns Forbidden. Sets the `BillTo` from the current site context.               |
| 600   | `GetUsers`                | If `VmiUsers` parameter is empty, bypasses handler. Retrieves `UserProfile` entities matching the provided user Ids that are associated with the current `BillTo` customer. Includes customer relationships via eager loading.                                                                             |
| 700   | `GetVmiLocations`         | If `VmiUsers` parameter is empty, bypasses handler. Retrieves `VmiLocation` entities matching the location names from the import data. Filters to active locations assigned to available ship-to customers.                                                                                                |
| 800   | `UpdateUsers`             | If no users were found, bypasses handler. For each user, updates VMI roles (removes existing VMI\_Admin and VMI\_User roles, then adds specified roles). Assigns customers associated with the specified VMI locations using the account pipeline. Updates `RolesChangedOn` timestamp for non-guest users. |
| 900   | `SetImportVmiUsersResult` | Copies the `VmiUsers` parameter to the result for the response.                                                                                                                                                                                                                                            |

## PATCH Update VMI User

**HTTP Verb** – PATCH

**URL** – /api/v1/accounts/vmi/

**Description** – Update a VMI user's role and location assignments

**Base** – `HandlerBase\<UpdateVmiUserParameter, UpdateVmiUserResult\>`

**Handlers** –

| Order | Handler                  | Description                                                                                                                                                                                                                                                                                                                   |
| ----- | ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 500   | `ValidateContext`        | Retrieves the `UserProfile` by the specified `UserId` (includes customer relationships). Returns `NotFound` error if the user does not exist.                                                                                                                                                                                 |
| 600   | `UpdateRole`             | If Role is blank and `RemoveVmiPermissions` is `false`, bypasses handler. Removes existing VMI\_Admin and VMI\_User roles. If `RemoveVmiPermissions` is `true`, updates `RolesChangedOn` and exits. Otherwise, validates the specified role exists, assigns it to the user, and updates `RolesChangedOn` for non-guest users. |
| 700   | `AssignVmiLocations`     | If `VmiLocationIds` parameter is `null`, bypasses handler. Unassigns all existing VMI location customers from the user. If `VmiLocationIds` is not empty, retrieves the `VmiLocations` and assigns their associated customers to the user. Invalidates ETag caches for updated customers.                                     |
| 800   | `SetUpdateVmiUserResult` | Copies `UserId`, Role, `VmiLocationIds`, and `RemoveVmiPermissions` from the parameter to the result for the response.                                                                                                                                                                                                        |
