Frontend API
Methods to manage and update account addresses stored on a customer's account.
Use to get a list of addresses on file for the account. These are stored automatically when a non-guest user checks out and chooses to save their information for later.
Returns all addresses, with offset pagination using limit and page.
await swell.account.listAddresses()
Use to add a new address to the account.
Returns the newly created address object.
await swell.account.createAddress({
name: 'Julia Sanchez',
address1: 'Apartment 16B',
address2: '2602 Pinewood Drive',
city: 'Jacksonville',
state: 'FL',
zip: '32216',
country: 'US', // Two letter ISO country code
phone: '904-504-4760'
})
Use to update an existing address from the account by ID.
Returns the updated address object.
await swell.account.updateAddress("5c15505200c7d14d851e510f", {
address1: '06 Bennered Mare',
city: 'Whiterun',
state: 'NY',
zip: '10005',
country: 'US' // Two letter ISO country code
})
Use to remove an existing address from the account by ID.
Returns the deleted address object.
await swell.account.deleteAddress('5c15505200c7d14d851e510f')
Methods to manage and update account addresses stored on a customer's account.
List addresses
Use to get a list of addresses on file for the account. These are stored automatically when a non-guest user checks out and chooses to save their information for later.
Returns all addresses. The parameters for this query are _locale and _currency.
query getAccountAddresses {
account {
addresses {
results {
name
address1
city
state
zip
country
phone
}
}
}
}Create an address
Use to add a new address to the account. Returns the newly created address object.
The parameter for this mutation is input (required).
mutation createAccountAddress {
addAccountAddress(
input: {
name: "Ancotar"
address1: "1234 Fort Caractacus"
city: "Imperial City"
state: "FL"
country: "US" ## Two letter ISO country code
}
) {
name
address1
city
state
country
}
}Update an address
Use to update an existing address from the account by ID. Returns the updated address object.
The parameter for this mutation is addressId (required) and input (required).
mutation updateAccountAddress {
updateAccountAddress(
addressId: "62fe8f954711c20012d6a5c7"
input: { zip: "32216", phone: "904-504-4760" }
) {
name
zip
phone
}
}Delete an address
Use to remove an existing address from the account by ID. Returns the deleted address object.
The parameter for this mutation is addressId (required).
mutation deleteAccountAddress {
deleteAccountAddress(addressId: "62fe8f954711c20012d6a5c7") {
name
address1
city
state
zip
country
phone
}
}