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
FunctionDescription
acceptCompanyInvitationAccepts a company invitation using the invitation code and user details from an email link.
allowCompanyRegistrationReturns 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.
companyEnabledReturns whether the Company feature is enabled in store configuration.
createCompanyRegisters a new B2B company with complete business information including company details, legal address, and administrator account.
createCompanyRoleCreates a new company role with specified permissions and assigns it to users.
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.
deleteCompanyRoleDeletes a company role by ID and unassigns users from the deleted role.
deleteCompanyTeamDeletes a company team by entity ID.
deleteCompanyUserUnassigns the user from the company (does not remove from 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.
getCompanyAclResourcesRetrieves the available ACL (Access Control List) resources for company role permissions.
getCompanyCreditRetrieves the company’s credit information including available credit, credit limit, outstanding balance, and currency.
getCompanyCreditHistoryRetrieves the company’s credit transaction history with pagination support.
getCompanyRoleRetrieves details for a single company role including permissions and assigned users.
getCompanyRolesRetrieves all company roles with their permissions and user assignments.
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.
getCountriesRetrieves available countries and regions for address forms.
getCustomerCompanyFetches simplified customer company information for display on the customer account information page.
getStoreConfigRetrieves store configuration settings relevant to company management.
initializeInitializes the Company drop-in with optional language definitions and data model metadata.
isCompanyAdminChecks if the current authenticated customer is a company administrator in any company.
isCompanyRoleNameAvailableChecks if a role name is available for use in the company.
isCompanyUserChecks if the current authenticated customer belongs to any company.
isCompanyUserEmailAvailableChecks if an email address is available for a new company user.
updateCompanyUpdates company profile information with permission-aware field filtering based on user’s edit permissions.
updateCompanyRoleUpdates an existing company role’s name, permissions, or assigned users.
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

Returns 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

Returns 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

Registers a new B2B company with complete business information.

This function handles the entire company registration workflow including:

  • Company details validation (name, email, legal name, tax IDs)
  • Legal address validation with country/region support
  • Company administrator account creation
  • Email uniqueness validation
const createCompany = async (
formData: CompanyCreateInput
): Promise<{ success: boolean; company?: CompanyRegistrationModel; errors?: string[] }>
ParameterTypeReq?Description
formDataCompanyCreateInputYesCompany registration form data containing company info, legal address, and admin details. Includes: company_name, company_email, legal_name, vat_tax_id, reseller_id, legal_address (with street, city, region, postcode, country_id, telephone), and company_admin (with email, firstname, lastname, job_title, telephone, gender, custom_attributes).

Events

Does not emit any drop-in events.

Returns

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

Returns a promise resolving to registration result with success status, company data on success, or error messages on failure.

See CompanyRegistrationModel.

Example

const result = await createCompany({
company_name: 'Example Corp',
company_email: 'contact@example.com',
legal_name: 'Example Corporation Inc.',
vat_tax_id: 'VAT123456789',
legal_address: {
street: ['123 Main St', 'Suite 100'],
city: 'San Francisco',
region: { region_code: 'CA', region: 'California', region_id: 12 },
postcode: '94105',
country_id: 'US',
telephone: '+1-555-123-4567'
},
company_admin: {
email: 'admin@example.com',
firstname: 'John',
lastname: 'Doe',
job_title: 'CEO'
}
});
if (result.success) {
console.log('Company registered:', result.company);
} else {
console.error('Registration failed:', result.errors);
}

createCompanyRole

Creates a new company role with specified name and permissions.

The role name must be unique within the company. Use isCompanyRoleNameAvailable to validate name uniqueness before calling this function.

Permissions Required:

  • Magento_Company::roles_edit - User must have role management permission
function createCompanyRole(input: CompanyRoleCreateInputModel): Promise<CompanyRoleModel>
ParameterTypeReq?Description
inputCompanyRoleCreateInputModelYesRole creation data including name and permission IDs.

Events

Does not emit any drop-in events.

Returns

Returns CompanyRoleModel - The newly created role with complete details.

Example

const newRole = await createCompanyRole({
name: 'Sales Manager',
permissions: [
'Magento_Company::index',
'Magento_Company::view',
'Magento_Sales::all',
'Magento_Sales::place_order'
]
});
console.log(`Created role: ${newRole.name} (ID: ${newRole.id})`);

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

Permanently deletes a company role.

Permissions Required:

  • Magento_Company::roles_edit - User must have role management permission
function deleteCompanyRole(variables: DeleteCompanyRoleVariables): Promise<boolean>
ParameterTypeReq?Description
variablesDeleteCompanyRoleVariablesYesDelete operation parameters containing the role ID.

Events

Does not emit any drop-in events.

Returns

Returns boolean - true if deletion succeeded, false if it failed (for example, the role has users).

Example

try {
const success = await deleteCompanyRole({ id: 'cm9sZS8xMjM=' });
if (success) {
console.log('Role deleted successfully');
} else {
console.error('Cannot delete: role has assigned users');
}
} catch (error) {
console.error('Delete failed:', error.message);
}

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

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

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

Retrieves the available ACL (Access Control List) resources for company role permissions.

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

Retrieves the company’s credit transaction history with pagination support.

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

Retrieves complete details for a specific company role by ID.

Returns role name, assigned user count, and the complete permission tree structure with this role’s granted permissions. Used when editing an existing role or viewing role details.

Permissions Required:

  • Magento_Company::roles_view (minimum) - To view role details
  • Magento_Company::roles_edit - To modify the role (additional permission)
function getCompanyRole(variables: GetCompanyRoleVariables): Promise<CompanyRoleModel>
ParameterTypeReq?Description
variablesGetCompanyRoleVariablesYesQuery parameters containing the role ID.

Events

Does not emit any drop-in events.

Returns

Returns CompanyRoleModel - Complete role details including permissions.

Example

const role = await getCompanyRole({ id: 'cm9sZS8xMjM=' });
console.log(`Role: ${role.name}`);
console.log(`Users: ${role.usersCount}`);
console.log(`Permissions: ${role.permissions.length} categories`);

getCompanyRoles

Retrieves a paginated list of all company roles with basic information.

Returns roles with their names, assigned user counts, and IDs. Supports server-side pagination and filtering by role name.

Permissions Required:

  • Magento_Company::roles_view - User must have permission to view company roles
function getCompanyRoles(variables: GetCompanyRolesVariables = {}): Promise<CompanyRolesResponseModel>
ParameterTypeReq?Description
variablesGetCompanyRolesVariablesNoOptional query parameters for pagination and filtering.

Events

Does not emit any drop-in events.

Returns

Returns CompanyRolesResponseModel - Paginated roles list with metadata.

Example

const response = await getCompanyRoles({
pageSize: 20,
currentPage: 1,
filter: { name: 'Manager' }
});
console.log(`Total roles: ${response.totalCount}`);
response.items.forEach(role => {
console.log(`${role.name}: ${role.usersCount} users`);
});

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

Retrieves available countries and regions for address forms.

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

Retrieves store configuration settings relevant to company management.

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, the default configuration is used.

Events

Does not emit any drop-in events.

Returns

Returns void.

isCompanyAdmin

Checks 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

Validates whether a role name is available for use (not already taken).

Used for real-time validation during role creation and editing to prevent duplicate role names within a company. Role names are case-sensitive.

function isCompanyRoleNameAvailable(variables: IsCompanyRoleNameAvailableVariables): Promise<boolean>
ParameterTypeReq?Description
variablesIsCompanyRoleNameAvailableVariablesYesValidation parameters containing the role name to check.

Events

Does not emit any drop-in events.

Returns

Returns boolean - true if name is available, false if already in use.

Example

const isAvailable = await isCompanyRoleNameAvailable({
name: 'Sales Manager'
});
if (isAvailable) {
console.log('Name is available - can proceed with creation');
} else {
console.error('Name already exists - choose a different name');
}

isCompanyUser

Checks 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

Checks if an email address is available for a new company user.

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

Events

Does not emit any drop-in events.

Returns

Returns void.

updateCompany

Updates company profile information with permission-aware field filtering.

This function dynamically builds the GraphQL mutation based on user permissions:

  • Only requests fields the user can view in the response
  • Only sends fields the user can edit in the mutation

Permissions Required:

  • Magento_Company::edit_account - To update name, email, legal name, VAT/Tax ID, Reseller ID
  • Magento_Company::edit_address - To update legal address fields
const updateCompany = async (
input: UpdateCompanyDto
): Promise<CompanyModel>
ParameterTypeReq?Description
inputUpdateCompanyDtoYesPartial company data to update (only changed fields). Can include: name, email, legalName, vatTaxId, resellerId, and legalAddress (with street, city, region, countryCode, postcode, telephone).

Events

Emits company/updated after successful update with new company data.

Returns

Returns CompanyModel - Complete updated company object with all current data.

Example

const updated = await updateCompany({
name: 'New Company Name',
legalAddress: {
street: ['456 New St'],
city: 'Los Angeles',
region: { region: 'California', regionCode: 'CA' },
countryCode: 'US',
postcode: '90001'
}
});
// Event 'company/updated' is emitted with { company: updated }

updateCompanyRole

Updates an existing company role’s name and/or permissions.

The role name must be unique within the company (excluding the current role). Use isCompanyRoleNameAvailable to validate name uniqueness if changing the name.

Permissions Required:

  • Magento_Company::roles_edit - User must have role management permission
function updateCompanyRole(input: CompanyRoleUpdateInputModel): Promise<CompanyRoleModel>
ParameterTypeReq?Description
inputCompanyRoleUpdateInputModelYesRole update data including ID, new name, and/or new permission IDs.

Events

Does not emit any drop-in events.

Returns

Returns CompanyRoleModel - The updated role with complete details.

Example

const updatedRole = await updateCompanyRole({
id: 'cm9sZS8xMjM=',
name: 'Senior Sales Manager',
permissions: [
'Magento_Company::index',
'Magento_Company::view',
'Magento_Company::edit_account',
'Magento_Sales::all',
'Magento_Sales::place_order',
'Magento_Sales::view_orders'
]
});
console.log(`Updated role: ${updatedRole.name}`);

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 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;
}