---
title: Manage customer accounts with the Customer Account API
description: >-
  Learn how to accomplish common tasks like associating an address with a
  customer and updating their first and last name.
source_url:
  html: >-
    https://shopify.dev/docs/storefronts/headless/building-with-the-customer-account-api/customer-accounts
  md: >-
    https://shopify.dev/docs/storefronts/headless/building-with-the-customer-account-api/customer-accounts.md
api_name: customer
---

# Manage customer accounts with the Customer Account API

You can update customer accounts using the [Customer Account API](https://shopify.dev/docs/api/customer).

This guide covers how to update a customer, and accomplish common tasks like creating, updating and deleting an address on a customer.

***

## Requirements

* You've completed the [Getting started with the Customer Account API](https://shopify.dev/docs/storefronts/headless/building-with-the-customer-account-api/getting-started) guide.

***

## Step 1: Update a customer

Customers are automatically created if needed when you call the API.

You update a customer using the [`customerUpdate`](https://shopify.dev/docs/api/customer/unstable/mutations/customerUpdate) mutation. You can use this mutation to update the profile of a customer on your storefront.

## POST https://{shop}.myshopify.com/api/{api\_version}/graphql.json

## GraphQL mutation

```graphql
mutation customerUpdate($input:CustomerUpdateInput!) {
  customerUpdate(input:$input) {
    customer {
      id
      firstName
      lastName
    }
    userErrors {
      field
      message
      code
    }
  }
}
```

## Variables

```json
{
  "input": {
    "firstName": "John",
    "lastName": "Doe"
  }
}
```

## JSON response

```json
{
  "data": {
    "customerUpdate": {
      "customer": {
        "id": "gid://shopify/Customer/1",
        "firstName": "John",
        "lastName": "Doe"
      },
      "userErrors": []
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 10,
      "actualQueryCost": 10
    }
  }
}
```

***

## Step 2: Create an address

The following example shows how to use the [`customerAddressCreate`](https://shopify.dev/docs/api/customer/unstable/mutations/customerAddressCreate) mutation to create a new address for a customer:

## POST \<https

## GraphQL mutation

```graphql
mutation addressCreate($addressInput:CustomerAddressInput!, $defaultAddress:Boolean) {
  customerAddressCreate(address:$addressInput, defaultAddress:$defaultAddress) {
    customerAddress {
      id
      address1
      city
      territoryCode
      zoneCode
      phoneNumber
      zip
    }
    userErrors {
      field
      message
      code
    }
  }
}
```

## Variables

```json
{
  "addressInput": {
    "lastName": "Doe",
    "firstName": "John",
    "address1": "123 Test Street",
    "zoneCode": "QC",
    "territoryCode": "CA",
    "zip": "H3K0X2",
    "city": "Montreal"
  },
  "defaultAddress": false
}
```

## JSON response

```json
{
  "data": {
    "customerAddressCreate": {
      "customerAddress": {
        "id": "gid://shopify/CustomerAddress/1",
        "address1": "123 Test Street",
        "city": "Montreal",
        "territoryCode": "CA",
        "zoneCode": "QC",
        "phoneNumber": null,
        "zip": "H3K0X2"
      },
      "userErrors": []
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 10,
      "actualQueryCost": 10
    }
  }
}
```

***

## Step 3: Update an address

The following example shows how to use the [`customerAddressUpdate`](https://shopify.dev/docs/api/customer/unstable/mutations/customerAddressUpdate) mutation to update an existing address for a customer:

## POST https://{shop}.myshopify.com/api/{api\_version}/graphql.json

## GraphQL mutation

```graphql
mutation addressUpdate($addressInput:CustomerAddressInput!, $addressId:ID!, $defaultAddress:Boolean) {
  customerAddressUpdate(addressId:$addressId, address:$addressInput, defaultAddress:$defaultAddress) {
    customerAddress {
      id
      address1
      city
      territoryCode
      zoneCode
      phoneNumber
      zip
    }
    userErrors {
      field
      message
      code
    }
  }
}
```

## Variables

```json
{
  "addressId": "gid://shopify/CustomerAddress/1",
  "addressInput": {
    "address1": "456 Test Street",
    "zip": "H3K8X2"
  },
  "defaultAddress": true
}
```

## JSON response

```json
{
  "data": {
    "customerAddressUpdate": {
      "customerAddress": {
        "id": "gid://shopify/CustomerAddress/1",
        "address1": "456 Test Street",
        "city": "Montreal",
        "territoryCode": "CA",
        "zoneCode": "QC",
        "phoneNumber": null,
        "zip": "H3K8X2"
      },
      "userErrors": []
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 10,
      "actualQueryCost": 10
    }
  }
}
```

***

## Step 4: Delete an address

The following example shows how to use the [`customerAddressDelete`](https://shopify.dev/docs/api/customer/unstable/mutations/customerAddressDelete) mutation to create a new address for a customer:

## POST \<https

## GraphQL mutation

```graphql
mutation addressDelete($addressId:ID!) {
  customerAddressDelete(addressId:$addressId) {
  deletedAddressId
    userErrors {
      field
      message
      code
    }
  }
}
```

## Variables

```json
{
  "addressId": "gid://shopify/CustomerAddress/2"
}
```

## JSON response

```json
{
  "data": {
    "customerAddressDelete": {
      "deletedAddressId": "gid://shopify/CustomerAddress/2",
      "userErrors": []
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 10,
      "actualQueryCost": 10
    }
  }
}
```

***

## Next steps

* Learn more about the [Customer Account API](https://shopify.dev/docs/api/customer).

***
