changeCustomerPassword mutation

Use the changeCustomerPassword mutation to change the password for the logged-in customer.

To return or modify information about a customer, Magento recommends you use customer tokens in the header of your GraphQL calls. However, you also can use session authentication.

Syntax

mutation: {changeCustomerPassword(currentPassword: String! newPassword: String!) {Customer}}

Example usage

The following call updates the customer’s password.

Request:

1
2
3
4
5
6
7
8
9
mutation {
  changeCustomerPassword(
    currentPassword: "roni_cost3@example.com"
    newPassword: "roni_cost4@example.com"
  ) {
    id
    email
  }
}

Response:

1
2
3
4
5
6
7
8
{
  "data": {
    "changeCustomerPassword": {
      "id": 1,
      "email": "roni_cost@example.com"
    }
  }
}

Input attributes

The changeCustomerPassword mutation requires the following inputs:

Attribute Data Type Description
currentPassword String The customer’s current password
newPassword String The customer’s new password

Output attributes

The changeCustomerPassword mutation returns the customer object.

Attribute Data Type Description
addresses CustomerAddress An array containing the customer’s shipping and billing addresses
created_at String Timestamp indicating when the account was created
default_billing String The ID assigned to the billing address
default_shipping String The ID assigned to the shipping address
dob String 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 The group assigned to the user. Default values are 0 (Not logged in), 1 (General), 2 (Wholesale), and 3 (Retailer)
id Int 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
prefix String An honorific, such as Dr., Mr., or Mrs.
suffix String A value such as Sr., Jr., or III
taxvat String The customer’s Tax/VAT number (for corporate customers)

CustomerAddress output

The values assigned to attributes such as firstname and lastname in this object may be different from those defined in the Customer object.

The CustomerAddress output returns the following attributes:

Attribute Data Type Description
city String The city or town
company String The customer’s company
country_id String The customer’s country
custom_attributes CustomerAddressAttribute Address custom attributes
customer_id Int The customer ID
default_billing Boolean Indicates whether the address is the default billing address
default_shipping Boolean Indicates whether the address is the default shipping address
extension_attributes CustomerAddressAttribute Address extension attributes
fax String The fax number
firstname String The first name of the person associated with the shipping/billing address
id Int The ID assigned to the address object
lastname String The family name of the person associated with the shipping/billing address
middlename String The middle name of the person associated with the shipping/billing address
postcode String The customer’s ZIP or postal code
prefix String An honorific, such as Dr., Mr., or Mrs.
region CustomerAddressRegion An object that defines the customer’s state or province
region_id Int A number that uniquely identifies the state, province, or other area
street [String] An array of strings that define the street number and name
suffix String A value such as Sr., Jr., or III
telephone String The telephone number
vat_id String The customer’s Tax/VAT number (for corporate customers)

CustomerAddressAttribute output

The CustomerAddressAttribute output returns the following attributes:

Attribute Data Type Description
attribute_code String Attribute code
value String Attribute value

CustomerAddressRegion output

The customerAddressRegion output returns the following attributes:

Attribute Data Type Description
region_code String The address region code
region String The state or province name
region_id Int Uniquely identifies the region

Errors

Error Description
The current customer isn't authorized. The customer’s token does not exist in the oauth_token table.
Invalid login or password. The password specified in the currentPassword attribute is not valid.
Specify the "currentPassword" value. The password specified in the currentPassword attribute is empty.
Specify the "newPassword" value. The password specified in the newPassword attribute is empty.
The account is locked. The customer’s password cannot be changed because the account is locked.