customerAddressDelete
Overview
Remove an address from the customer's address book using its _id. Typically requires an authenticated customer token.
- Type: GraphQL Mutation
- Endpoint: https://subdomain.com
- Authentication:
Authorization: Bearer <TOKEN>
Mutation
mutation DeleteCustomerAddressesById($addressId: ID!) {
deleteCustomerAddressesById(addressId: $addressId) {
success
message
}
}
Variables
{
"addressId": "<ADDRESS_ID>"
}
Examples
- cURL
- JavaScript (fetch)
curl -X POST \
https://subdomain.com\
-H "Content-Type": "application/json" \
-H "Authorization: Bearer <TOKEN>" \
--data-binary @- << 'EOF'
{
"query": "mutation DeleteCustomerAddressesById($addressId: ID!) { deleteCustomerAddressesById(addressId: $addressId) { success message } }",
"variables": { "addressId": "<ADDRESS_ID>" }
}
EOF
const res = await fetch('https://subdomain.com', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + token,
},
body: JSON.stringify({
query: `
mutation DeleteCustomerAddressesById($addressId: ID!) {
deleteCustomerAddressesById(addressId: $addressId) {
success
message
}
}
`,
variables: { addressId: '<ADDRESS_ID>' },
}),
});
const json = await res.json();
Notes
- Attempting to delete an address not owned by the customer should return an error; handle
success/messagegracefully. - Use this together with
createCustomerAddressesandfindCustomerAddressByAccountfor full CRUD flows.