B2B for Adobe Commerce only. Learn more.

updateCompanyUser mutation

Use the updateCompanyUser mutation to update an existing company user.

You can get the user ID and role ID with the company query.

Syntax

1
2
3
4
5
6
7
mutation {
    updateCompanyUser(
        input: CompanyUserUpdateInput!
    ) {
        UpdateCompanyUserOutput
    }
}

Example usage

The following example changes the job title of the specified company user.

Request:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
mutation {
  updateCompanyUser(
    input: {
      id: "Mg=="
      job_title: "Company User"
    }
  ) {
    user {
      email
      firstname
      lastname
      job_title
      telephone
      status
      role {
        id
        name
        users_count
      }
    }
  }
}

Response:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{
  "data": {
    "updateCompanyUser": {
      "user": {
        "email": "jane.doe@example.com",
        "firstname": "Jane",
        "lastname": "Doe",
        "job_title": "Company User",
        "telephone": "1234567890",
        "status": "ACTIVE",
        "role": {
          "id": "MQ==",
          "name": "Default User",
          "users_count": 1
        }
      }
    }
  }
}

This example deactivates the company user and assigns a different role.

Request:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
mutation {
  updateCompanyUser(
    input: {
      id: "Mg=="
      role_id: "MQ=="
      status: INACTIVE
    }
  ) {
    user {
      email
      firstname
      lastname
      job_title
      telephone
      status
      role {
        id
        name
        users_count
      }
    }
  }
}

Response:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{
  "data": {
    "updateCompanyUser": {
      "user": {
        "email": "jane.doe@example.com",
        "firstname": "Jane",
        "lastname": "Doe",
        "job_title": "Company User",
        "telephone": "1234567890",
        "status": "INACTIVE",
        "role": {
          "id": "MQ==",
          "name": "Default User",
          "users_count": 1
        }
      }
    }
  }
}

Input attributes

The CompanyUserUpdateInput input object defines the company user data.

CompanyUserUpdateInput attributes

The CompanyUserUpdateInput object contains the following attributes:

Attribute Data Type Description
email String The company user’s email address
firstname String The company user’s first name
id ID! The encoded user ID of the company user to be updated
job_title String The company user’s job title or function
lastname String The company user’s last name
role_id ID The ID of the role assigned to the company user
status CompanyUserStatusEnum Indicates whether the company user is ACTIVE or INACTIVE
telephone String The company user’s phone number

Output attributes

The UpdateCompanyUserOutput output object contains the following attribute:

Attribute Data Type Description
user Customer! Contains company user data

Customer attributes

Attribute Data Type Description
addresses CustomerAddress An array containing the customer’s shipping and billing addresses
allow_remote_shopping_assistance Boolean! Indicates whether the customer has enabled remote shopping assistance
compare_list CompareList The contents of the customer’s comparison list
created_at String Timestamp indicating when the account was created
date_of_birth String The customer’s date of birth. In keeping with current security and privacy best practices, be sure you are aware of any potential legal and security risks associated with the storage of customers’ full date of birth (month, day, year) along with other personal identifiers, such as full name, before collecting or processing such data.
default_billing String The ID assigned to the billing address
default_shipping String The ID assigned to the shipping address
dob String Deprecated. Use date_of_birth instead. The customer’s date of birth
email String The customer’s email address
firstname String The customer’s first name
gender Int The customer’s gender (Male - 1, Female - 2)
group_id Int Deprecated. This attribute is not applicable for GraphQL. The group assigned to the user. Default values are 0 (Not logged in), 1 (General), 2 (Wholesale), and 3 (Retailer)
id Int Deprecated. This attribute is not applicable for GraphQL. The ID assigned to the customer
is_subscribed Boolean Indicates whether the customer is subscribed to the company’s newsletter
lastname String The customer’s family name
middlename String The customer’s middle name
orders(filter CustomerOrdersFilterInput, currentPage = 1 Int, pageSize = 20 Int) [CustomerOrders] A list of the customer’s placed orders
prefix String An honorific, such as Dr., Mr., or Mrs.
return(uid: ID!) Return Gets details about the specified return request
returns(pageSize: Int = 20 currentPage: Int = 1) Returns Information about the customer’s return requests
reviews(pageSize: Int = 20 currentPage: Int = 1) ProductReviews! The list of reviews of the product
reward_points [RewardPoints] Details about the customer’s reward points
suffix String A value such as Sr., Jr., or III
taxvat String The customer’s Tax/VAT number (for corporate customers)
wishlist Wishlist! Deprecated. Use wishlist_v2 instead. Contains the contents of the customer’s wish lists
wishlist_v2(id ID!) [Wishlist]! Retrieve the specified wish list identified by the unique ID for a Wishlist object

For B2B, company administrators and users can have the following attributes.

Attribute Data Type Description
job_title String The job title for a B2B company user
requisition_lists (pageSize = 20 Int, currentPage = 1 Int, filter RequisitionListFilterInput) RequisitionLists Contains the customer’s requisition lists
role CompanyRole The role name and permissions assigned to the company user
status CompanyUserStatusEnum Indicates whether the company user is ACTIVE or INACTIVE
team CompanyTeam The team the company user is assigned to
telephone String The phone number of the company user

Errors

Error Description
You do not have authorization to perform this action. The user with the ID provided in the input.id argument is not assigned to your company.
No such entity with roleId = xxx The company role with ID xxx doesn’t exist.
A customer with the same email address already exists in an associated website The email provided in the input.email argument belongs to another user.