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.
| Function | Description |
|---|---|
acceptCompanyInvitation | Accepts a company invitation using the invitation code and user details from an email link. |
allowCompanyRegistration | Returns whether the backend allows company self-registration per store configuration. |
checkCompanyCreditEnabled | Checks whether the Company Credit functionality (“Payment on Account”) is enabled for the logged-in customer’s company. |
companyEnabled | Returns whether the Company feature is enabled in store configuration. |
createCompany | Registers a new B2B company with complete business information including company details, legal address, and administrator account. |
createCompanyRole | Creates a new company role with specified permissions and assigns it to users. |
createCompanyTeam | Creates a new company team under an optional target structure node. |
createCompanyUser | Creates a new company user and optionally places them under a target structure node. |
deleteCompanyRole | Deletes a company role by ID and unassigns users from the deleted role. |
deleteCompanyTeam | Deletes a company team by entity ID. |
deleteCompanyUser | Unassigns the user from the company (does not remove from Company Structure tree). |
fetchUserPermissions | API function retrieves the current user’s role permissions and returns both the flattened permission IDs and the raw role response. |
getCompany | Retrieves complete information about the current company including name, structure, settings, and metadata. |
getCompanyAclResources | Retrieves the available ACL (Access Control List) resources for company role permissions. |
getCompanyCredit | Retrieves the company’s credit information including available credit, credit limit, outstanding balance, and currency. |
getCompanyCreditHistory | Retrieves the company’s credit transaction history with pagination support. |
getCompanyRole | Retrieves details for a single company role including permissions and assigned users. |
getCompanyRoles | Retrieves all company roles with their permissions and user assignments. |
getCompanyStructure | Retrieves the hierarchical organization structure of the company including all teams, divisions, and reporting relationships. |
getCompanyTeam | Fetches details for a single company team by entity ID. |
getCompanyUser | Fetches details for a single company user by entity ID. |
getCompanyUsers | Fetches the list of company users with their roles and team information, supporting pagination and status filtering. |
getCountries | Retrieves available countries and regions for address forms. |
getCustomerCompany | Fetches simplified customer company information for display on the customer account information page. |
getStoreConfig | Retrieves store configuration settings relevant to company management. |
initialize | Initializes the Company drop-in with optional language definitions and data model metadata. |
isCompanyAdmin | Checks if the current authenticated customer is a company administrator in any company. |
isCompanyRoleNameAvailable | Checks if a role name is available for use in the company. |
isCompanyUser | Checks if the current authenticated customer belongs to any company. |
isCompanyUserEmailAvailable | Checks if an email address is available for a new company user. |
updateCompany | Updates company profile information with permission-aware field filtering based on user’s edit permissions. |
updateCompanyRole | Updates an existing company role’s name, permissions, or assigned users. |
updateCompanyStructure | Moves a structure node under a new parent in the company structure tree. |
updateCompanyTeam | Updates a company team’s name and/or description. |
updateCompanyUser | Updates company user fields such as name, email, telephone, role, and status. |
updateCompanyUserStatus | Updates a company user’s status between Active and Inactive with automatic base64 encoding. |
validateCompanyEmail | Validates 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>| Parameter | Type | Req? | Description |
|---|---|---|---|
input | AcceptCompanyInvitationInput | Yes | Input 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[] }>| Parameter | Type | Req? | Description |
|---|---|---|---|
formData | CompanyCreateInput | Yes | Company 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.
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>| Parameter | Type | Req? | Description |
|---|---|---|---|
input | CompanyRoleCreateInputModel | Yes | Role 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>| Parameter | Type | Req? | Description |
|---|---|---|---|
input | CreateCompanyTeamInput | Yes | Input 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>| Parameter | Type | Req? | Description |
|---|---|---|---|
input | CreateCompanyUserInput | Yes | Input 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>| Parameter | Type | Req? | Description |
|---|---|---|---|
variables | DeleteCompanyRoleVariables | Yes | Delete 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>| Parameter | Type | Req? | Description |
|---|---|---|---|
id | string | Yes | The 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>| Parameter | Type | Req? | Description |
|---|---|---|---|
params | DeleteCompanyUserParams | Yes | An 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>| Parameter | Type | Req? | Description |
|---|---|---|---|
params | GetCompanyCreditHistoryParams | No | An 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 detailsMagento_Company::roles_edit- To modify the role (additional permission)
function getCompanyRole(variables: GetCompanyRoleVariables): Promise<CompanyRoleModel>| Parameter | Type | Req? | Description |
|---|---|---|---|
variables | GetCompanyRoleVariables | Yes | Query 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>| Parameter | Type | Req? | Description |
|---|---|---|---|
variables | GetCompanyRolesVariables | No | Optional 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>| Parameter | Type | Req? | Description |
|---|---|---|---|
id | string | Yes | The 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>| Parameter | Type | Req? | Description |
|---|---|---|---|
id | string | Yes | The 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>| Parameter | Type | Req? | Description |
|---|---|---|---|
params | CompanyUsersParams | No | An 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>| Parameter | Type | Req? | Description |
|---|---|---|---|
config | CompanyDropinConfig | No | An 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>| Parameter | Type | Req? | Description |
|---|---|---|---|
variables | IsCompanyRoleNameAvailableVariables | Yes | Validation 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>| Parameter | Type | Req? | Description |
|---|---|---|---|
email | string | Yes | The 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 IDMagento_Company::edit_address- To update legal address fields
const updateCompany = async ( input: UpdateCompanyDto): Promise<CompanyModel>| Parameter | Type | Req? | Description |
|---|---|---|---|
input | UpdateCompanyDto | Yes | Partial 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>| Parameter | Type | Req? | Description |
|---|---|---|---|
input | CompanyRoleUpdateInputModel | Yes | Role 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>| Parameter | Type | Req? | Description |
|---|---|---|---|
input | UpdateCompanyStructureInput | Yes | Input 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>| Parameter | Type | Req? | Description |
|---|---|---|---|
input | UpdateCompanyTeamInput | Yes | Input 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>| Parameter | Type | Req? | Description |
|---|---|---|---|
input | UpdateCompanyUserInput | Yes | Input 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>| Parameter | Type | Req? | Description |
|---|---|---|---|
params | UpdateCompanyUserStatusParams | Yes | An 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>| Parameter | Type | Req? | Description |
|---|---|---|---|
email | string | Yes | The 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;}