Skip to content

Search is only available in production builds. Try building and previewing the site to test it out locally.

Company Management Functions

The Company Management drop-in provides 26 API functions for managing company structures, users, roles, permissions, and credit, enabling complete B2B company administration workflows.

Version: 1.0.0-beta27
FunctionDescription
acceptCompanyInvitationAccepts a company invitation using the invitation code and user details from an email link..
allowCompanyRegistrationReturn whether the backend allows company self-registration per store configuration..
checkCompanyCreditEnabledChecks whether the Company Credit functionality (“Payment on Account”) is enabled for the logged-in customer’s company..
companyEnabledReturn whether the Company feature is enabled in store configuration..
createCompanyAPI function for the drop-in..
createCompanyRoleAPI function for the drop-in..
createCompanyTeamCreates a new company team under an optional target structure node..
createCompanyUserCreates a new company user and optionally places them under a target structure node..
deleteCompanyRoleAPI function for the drop-in..
deleteCompanyTeamDeletes a company team by entity ID..
deleteCompanyUser⚠️ IMPORTANT: This function unassigns the user from the company and should NOT be used for removing users from the Company Structure tree..
fetchUserPermissionsAPI function retrieves the current user’s role permissions and returns both the flattened permission IDs and the raw role response.
getCompanyRetrieves complete information about the current company including name, structure, settings, and metadata.
getCompanyAclResourcesAPI function for the drop-in..
getCompanyCreditRetrieves the company’s credit information including available credit, credit limit, outstanding balance, and currency.
getCompanyCreditHistoryAPI function for the drop-in..
getCompanyRoleAPI function for the drop-in..
getCompanyRolesAPI function for the drop-in..
getCompanyStructureRetrieves the hierarchical organization structure of the company including all teams, divisions, and reporting relationships.
getCompanyTeamFetches details for a single company team by entity ID..
getCompanyUserFetches details for a single company user by entity ID..
getCompanyUsersFetches the list of company users with their roles and team information, supporting pagination and status filtering..
getCountries## Overview..
getCustomerCompanyFetches simplified customer company information for display on the customer account information page.
getStoreConfigAPI function for the drop-in..
initializeInitializes the Company drop-in with optional language definitions and data model metadata..
isCompanyAdminCheck if the current authenticated customer is a company administrator in any company..
isCompanyRoleNameAvailableAPI function for the drop-in..
isCompanyUserCheck if the current authenticated customer belongs to any company..
isCompanyUserEmailAvailableAPI function for the drop-in..
updateCompanyAPI function for the drop-in..
updateCompanyRoleAPI function for the drop-in..
updateCompanyStructureMoves a structure node under a new parent in the company structure tree..
updateCompanyTeamUpdates a company team’s name and/or description..
updateCompanyUserUpdates company user fields such as name, email, telephone, role, and status..
updateCompanyUserStatusUpdates a company user’s status between Active and Inactive with automatic base64 encoding..
validateCompanyEmailValidates if a company email is available..

acceptCompanyInvitation

Accepts a company invitation using the invitation code and user details from an email link.

const acceptCompanyInvitation = async (
input: AcceptCompanyInvitationInput
): Promise<any>
ParameterTypeReq?Description
inputAcceptCompanyInvitationInputYesInput parameters for the operation.

Events

Does not emit any drop-in events.

Returns

Returns void.

allowCompanyRegistration

Return whether the backend allows company self-registration per store configuration.

const allowCompanyRegistration = async (): Promise<boolean>

Events

Does not emit any drop-in events.

Returns

Returns boolean.

checkCompanyCreditEnabled

Checks whether the Company Credit functionality (“Payment on Account”) is enabled for the logged-in customer’s company.

const checkCompanyCreditEnabled = async (): Promise<CheckCompanyCreditEnabledResponse>

Events

Does not emit any drop-in events.

Returns

Returns CheckCompanyCreditEnabledResponse.

companyEnabled

Return whether the Company feature is enabled in store configuration.

const companyEnabled = async (): Promise<boolean>

Events

Does not emit any drop-in events.

Returns

Returns boolean.

createCompany

const createCompany = async (
formData: any
): Promise<{ success: boolean; company?: CompanyRegistrationModel; errors?: string[] }>
ParameterTypeReq?Description
formDataanyYesAn object containing the company registration information including company name, legal name, email, VAT/TAX ID, and resale number. The structure depends on your store’s company registration requirements.

Events

Does not emit any drop-in events.

Returns

{ success: boolean; company?: CompanyRegistrationModel; errors?: string[] }

See CompanyRegistrationModel.

createCompanyRole

Signature

function createCompanyRole(input: CompanyRoleCreateInputModel): Promise<CompanyRoleModel>

Parameters

ParameterTypeRequiredDescription
inputCompanyRoleCreateInputModelYes

createCompanyTeam

Creates a new company team under an optional target structure node.

const createCompanyTeam = async (
input: CreateCompanyTeamInput
): Promise<any>
ParameterTypeReq?Description
inputCreateCompanyTeamInputYesInput parameters for the operation.

Events

Does not emit any drop-in events.

Returns

Returns void.

createCompanyUser

Creates a new company user and optionally places them under a target structure node.

const createCompanyUser = async (
input: CreateCompanyUserInput
): Promise<any>
ParameterTypeReq?Description
inputCreateCompanyUserInputYesInput parameters for the operation.

Events

Does not emit any drop-in events.

Returns

Returns void.

deleteCompanyRole

Signature

function deleteCompanyRole(variables: DeleteCompanyRoleVariables): Promise<boolean>

Parameters

ParameterTypeRequiredDescription
variablesDeleteCompanyRoleVariablesYesAn object of type DeleteCompanyRoleVariables containing the role ID to delete. See the type definition for the exact structure.

deleteCompanyTeam

Deletes a company team by entity ID.

const deleteCompanyTeam = async (
id: string
): Promise<any>
ParameterTypeReq?Description
idstringYesThe unique identifier for the company team (structure node) to delete. This removes the team and may reassign team members depending on your company’s configuration.

Events

Does not emit any drop-in events.

Returns

Returns void.

deleteCompanyUser

⚠️ IMPORTANT: This function unassigns the user from the company and should NOT be used for removing users from the Company Structure tree.

const deleteCompanyUser = async (
params: DeleteCompanyUserParams
): Promise<DeleteCompanyUserResponse>
ParameterTypeReq?Description
paramsDeleteCompanyUserParamsYesAn object of type `DeleteCompanyUserParams` containing the user ID to delete and any additional parameters required for user deletion.

Events

Does not emit any drop-in events.

Returns

Returns DeleteCompanyUserResponse.

fetchUserPermissions

The fetchUserPermissions API function retrieves the current user’s role permissions and returns both the flattened permission IDs and the raw role response. This function is used internally by other API functions to determine what data the user can access.

const fetchUserPermissions = async (): Promise<any>

Events

Does not emit any drop-in events.

Returns

Returns void.

getCompany

Retrieves complete information about the current company including name, structure, settings, and metadata. Returns the full company profile for the authenticated user’s company context.

const getCompany = async (): Promise<any>

Events

Does not emit any drop-in events.

Returns

Returns a Promise that resolves to a CompanyModel object containing comprehensive company details.

getCompanyAclResources

const getCompanyAclResources = async (): Promise<CompanyAclResourceModel[]>

Events

Does not emit any drop-in events.

Returns

Returns an array of CompanyAclResourceModel objects.

getCompanyCredit

Retrieves the company’s credit information including available credit, credit limit, outstanding balance, and currency. This is used to display company credit status and validate purchase limits.

const getCompanyCredit = async (): Promise<CompanyCreditInfo | null>

Events

Does not emit any drop-in events.

Returns

Returns CompanyCreditInfo or null.

getCompanyCreditHistory

const getCompanyCreditHistory = async (
params: GetCompanyCreditHistoryParams = {}
): Promise<CompanyCreditHistory | null>
ParameterTypeReq?Description
paramsGetCompanyCreditHistoryParamsNoAn optional object of type `GetCompanyCreditHistoryParams` containing pagination parameters (currentPage, pageSize) and optional filters. Omit to retrieve history with default pagination.

Events

Does not emit any drop-in events.

Returns

Returns CompanyCreditHistory or null.

getCompanyRole

Signature

function getCompanyRole(variables: GetCompanyRoleVariables): Promise<CompanyRoleModel>

Parameters

ParameterTypeRequiredDescription
variablesGetCompanyRoleVariablesYesAn object of type GetCompanyRoleVariables containing the role ID to retrieve. Returns complete role details including permissions and assigned users.

getCompanyRoles

Signature

function getCompanyRoles(variables: GetCompanyRolesVariables = {}): Promise<CompanyRolesResponseModel>

Parameters

ParameterTypeRequiredDescription
variablesGetCompanyRolesVariables = {}YesAn optional object of type GetCompanyRolesVariables containing pagination and filter parameters. Omit to retrieve all company roles with default pagination.

getCompanyStructure

Retrieves the hierarchical organization structure of the company including all teams, divisions, and reporting relationships. Returns the complete company tree structure.

const getCompanyStructure = async (): Promise<any>

Events

Does not emit any drop-in events.

Returns

Returns a Promise that resolves to a CompanyStructureModel object representing the organizational hierarchy.

getCompanyTeam

Fetches details for a single company team by entity ID.

const getCompanyTeam = async (
id: string
): Promise<any>
ParameterTypeReq?Description
idstringYesThe unique identifier for the company team to retrieve. Returns detailed information about the team including its name, members, and position in the company hierarchy.

Events

Does not emit any drop-in events.

Returns

Returns void.

getCompanyUser

Fetches details for a single company user by entity ID.

const getCompanyUser = async (
id: string
): Promise<any>
ParameterTypeReq?Description
idstringYesThe unique identifier for the company user to retrieve. Returns complete user profile including role, team assignment, and permissions.

Events

Does not emit any drop-in events.

Returns

Returns void.

getCompanyUsers

Fetches the list of company users with their roles and team information, supporting pagination and status filtering.

const getCompanyUsers = async (
params: CompanyUsersParams = {}
): Promise<CompanyUsersResponse>
ParameterTypeReq?Description
paramsCompanyUsersParamsNoAn optional object of type `CompanyUsersParams` containing pagination and filter criteria (currentPage, pageSize, filter). Omit to retrieve all users with default pagination.

Events

Does not emit any drop-in events.

Returns

Returns CompanyUsersResponse.

getCountries

Overview

const getCountries = async (): Promise<{
availableCountries: Country[] | [];
countriesWithRequiredRegion: string[];
optionalZipCountries: string[];
}>

Events

Does not emit any drop-in events.

Returns

Promise<{
availableCountries: Country[] | [];
countriesWithRequiredRegion: string[];
optionalZipCountries: string[];
}>

See Country.

getCustomerCompany

Fetches simplified customer company information for display on the customer account information page. This is a lightweight API that only returns essential company details without requiring full company management permissions.

const getCustomerCompany = async (): Promise<any>

Events

Does not emit any drop-in events.

Returns

Returns void.

getStoreConfig

const getStoreConfig = async (): Promise<StoreConfigModel>

Events

Does not emit any drop-in events.

Returns

Returns StoreConfigModel.

initialize

Initializes the Company drop-in with optional language definitions and data model metadata.

const initialize = async (
config: CompanyDropinConfig = {}
): Promise<any>
ParameterTypeReq?Description
configCompanyDropinConfigNoAn optional configuration object of type `CompanyDropinConfig` containing initialization settings such as langDefinitions for internationalization. If omitted, default configuration is used.

Events

Does not emit any drop-in events.

Returns

Returns void.

isCompanyAdmin

Check if the current authenticated customer is a company administrator in any company.

const isCompanyAdmin = async (): Promise<boolean>

Events

Does not emit any drop-in events.

Returns

Returns boolean.

isCompanyRoleNameAvailable

Signature

function isCompanyRoleNameAvailable(variables: IsCompanyRoleNameAvailableVariables): Promise<boolean>

Parameters

ParameterTypeRequiredDescription
variablesIsCompanyRoleNameAvailableVariablesYesAn object of type IsCompanyRoleNameAvailableVariables containing the role name to check for availability. Returns a boolean indicating whether the name can be used for a new role.

isCompanyUser

Check if the current authenticated customer belongs to any company.

const isCompanyUser = async (): Promise<boolean>

Events

Does not emit any drop-in events.

Returns

Returns boolean.

isCompanyUserEmailAvailable

const isCompanyUserEmailAvailable = async (
email: string
): Promise<any>
ParameterTypeReq?Description
emailstringYesThe email address.

Events

Does not emit any drop-in events.

Returns

Returns void.

updateCompany

const updateCompany = async (
input: UpdateCompanyDto
): Promise<CompanyModel>
ParameterTypeReq?Description
inputUpdateCompanyDtoYesInput parameters for the operation.

Events

Does not emit any drop-in events.

Returns

Returns CompanyModel.

updateCompanyRole

Signature

function updateCompanyRole(input: CompanyRoleUpdateInputModel): Promise<CompanyRoleModel>

Parameters

ParameterTypeRequiredDescription
inputCompanyRoleUpdateInputModelYes

updateCompanyStructure

Moves a structure node under a new parent in the company structure tree.

const updateCompanyStructure = async (
input: UpdateCompanyStructureInput
): Promise<any>
ParameterTypeReq?Description
inputUpdateCompanyStructureInputYesInput parameters for the operation.

Events

Does not emit any drop-in events.

Returns

Returns void.

updateCompanyTeam

Updates a company team’s name and/or description.

const updateCompanyTeam = async (
input: UpdateCompanyTeamInput
): Promise<any>
ParameterTypeReq?Description
inputUpdateCompanyTeamInputYesInput parameters for the operation.

Events

Does not emit any drop-in events.

Returns

Returns void.

updateCompanyUser

Updates company user fields such as name, email, telephone, role, and status.

const updateCompanyUser = async (
input: UpdateCompanyUserInput
): Promise<any>
ParameterTypeReq?Description
inputUpdateCompanyUserInputYesInput parameters for the operation.

Events

Does not emit any drop-in events.

Returns

Returns void.

updateCompanyUserStatus

Updates a company user’s status between Active and Inactive with automatic base64 encoding.

const updateCompanyUserStatus = async (
params: UpdateCompanyUserStatusParams
): Promise<UpdateCompanyUserStatusResponse>
ParameterTypeReq?Description
paramsUpdateCompanyUserStatusParamsYesAn object of type `UpdateCompanyUserStatusParams` containing the user ID and the new status value (active, inactive). Used to enable or disable user access to company resources.

Events

Does not emit any drop-in events.

Returns

Returns UpdateCompanyUserStatusResponse.

validateCompanyEmail

Validates if a company email is available.

const validateCompanyEmail = async (
email: string
): Promise<ValidateCompanyEmailResponse>
ParameterTypeReq?Description
emailstringYesThe email address.

Events

Does not emit any drop-in events.

Returns

Returns ValidateCompanyEmailResponse.

Data Models

The following data models are used by functions in this drop-in.

CheckCompanyCreditEnabledResponse

The CheckCompanyCreditEnabledResponse object is returned by the following functions: checkCompanyCreditEnabled.

interface CheckCompanyCreditEnabledResponse {
creditEnabled: boolean;
error?: string;
}

CompanyAclResourceModel

The CompanyAclResourceModel object is returned by the following functions: getCompanyAclResources.

interface CompanyAclResourceModel {
id: string;
text: string;
sortOrder: number;
children?: CompanyAclResourceModel[];
}

CompanyCreditHistory

The CompanyCreditHistory object is returned by the following functions: getCompanyCreditHistory.

interface CompanyCreditHistory {
items: CompanyCreditHistoryItem[];
pageInfo: CompanyCreditHistoryPageInfo;
totalCount: number;
}

CompanyCreditInfo

The CompanyCreditInfo object is returned by the following functions: getCompanyCredit.

interface CompanyCreditInfo {
credit: {
available_credit: {
currency: string;
value: number;
};
credit_limit: {
currency: string;
value: number;
};
outstanding_balance: {
currency: string;
value: number;
};
};
}

CompanyRegistrationModel

The CompanyRegistrationModel object is returned by the following functions: createCompany.

interface CompanyRegistrationModel {
id: string;
name: string;
email: string;
legalName?: string;
vatTaxId?: string;
resellerId?: string;
legalAddress: {
street: string[];
city: string;
region: {
regionCode: string;
region?: string;
regionId?: number;
};
postcode: string;
countryCode: string;
telephone?: string;
};
companyAdmin: {
id: string;
firstname: string;
lastname: string;
email: string;
jobTitle?: string;
telephone?: string;
};
}

CompanyRoleModel

The CompanyRoleModel object is returned by the following functions: createCompanyRole, getCompanyRole, updateCompanyRole.

interface CompanyRoleModel {
id: string;
name: string;
usersCount: number;
permissions: CompanyAclResourceModel[];
}

CompanyRolesResponseModel

The CompanyRolesResponseModel object is returned by the following functions: getCompanyRoles.

interface CompanyRolesResponseModel {
items: CompanyRoleModel[];
totalCount: number;
pageInfo: PageInfoModel;
}

CompanyUsersResponse

The CompanyUsersResponse object is returned by the following functions: getCompanyUsers.

interface CompanyUsersResponse {
users: CompanyUser[];
pageInfo: CompanyUsersPageInfo;
totalCount?: number;
}

Country

The Country object is returned by the following functions: getCountries.

type Country = {
value: string;
text: string;
availableRegions?: {
id: number;
code: string;
name: string;
}[];
};

DeleteCompanyUserResponse

The DeleteCompanyUserResponse object is returned by the following functions: deleteCompanyUser.

interface DeleteCompanyUserResponse {
success: boolean;
}

StoreConfigModel

The StoreConfigModel object is returned by the following functions: getStoreConfig.

interface StoreConfigModel {
defaultCountry: string;
storeCode: string;
}

UpdateCompanyUserStatusResponse

The UpdateCompanyUserStatusResponse object is returned by the following functions: updateCompanyUserStatus.

interface UpdateCompanyUserStatusResponse {
success: boolean;
user?: {
id: string;
status: CompanyUserStatus;
};
}

ValidateCompanyEmailResponse

The ValidateCompanyEmailResponse object is returned by the following functions: validateCompanyEmail.

interface ValidateCompanyEmailResponse {
isValid: boolean;
error?: string;
}