updateCustomerAddress mutation
Use the updateCustomerAddress
mutation to update the customer’s address.
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: {updateCustomerAddress(id: Int!, input: CustomerAddressInput) {CustomerAddress}}
Example usage
The following call updates the customer’s city and postcode.
Request:
1
2
3
4
5
6
7
8
9
10
mutation {
updateCustomerAddress(id:3, input: {
city: "New City"
postcode: "55555"
}) {
id
city
postcode
}
}
Response:
1
2
3
4
5
6
7
8
9
{
"data": {
"updateCustomerAddress": {
"id": 3,
"city": "New City",
"postcode": 55555
}
}
}
Input attributes
The updateCustomerAddress
object contains the following inputs:
Attribute | Data Type | Description |
---|---|---|
id |
Int! | The ID assigned to the address object |
CustomerAddressInput |
CustomerAddress | An array containing the customer’s shipping and billing addresses |
CustomerAddressInput attributes
The CustomerAddressInput
object can contain the following attributes:
Attribute | Data Type | Description |
---|---|---|
city |
String | The city or town |
company |
String | The customer’s company |
country_code |
String | The customer’s country |
country_id |
String | Deprecated. Use country_code instead. The customer’s country |
custom_attributes |
CustomerAddressAttributeInput | Deprecated. Not applicable for GraphQL |
default_billing |
Boolean | Indicates whether the address is the default billing address |
default_shipping |
Boolean | Indicates whether the address is the default shipping address |
fax |
String | The fax number |
firstname |
String | The first name of the person associated with the shipping/billing address |
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 |
CustomerAddressRegionInput | An object that defines the customer’s state or province |
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) |
CustomerAddressAttributeInput attributes
The CustomerAddressAttributeInput
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 |
CustomerAddressRegionInput attributes
The customerAddressRegionInput
object can contain 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 |
Output attributes
The updateCustomerAddress
mutation returns the CustomerAddress
object.
CustomerAddress attributes
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 |
---|---|
Address "id" value should be specified |
The id argument is zero. |
Could not find a address with ID "XXX" |
The customer address specified in the id argument does not exist. |
Current customer does not have permission to address with ID "XXX" |
The customer tries to update the address of another customer. |
Field "updateCustomerAddress" argument "id" of type "Int!" is required but not provided. |
The id argument was omitted. |
Field "updateCustomerAddress" argument "id" requires type Int!, found "XXX". |
The specified id argument value has the wrong type. |
"input" value must be specified |
The input argument was omitted or was specified but is empty. |
Syntax Error: Expected Name, found ) |
The id and input arguments are omitted. |
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. |