User Account Functions
The User Account drop-in provides API functions that enable you to programmatically control behavior, fetch data, and integrate with Adobe Commerce backend services.
| Function | Description |
|---|---|
createCompanyAddress | Creates a company address in the company address book using the CustomerAddressesModel object. |
createCustomerAddress | Creates an address for an existing customer using the CustomerAddressesModel object as an argument. |
deleteCompanyAddress | Deletes a company address by ID. |
getAdminAssistanceActions | Fetches a paginated list of administrator actions recorded during seller-assisted buying sessions. |
getAttributesForm | Calls the attributesForm query to retrieve EAV attributes associated with customer and customer address frontend forms. |
getCompanyAddressBook | Retrieves the company address book for the current customer. |
getCompanyAddressBookConfig | Retrieves the company address book configuration. |
getCountries | Calls the countries query to retrieve a list of countries. |
getCustomer | Retrieves the customer information for the logged-in customer. |
getCustomerAddress | Returns an array of addresses associated with the current customer. |
getCustomerCompanyContext | Determines whether the customer has a company context. |
getCustomerPaymentTokens | Retrieves stored payment tokens for the logged-in customer via the customerPaymentTokens query. |
getCustomerRolePermissions | Retrieves and resolves the customer’s company address role permissions. |
deletePaymentToken | Removes a stored payment token using the deletePaymentToken mutation. |
getOrderHistoryList | Retrieves a list of customer orders asynchronously using the customer query. |
getRegions | Calls the country query to retrieve a list of states or provinces for a specific country. |
getStoreConfig | Calls the storeConfig query to retrieve password requirements and the seller-assisted buying feature flag and consent checkbox settings. |
removeCustomerAddress | Removes an address associated with the current customer. |
setDefaultCompanyAddress | Sets a company address as the default by ID. |
updateCompanyAddress | Updates a company address by ID. |
updateCustomer | Updates the logged-in customer. |
updateCustomerAddress | Updates an address associated with the current customer. |
updateCustomerEmail | Updates the email address of the logged-in customer. |
updateCustomerPassword | Updates the password of the logged-in customer. |
createCompanyAddress
Section titled “createCompanyAddress”The createCompanyAddress function creates a company address in the company address book using the CustomerAddressesModel object as an argument. Use it in B2B flows where the customer manages company addresses.
const createCompanyAddress = async ( address: CustomerAddressesModel): Promise<CreateCompanyAddressResult>| Parameter | Type | Req? | Description |
|---|---|---|---|
address | CustomerAddressesModel | Yes | The company address details, including street, city, region, country, postal code, and optional fields such as company name and phone number. |
Events
Section titled “Events”Does not emit any drop-in events.
Returns
Section titled “Returns”Returns a CompanyAddressModel for the created company address.
createCustomerAddress
Section titled “createCustomerAddress”The createCustomerAddress function creates an address for an existing customer using the CustomerAddressesModel object as an argument. The function calls the createCustomerAddress mutation.
const createCustomerAddress = async ( address: CustomerAddressesModel): Promise<string>| Parameter | Type | Req? | Description |
|---|---|---|---|
address | CustomerAddressesModel | Yes | The new address details including street, city, region, country, postal code, and optional fields like company name and phone number. |
Events
Section titled “Events”Does not emit any drop-in events.
Returns
Section titled “Returns”Returns string.
deleteCompanyAddress
Section titled “deleteCompanyAddress”The deleteCompanyAddress function deletes a company address from the company address book. Pass the ID of the address to remove.
const deleteCompanyAddress = async ( id: string): Promise<DeleteCompanyAddressResult>| Parameter | Type | Req? | Description |
|---|---|---|---|
id | string | Yes | The ID of the company address to delete. |
Events
Section titled “Events”Does not emit any drop-in events.
Returns
Section titled “Returns”Returns a boolean that is true when the company address is deleted.
getAdminAssistanceActions
Section titled “getAdminAssistanceActions”The getAdminAssistanceActions function fetches a paginated list of administrator actions recorded during seller-assisted buying sessions. The SellerAssistedBuyingActivity container uses this function internally to populate its activity grid.
const getAdminAssistanceActions = async ( pageSize: number, currentPage: number): Promise<AdminAssistanceActions | null>| Parameter | Type | Req? | Description |
|---|---|---|---|
pageSize | number | Yes | Number of items to fetch per page. |
currentPage | number | Yes | Page to fetch, starting at 1. |
Events
Section titled “Events”Does not emit any drop-in events.
Returns
Section titled “Returns”Returns AdminAssistanceActions or null when the request fails or returns no data.
Example
Section titled “Example”import { getAdminAssistanceActions } from '/@dropins/storefront-account/api.js';
const actions = await getAdminAssistanceActions(10, 1);
if (actions) { console.log('Total actions:', actions.totalCount); console.log('Total pages:', actions.pageInfo.totalPages);
actions.items.forEach((item) => { console.log(`${item.date}: ${item.action} — ${item.details}`); });}getAttributesForm
Section titled “getAttributesForm”The getAttributesForm function calls the attributesForm query to retrieve EAV attributes associated with customer and customer address frontend forms. The formCode parameter must be one of the following values: customer_account_create, customer_account_edit, customer_address_create, or customer_address_edit.
const getAttributesForm = async ( formCode: string): Promise<AttributesFormModel[]>| Parameter | Type | Req? | Description |
|---|---|---|---|
formCode | string | Yes | One of “customer_account_create”, “customer_account_edit”, “customer_address_create”, “customer_address_edit”. |
Events
Section titled “Events”Does not emit any drop-in events.
Returns
Section titled “Returns”Returns AttributesFormModel[].
getCompanyAddressBook
Section titled “getCompanyAddressBook”The getCompanyAddressBook function retrieves the company address book for the current customer.
const getCompanyAddressBook = async (): Promise<CompanyAddressBookModel>Events
Section titled “Events”Does not emit any drop-in events.
Returns
Section titled “Returns”Returns a CompanyAddressBookModel.
getCompanyAddressBookConfig
Section titled “getCompanyAddressBookConfig”The getCompanyAddressBookConfig function retrieves the company address book configuration, such as whether the company address book and custom company addresses are enabled.
const getCompanyAddressBookConfig = async (): Promise<CompanyAddressBookConfigModel>Events
Section titled “Events”Does not emit any drop-in events.
Returns
Section titled “Returns”Returns a CompanyAddressBookConfigModel.
getCountries
Section titled “getCountries”The getCountries function calls the countries query to retrieve a list of countries.
const getCountries = async (): Promise<{ availableCountries: Country[] | []; countriesWithRequiredRegion: string[]; optionalZipCountries: string[];}>Events
Section titled “Events”Does not emit any drop-in events.
Returns
Section titled “Returns”Promise<{ availableCountries: Country[] | []; countriesWithRequiredRegion: string[]; optionalZipCountries: string[];}>See Country.
getCustomer
Section titled “getCustomer”The getCustomer function retrieves the customer information for the logged-in customer. The function calls the customer query.
const getCustomer = async (): Promise<CustomerDataModelShort>Events
Section titled “Events”Does not emit any drop-in events.
Returns
Section titled “Returns”Returns CustomerDataModelShort.
getCustomerAddress
Section titled “getCustomerAddress”The getCustomerAddress function returns an array of addresses associated with the current customer. The function calls the customer query.
const getCustomerAddress = async (): Promise< CustomerAddressesModel[]>Events
Section titled “Events”Does not emit any drop-in events.
Returns
Section titled “Returns”Promise< CustomerAddressesModel[]>getCustomerCompanyContext
Section titled “getCustomerCompanyContext”The getCustomerCompanyContext function determines whether the customer has a company context. Use it to detect B2B customers before showing company-specific features.
const getCustomerCompanyContext = async (): Promise<boolean>Events
Section titled “Events”Does not emit any drop-in events.
Returns
Section titled “Returns”Returns a boolean that is true when the customer has a company context.
getCustomerPaymentTokens
Section titled “getCustomerPaymentTokens”The getCustomerPaymentTokens function retrieves saved payment methods (vault tokens) for the logged-in customer. It calls the `customerPaymentTokens` query via the drop-in GraphQL client (GET, no cache), then transforms the results into display rows for the PaymentMethods container.
const getCustomerPaymentTokens = async ( filterPaymentMethodCodes?: string[]): Promise<StoredPaymentMethodDisplay[]>| Parameter | Type | Req? | Description |
|---|---|---|---|
filterPaymentMethodCodes | string[] | No | When set, only tokens whose payment_method_code equals or starts with one of these strings are returned. |
Events
Section titled “Events”Does not emit any drop-in events. To populate the PaymentMethods list from client-side data without calling this query, emit account/customerPaymentTokens on the event bus (see Events). This event is for display data only. Token removal still uses deletePaymentToken, not the bus.
Returns
Section titled “Returns”Returns StoredPaymentMethodDisplay[].
getCustomerRolePermissions
Section titled “getCustomerRolePermissions”The getCustomerRolePermissions function retrieves and resolves the customer’s role permissions for company address management.
const getCustomerRolePermissions = async (): Promise<ResolvedCompanyAddressPermissions>Events
Section titled “Events”Does not emit any drop-in events.
Returns
Section titled “Returns”Returns a ResolvedCompanyAddressPermissions object describing which company address actions the customer can perform.
deletePaymentToken
Section titled “deletePaymentToken”The deletePaymentToken function removes a stored payment token for the logged-in customer. It calls the deletePaymentToken mutation with the token public_hash.
The built-in PaymentMethods container calls this only after the shopper confirms removal in the confirmation dialog. If you call deletePaymentToken from your own code, the mutation runs immediately and there is no confirmation UI unless you implement it.
const deletePaymentToken = async (publicHash: string): Promise<boolean>| Parameter | Type | Req? | Description |
|---|---|---|---|
publicHash | string | Yes | Public hash of the token to remove (from getCustomerPaymentTokens or the account/customerPaymentTokens payload). |
Events
Section titled “Events”Does not emit any drop-in events.
Returns
Section titled “Returns”Returns true when the mutation reports success, otherwise false.
getOrderHistoryList
Section titled “getOrderHistoryList”The getOrderHistoryList function is an asynchronous function that retrieves a list of customer orders using the customer query. It optionally takes parameters for pagination and filtering.
const getOrderHistoryList = async ( pageSize: number, selectOrdersDate: string, currentPage: number): Promise<OrderHistoryModel | null>| Parameter | Type | Req? | Description |
|---|---|---|---|
pageSize | number | Yes | The maximum number of results to return at once. The default value is 20. |
selectOrdersDate | string | Yes | Represents a date filter for the orders. |
currentPage | number | Yes | The current page of the order history list. The default value is 1. |
Events
Section titled “Events”Does not emit any drop-in events.
Returns
Section titled “Returns”Returns OrderHistoryModel or null.
getRegions
Section titled “getRegions”The getRegions function calls the country query to retrieve a list of states or provinces for a specific country.
const getRegions = async ( countryCode: string): Promise<RegionTransform[] | []>| Parameter | Type | Req? | Description |
|---|---|---|---|
countryCode | string | Yes | A two-letter ISO country code. |
Events
Section titled “Events”Does not emit any drop-in events.
Returns
Section titled “Returns”Returns RegionTransform[] | []. See RegionTransform.
getStoreConfig
Section titled “getStoreConfig”The getStoreConfig function calls the storeConfig query to retrieve details about password requirements. The response also includes the seller-assisted buying fields that control whether the feature is active and customize the consent checkbox shown to customers.
const getStoreConfig = async (): Promise<StoreConfigModel>Events
Section titled “Events”Does not emit any drop-in events.
Returns
Section titled “Returns”Returns StoreConfigModel.
removeCustomerAddress
Section titled “removeCustomerAddress”The removeCustomerAddress function removes an address associated with the current customer. The function calls the deleteCustomerAddress mutation.
const removeCustomerAddress = async ( addressId: number): Promise<boolean>| Parameter | Type | Req? | Description |
|---|---|---|---|
addressId | number | Yes | An internal ID for the address. |
Events
Section titled “Events”Does not emit any drop-in events.
Returns
Section titled “Returns”Returns boolean.
setDefaultCompanyAddress
Section titled “setDefaultCompanyAddress”The setDefaultCompanyAddress function sets a company address as the default. Pass the ID of the address to set as the default.
const setDefaultCompanyAddress = async ( id: string): Promise<SetDefaultCompanyAddressResult>| Parameter | Type | Req? | Description |
|---|---|---|---|
id | string | Yes | The ID of the company address to set as the default. |
Events
Section titled “Events”Does not emit any drop-in events.
Returns
Section titled “Returns”Returns a CompanyAddressModel for the updated company address.
updateCompanyAddress
Section titled “updateCompanyAddress”The updateCompanyAddress function updates a company address in the company address book. Pass the address ID and the updated CustomerAddressesModel values.
const updateCompanyAddress = async ( id: string, input: CustomerAddressesModel): Promise<UpdateCompanyAddressResult>| Parameter | Type | Req? | Description |
|---|---|---|---|
id | string | Yes | The ID of the company address to update. |
input | CustomerAddressesModel | Yes | The updated company address details. |
Events
Section titled “Events”Does not emit any drop-in events.
Returns
Section titled “Returns”Returns a CompanyAddressModel for the updated company address.
updateCustomer
Section titled “updateCustomer”The updateCustomer function updates the logged-in customer. The function calls the updateCustomerV2 mutation.
The form object keys are converted to snake_case using the convertKeysCase utility with specific mappings for firstName, lastName, middleName, and custom_attributesV2.
const updateCustomer = async ( form: Record<string, string>): Promise<string>| Parameter | Type | Req? | Description |
|---|---|---|---|
form | Record<string, string> | Yes | The customer attributes to update, such as firstName, lastName, email, date of birth, and custom attributes. |
Events
Section titled “Events”Does not emit any drop-in events.
Returns
Section titled “Returns”Returns string.
updateCustomerAddress
Section titled “updateCustomerAddress”The updateCustomerAddress function updates an address associated with the current customer. The function calls the updateCustomerAddress mutation.
The forms object includes an addressId (the ID of the address to update) and other address details as defined in CustomerAddressesModel.
const updateCustomerAddress = async ( forms: ExtendedAddressFormProps): Promise<string>| Parameter | Type | Req? | Description |
|---|---|---|---|
forms | ExtendedAddressFormProps | Yes | The addressId and address attributes to update, such as street, city, region, country, and postal code. |
Events
Section titled “Events”Does not emit any drop-in events.
Returns
Section titled “Returns”Returns string.
updateCustomerEmail
Section titled “updateCustomerEmail”The updateCustomerEmail function updates the email address of the logged-in customer. The function calls the updateCustomerEmail mutation.
const updateCustomerEmail = async ( { email, password, }: { email: string; password: string; }): Promise<string>| Parameter | Type | Req? | Description |
|---|---|---|---|
email | string | Yes | The new email address. |
password | string | Yes | The customer’s current password (used to verify the change). |
Events
Section titled “Events”Does not emit any drop-in events.
Returns
Section titled “Returns”Returns string.
updateCustomerPassword
Section titled “updateCustomerPassword”The updateCustomerPassword function updates the password of the logged-in customer. The function calls the changeCustomerPassword mutation.
const updateCustomerPassword = async ( { currentPassword, newPassword, }: ChangeCustomerPasswordProps): Promise<string>| Parameter | Type | Req? | Description |
|---|---|---|---|
currentPassword | string | Yes | The customer’s current password. |
newPassword | string | Yes | The new password. |
Events
Section titled “Events”Does not emit any drop-in events.
Returns
Section titled “Returns”Returns string.
Data Models
Section titled “Data Models”The following data models are used by functions in this drop-in.
Country
Section titled “Country”The Country object is returned by the following functions: getCountries.
type Country = { value: string; text: string; availableRegions?: { id: number; code: string; name: string; }[];};CustomerAddressesModel
Section titled “CustomerAddressesModel”The CustomerAddressesModel object is returned by the following functions: getCustomerAddress.
interface CustomerAddressesModel { firstName?: string; lastName?: string; city?: string; company?: string; countryCode?: string; region?: { region: string; regionCode: string; regionId: string | number }; telephone?: string; id?: string; vatId?: string; postcode?: string; street?: string; streetMultiline_2?: string; defaultShipping?: boolean; defaultBilling?: boolean; uid?: string;}CustomerDataModelShort
Section titled “CustomerDataModelShort”The CustomerDataModelShort object is returned by the following functions: getCustomer.
interface CustomerDataModelShort { firstName: string; lastName: string; middleName: string; dateOfBirth: string; prefix: string; gender: 1 | 2 | string; suffix: string; email: string; createdAt: string; [key: string]: string | boolean | number;}OrderHistoryModel
Section titled “OrderHistoryModel”The OrderHistoryModel object is returned by the following functions: getOrderHistoryList.
interface OrderHistoryModel { items: OrderDetails[]; pageInfo: PaginationInfo; totalCount: number; dateOfFirstOrder: string;}RegionTransform
Section titled “RegionTransform”The RegionTransform object is returned by the following functions: getRegions.
interface RegionTransform { text: string; value: string; id?: string | number;}StoreConfigModel
Section titled “StoreConfigModel”The StoreConfigModel object is returned by the following functions: getStoreConfig.
interface StoreConfigModel { baseMediaUrl: string; minLength: number; requiredCharacterClasses: number; storeCode: string; shoppingAssistanceEnabled: boolean; shoppingAssistanceCheckboxTitle: string; shoppingAssistanceCheckboxTooltip: string;}The seller-assisted buying fields:
| Field | Type | Description |
|---|---|---|
shoppingAssistanceEnabled | boolean | true when seller-assisted buying is enabled at the store level. Controlled by the Enable Extension setting in the Admin. The seller-assisted buying containers use this value to show or hide feature content. |
shoppingAssistanceCheckboxTitle | string | Label for the consent checkbox. Set by the Title for Login as Customer opt-in checkbox field in the Admin. Falls back to the dictionary value when not configured. |
shoppingAssistanceCheckboxTooltip | string | Tooltip text for the consent checkbox. Set by the Login as Customer checkbox tooltip field in the Admin. Falls back to the dictionary value when not configured. |
AdminAssistanceActions
Section titled “AdminAssistanceActions”The AdminAssistanceActions object is returned by the following functions: getAdminAssistanceActions.
interface AdminAssistanceActions { totalCount: number; items: AdminAssistanceAction[]; pageInfo: AdminAssistanceActionsPageInfo;}AdminAssistanceAction
Section titled “AdminAssistanceAction”Each item in the items array. The action field contains one of the action type keys defined for seller-assisted buying. See the User Account dictionary for the full list of action type keys and their default labels.
interface AdminAssistanceAction { action: string; date: string; details: string;}AdminAssistanceActionsPageInfo
Section titled “AdminAssistanceActionsPageInfo”interface AdminAssistanceActionsPageInfo { currentPage: number; pageSize: number; totalPages: number;}StoredPaymentMethodDisplay
Section titled “StoredPaymentMethodDisplay”The StoredPaymentMethodDisplay object is returned as list items by getCustomerPaymentTokens. The same shape is also used as the typed payload for the account/customerPaymentTokens event when injecting a list via the event bus (see Events). It aligns with the PaymentMethods / PaymentCard view model and includes publicHash for keys and for use with deletePaymentToken.
type StoredPaymentMethodDisplay = { publicHash: string; cardBrand: string; lastFourDigits: string; expired?: boolean; variant?: 'secondary' | 'primary';};