# Address management

Source: https://developers.swell.is/frontend-api/address-management

**Swell.js:**

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, with offset pagination using* *`limit`* *and* *`page`**.*

**List addresses**

**swell.js**

```javascript
await swell.account.listAddresses()
```

### Create an address

Use to add a new address to the account.

*Returns the newly created address object.*

**Create an address**

**swell.js**

```javascript
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'
})
```

### Update an address

Use to update an existing address from the account by ID.

*Returns the updated address object*.

**Update an address**

**swell.js**

```javascript
await swell.account.updateAddress("5c15505200c7d14d851e510f", {
  address1: '06 Bennered Mare',
  city: 'Whiterun',
  state: 'NY',
  zip: '10005',
  country: 'US' // Two letter ISO country code
})
```

### Delete an address

Use to remove an existing address from the account by ID.

*Returns the deleted address object.*

**Delete an address**

**swell.js**

```javascript
await swell.account.deleteAddress('5c15505200c7d14d851e510f')
```

**GraphQL:**

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`.

**List addresses**

**GraphQL**

```graphql
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).

**Create an address**

**GraphQL**

```graphql
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).

**Update an address**

**GraphQL**

```graphql
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).

**Delete an address**

**GraphQL**

```graphql
mutation deleteAccountAddress {
  deleteAccountAddress(addressId: "62fe8f954711c20012d6a5c7") {
    name
    address1
    city
    state
    zip
    country
    phone
  }
}
```
