Update a customer address
Description
Replace the details of one of a customer's addresses, identified by `addressId`. Without `setAsDefault`, the customer's default address doesn't change.
Query
mutation customerAddressUpdate($customerId: ID!, $addressId: ID!, $address: MailingAddressInput!) {
customerAddressUpdate(customerId: $customerId, addressId: $addressId, address: $address) {
address {
id
firstName
lastName
address1
city
province
country
zip
phone
}
userErrors {
field
message
}
}
}
Variables
{
"customerId": "gid://shopify/Customer/554456816",
"addressId": "gid://shopify/MailingAddress/768736626?model_name=CustomerAddress",
"address": {
"firstName": "Jane",
"lastName": "Doe",
"address1": "123 Main Street",
"city": "Nashville",
"provinceCode": "TN",
"countryCode": "US",
"zip": "37201",
"phone": "+16155550123"
}
}
cURL
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2026-07/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation customerAddressUpdate($customerId: ID!, $addressId: ID!, $address: MailingAddressInput!) { customerAddressUpdate(customerId: $customerId, addressId: $addressId, address: $address) { address { id firstName lastName address1 city province country zip phone } userErrors { field message } } }",
"variables": {
"customerId": "gid://shopify/Customer/554456816",
"addressId": "gid://shopify/MailingAddress/768736626?model_name=CustomerAddress",
"address": {
"firstName": "Jane",
"lastName": "Doe",
"address1": "123 Main Street",
"city": "Nashville",
"provinceCode": "TN",
"countryCode": "US",
"zip": "37201",
"phone": "+16155550123"
}
}
}'
React Router
import { authenticate } from "../shopify.server";
export const loader = async ({request}) => {
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation customerAddressUpdate($customerId: ID!, $addressId: ID!, $address: MailingAddressInput!) {
customerAddressUpdate(customerId: $customerId, addressId: $addressId, address: $address) {
address {
id
firstName
lastName
address1
city
province
country
zip
phone
}
userErrors {
field
message
}
}
}`,
{
variables: {
"customerId": "gid://shopify/Customer/554456816",
"addressId": "gid://shopify/MailingAddress/768736626?model_name=CustomerAddress",
"address": {
"firstName": "Jane",
"lastName": "Doe",
"address1": "123 Main Street",
"city": "Nashville",
"provinceCode": "TN",
"countryCode": "US",
"zip": "37201",
"phone": "+16155550123"
}
},
},
);
const json = await response.json();
return json.data;
}
Ruby
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
mutation customerAddressUpdate($customerId: ID!, $addressId: ID!, $address: MailingAddressInput!) {
customerAddressUpdate(customerId: $customerId, addressId: $addressId, address: $address) {
address {
id
firstName
lastName
address1
city
province
country
zip
phone
}
userErrors {
field
message
}
}
}
QUERY
variables = {
"customerId": "gid://shopify/Customer/554456816",
"addressId": "gid://shopify/MailingAddress/768736626?model_name=CustomerAddress",
"address": {
"firstName": "Jane",
"lastName": "Doe",
"address1": "123 Main Street",
"city": "Nashville",
"provinceCode": "TN",
"countryCode": "US",
"zip": "37201",
"phone": "+16155550123"
}
}
response = client.query(query: query, variables: variables)
Node.js
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation customerAddressUpdate($customerId: ID!, $addressId: ID!, $address: MailingAddressInput!) {
customerAddressUpdate(customerId: $customerId, addressId: $addressId, address: $address) {
address {
id
firstName
lastName
address1
city
province
country
zip
phone
}
userErrors {
field
message
}
}
}`,
"variables": {
"customerId": "gid://shopify/Customer/554456816",
"addressId": "gid://shopify/MailingAddress/768736626?model_name=CustomerAddress",
"address": {
"firstName": "Jane",
"lastName": "Doe",
"address1": "123 Main Street",
"city": "Nashville",
"provinceCode": "TN",
"countryCode": "US",
"zip": "37201",
"phone": "+16155550123"
}
},
},
});
Shopify CLI
shopify app execute \
--query \
'mutation customerAddressUpdate($customerId: ID!, $addressId: ID!, $address: MailingAddressInput!) {
customerAddressUpdate(customerId: $customerId, addressId: $addressId, address: $address) {
address {
id
firstName
lastName
address1
city
province
country
zip
phone
}
userErrors {
field
message
}
}
}' \
--variables \
'{
"customerId": "gid://shopify/Customer/554456816",
"addressId": "gid://shopify/MailingAddress/768736626?model_name=CustomerAddress",
"address": {
"firstName": "Jane",
"lastName": "Doe",
"address1": "123 Main Street",
"city": "Nashville",
"provinceCode": "TN",
"countryCode": "US",
"zip": "37201",
"phone": "+16155550123"
}
}'
Direct API Access
const response = await fetch('shopify:admin/api/2026-07/graphql.json', {
method: 'POST',
body: JSON.stringify({
query: `
mutation customerAddressUpdate($customerId: ID!, $addressId: ID!, $address: MailingAddressInput!) {
customerAddressUpdate(customerId: $customerId, addressId: $addressId, address: $address) {
address {
id
firstName
lastName
address1
city
province
country
zip
phone
}
userErrors {
field
message
}
}
}
`,
variables: {
"customerId": "gid://shopify/Customer/554456816",
"addressId": "gid://shopify/MailingAddress/768736626?model_name=CustomerAddress",
"address": {
"firstName": "Jane",
"lastName": "Doe",
"address1": "123 Main Street",
"city": "Nashville",
"provinceCode": "TN",
"countryCode": "US",
"zip": "37201",
"phone": "+16155550123"
}
},
}),
});
const { data } = await response.json();
console.log(data);
Response
{
"customerAddressUpdate": {
"address": {
"id": "gid://shopify/MailingAddress/768736626?model_name=CustomerAddress",
"firstName": "Jane",
"lastName": "Doe",
"address1": "123 Main Street",
"city": "Nashville",
"province": "Tennessee",
"country": "United States",
"zip": "37201",
"phone": "+16155550123"
},
"userErrors": []
}
}
Update an address and set it as the default address
Description
Update one of a customer's addresses and make it the customer's default address by passing `setAsDefault: true`.
Query
mutation customerAddressUpdate($customerId: ID!, $addressId: ID!, $address: MailingAddressInput!, $setAsDefault: Boolean) {
customerAddressUpdate(customerId: $customerId, addressId: $addressId, address: $address, setAsDefault: $setAsDefault) {
address {
id
address1
city
provinceCode
countryCodeV2
zip
}
userErrors {
field
message
}
}
}
Variables
{
"customerId": "gid://shopify/Customer/554456816",
"addressId": "gid://shopify/MailingAddress/768736626?model_name=CustomerAddress",
"address": {
"address1": "500 Broadway",
"city": "Nashville",
"provinceCode": "TN",
"countryCode": "US",
"zip": "37203"
},
"setAsDefault": true
}
cURL
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2026-07/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation customerAddressUpdate($customerId: ID!, $addressId: ID!, $address: MailingAddressInput!, $setAsDefault: Boolean) { customerAddressUpdate(customerId: $customerId, addressId: $addressId, address: $address, setAsDefault: $setAsDefault) { address { id address1 city provinceCode countryCodeV2 zip } userErrors { field message } } }",
"variables": {
"customerId": "gid://shopify/Customer/554456816",
"addressId": "gid://shopify/MailingAddress/768736626?model_name=CustomerAddress",
"address": {
"address1": "500 Broadway",
"city": "Nashville",
"provinceCode": "TN",
"countryCode": "US",
"zip": "37203"
},
"setAsDefault": true
}
}'
React Router
import { authenticate } from "../shopify.server";
export const loader = async ({request}) => {
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation customerAddressUpdate($customerId: ID!, $addressId: ID!, $address: MailingAddressInput!, $setAsDefault: Boolean) {
customerAddressUpdate(customerId: $customerId, addressId: $addressId, address: $address, setAsDefault: $setAsDefault) {
address {
id
address1
city
provinceCode
countryCodeV2
zip
}
userErrors {
field
message
}
}
}`,
{
variables: {
"customerId": "gid://shopify/Customer/554456816",
"addressId": "gid://shopify/MailingAddress/768736626?model_name=CustomerAddress",
"address": {
"address1": "500 Broadway",
"city": "Nashville",
"provinceCode": "TN",
"countryCode": "US",
"zip": "37203"
},
"setAsDefault": true
},
},
);
const json = await response.json();
return json.data;
}
Ruby
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
mutation customerAddressUpdate($customerId: ID!, $addressId: ID!, $address: MailingAddressInput!, $setAsDefault: Boolean) {
customerAddressUpdate(customerId: $customerId, addressId: $addressId, address: $address, setAsDefault: $setAsDefault) {
address {
id
address1
city
provinceCode
countryCodeV2
zip
}
userErrors {
field
message
}
}
}
QUERY
variables = {
"customerId": "gid://shopify/Customer/554456816",
"addressId": "gid://shopify/MailingAddress/768736626?model_name=CustomerAddress",
"address": {
"address1": "500 Broadway",
"city": "Nashville",
"provinceCode": "TN",
"countryCode": "US",
"zip": "37203"
},
"setAsDefault": true
}
response = client.query(query: query, variables: variables)
Node.js
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation customerAddressUpdate($customerId: ID!, $addressId: ID!, $address: MailingAddressInput!, $setAsDefault: Boolean) {
customerAddressUpdate(customerId: $customerId, addressId: $addressId, address: $address, setAsDefault: $setAsDefault) {
address {
id
address1
city
provinceCode
countryCodeV2
zip
}
userErrors {
field
message
}
}
}`,
"variables": {
"customerId": "gid://shopify/Customer/554456816",
"addressId": "gid://shopify/MailingAddress/768736626?model_name=CustomerAddress",
"address": {
"address1": "500 Broadway",
"city": "Nashville",
"provinceCode": "TN",
"countryCode": "US",
"zip": "37203"
},
"setAsDefault": true
},
},
});
Shopify CLI
shopify app execute \
--query \
'mutation customerAddressUpdate($customerId: ID!, $addressId: ID!, $address: MailingAddressInput!, $setAsDefault: Boolean) {
customerAddressUpdate(customerId: $customerId, addressId: $addressId, address: $address, setAsDefault: $setAsDefault) {
address {
id
address1
city
provinceCode
countryCodeV2
zip
}
userErrors {
field
message
}
}
}' \
--variables \
'{
"customerId": "gid://shopify/Customer/554456816",
"addressId": "gid://shopify/MailingAddress/768736626?model_name=CustomerAddress",
"address": {
"address1": "500 Broadway",
"city": "Nashville",
"provinceCode": "TN",
"countryCode": "US",
"zip": "37203"
},
"setAsDefault": true
}'
Direct API Access
const response = await fetch('shopify:admin/api/2026-07/graphql.json', {
method: 'POST',
body: JSON.stringify({
query: `
mutation customerAddressUpdate($customerId: ID!, $addressId: ID!, $address: MailingAddressInput!, $setAsDefault: Boolean) {
customerAddressUpdate(customerId: $customerId, addressId: $addressId, address: $address, setAsDefault: $setAsDefault) {
address {
id
address1
city
provinceCode
countryCodeV2
zip
}
userErrors {
field
message
}
}
}
`,
variables: {
"customerId": "gid://shopify/Customer/554456816",
"addressId": "gid://shopify/MailingAddress/768736626?model_name=CustomerAddress",
"address": {
"address1": "500 Broadway",
"city": "Nashville",
"provinceCode": "TN",
"countryCode": "US",
"zip": "37203"
},
"setAsDefault": true
},
}),
});
const { data } = await response.json();
console.log(data);
Response
{
"customerAddressUpdate": {
"address": {
"id": "gid://shopify/MailingAddress/768736626?model_name=CustomerAddress",
"address1": "500 Broadway",
"city": "Nashville",
"provinceCode": "TN",
"countryCodeV2": "US",
"zip": "37203"
},
"userErrors": []
}
}