updateCustomer mutation
Use the updateCustomer
mutation to update the customer’s personal information.
To return or modify information about a customer, we recommend you use customer tokens in the header of your GraphQL calls. However, you also can use session authentication.
Syntax
1
2
3
4
5
6
7
mutation {
updateCustomer(
input: CustomerInput!
) {
CustomerOutput
}
}
Example usage
The following call updates the first name and email address for a specific customer.
Request:
1
2
3
4
5
6
7
8
9
10
11
12
13
mutation {
updateCustomer(
input: {
firstname: "Rob"
email: "robloblaw@example.com"
}
) {
customer {
firstname
email
}
}
}
Response:
1
2
3
4
5
6
7
8
9
10
{
"data": {
"updateCustomer": {
"customer": {
"firstname": "Rob",
"email": "robloblaw@example.com"
}
}
}
}
Input attributes
The following table lists the attributes you can use as input for the updateCustomer
mutation. The Customer attributes table lists the attributes Magento returns.
Attribute | Data Type | Description |
---|---|---|
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. |
dob |
String | Deprecated. Use date_of_birth instead. The customer’s date of birth |
email |
String | The customer’s email address. Required to create a customer |
firstname |
String | The customer’s first name. Required to create a customer |
gender |
Int | The customer’s gender (Male - 1, Female - 2) |
is_subscribed |
Boolean | The customer’s new password |
lastname |
String | The customer’s last name. Required to create a customer |
middlename |
String | The customer’s middle name |
password |
String | The customer’s password. Required to create a customer |
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) |
Output attributes
The updateCustomer
mutation returns the CustomerOutput
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 |
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 |
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) |
wishlist |
Wishlist! | Contains the contents of the customer’s wish lists |
Address attributes (CustomerAddress)
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_code |
CountryCodeEnum | The customer’s country |
country_id |
String | Deprecated. Use country_code instead. The customer’s country |
custom_attributes |
CustomerAddressAttribute | Deprecated. Not applicable for GraphQL |
customer_id |
Int | Deprecated. This attribute is not applicable for GraphQL. The ID assigned to the customer |
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 | Deprecated. Use region instead. 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 attributes
The CustomerAddressAttribute
output data type has been deprecated because the contents are not applicable for GraphQL. It can contain the following attributes:
Attribute | Data Type | Description |
---|---|---|
attribute_code |
String | Attribute code |
value |
String | Attribute value |
CustomerAddressRegion attributes
The customerAddressRegion
output returns the following attributes:
Attribute | Data Type | Description |
---|---|---|
region |
String | The state or province name |
region_code |
String | The address region code |
region_id |
Int | Deprecated. Use region instead. Uniquely identifies the region |
Errors
Error | Description |
---|---|
"input" value should be specified |
The input argument is empty. |
"Email" is not a valid email address. |
The value provided in the input .email argument has an invalid format. |
A customer with the same email address already exists in an associated website. |
You cannot set a new email to a current customer, because another user has the specified email. |
Invalid date |
An incorrect value was provided in the date_of_birth argument. |
Invalid login or password. |
The value specified in the password argument is incorrect. |
Provide the current "password" to change "email". |
To change an email address, specify the correct customer password in the password argument. |
Required parameters are missing: First Name |
The customer first name cannot have an empty value. |
Required parameters are missing: Last Name |
The customer last name cannot have an empty value. |
The account is locked. |
You cannot modify a locked customer account. |
The current customer isn't authorized. |
The current customer is not currently logged in, or the customer’s token does not exist in the oauth_token table. |