# Update a customer

To [update](https://docs.commercelayer.io/core/updating-resources) an existing customer, send a `PATCH` request to the `/api/customers/:id` endpoint, where `id` is the ID of the resource that you want to update.

Here below the list of all the possible arguments that you can pass with the request body.

## Request

**PATCH** <https://yourdomain.commercelayer.io/api/customers/:id>

### Arguments

| Body Parameter                          | Type      | Required |
| --------------------------------------- | --------- | -------- |
| **type**                                | `string`  | Required |
| **id**                                  | `string`  | Required |
| attributes.**email**                    | `string`  | Optional |
| attributes.**password**                 | `string`  | Optional |
| attributes.**shopper\_reference**       | `string`  | Optional |
| attributes.**profile\_id**              | `string`  | Optional |
| attributes.**tax\_exemption\_code**     | `string`  | Optional |
| attributes.**\_add\_tags**              | `string`  | Optional |
| attributes.**\_remove\_tags**           | `string`  | Optional |
| attributes.**reference**                | `string`  | Optional |
| attributes.**reference\_origin**        | `string`  | Optional |
| attributes.**metadata**                 | `object`  | Optional |
| attributes.**\_request\_anonymization** | `boolean` | Optional |
| attributes.**\_cancel\_anonymization**  | `boolean` | Optional |
| relationships.**customer\_group**       | `object`  | Optional |
| relationships.**tags**                  | `array`   | Optional |

### Example

{% tabs %}
{% tab title="Request" %}
The following request updates the customer identified by the ID "XAyRWNUzyN":

```shell
curl -g -X PATCH \
  'https://yourdomain.commercelayer.io/api/customers/XAyRWNUzyN' \
  -H 'Accept: application/vnd.api+json' \
  -H 'Authorization: Bearer your-access-token' \
  -H 'Content-Type: application/vnd.api+json' \
  -d '{
  "data": {
    "type": "customers",
    "id": "xYZkjABcde",
    "attributes": {
      "password": "secret"
    },
    "relationships": {
      "customer_group": {
        "data": {
          "type": "customer_groups",
          "id": "ABCRtyUpBa"
        }
      }
    }
  }
}'
```

{% endtab %}

{% tab title="Response" %}
On success, the API responds with a `200 OK` status code, returning the updated resource object:

```json
{
  "data": {
    "id": "XAyRWNUzyN",
    "type": "customers",
    "links": {
      "self": "https://yourdomain.commercelayer.io/api/customers/XAyRWNUzyN"
    },
    "attributes": {
      "email": "john@example.com",
      "status": "prospect",
      "has_password": false,
      "total_orders_count": 6,
      "shopper_reference": "xxx-yyy-zzz",
      "profile_id": "xxx-yyy-zzz",
      "tax_exemption_code": "xxx-yyy-zzz",
      "created_at": "2018-01-01T12:00:00.000Z",
      "updated_at": "2018-01-01T12:00:00.000Z",
      "reference": "ANY-EXTERNAL-REFEFERNCE",
      "reference_origin": "ANY-EXTERNAL-REFEFERNCE-ORIGIN",
      "jwt_custom_claim": {
      },
      "metadata": {
        "foo": "bar"
      },
      "anonymization_info": {
        "status": "requested",
        "requested_at": "2025-03-15 11:39:21 UTC",
        "requester": {
          "id": "fdgt56hh",
          "first_name": "Travis",
          "last_name": "Muller",
          "email": "test@labadie.test"
        }
      },
      "anonymization_status": "requested"
    },
    "relationships": {
      "customer_group": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/customers/XAyRWNUzyN/relationships/customer_group",
          "related": "https://yourdomain.commercelayer.io/api/customers/XAyRWNUzyN/customer_group"
        }
      },
      "customer_addresses": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/customers/XAyRWNUzyN/relationships/customer_addresses",
          "related": "https://yourdomain.commercelayer.io/api/customers/XAyRWNUzyN/customer_addresses"
        }
      },
      "customer_payment_sources": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/customers/XAyRWNUzyN/relationships/customer_payment_sources",
          "related": "https://yourdomain.commercelayer.io/api/customers/XAyRWNUzyN/customer_payment_sources"
        }
      },
      "customer_subscriptions": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/customers/XAyRWNUzyN/relationships/customer_subscriptions",
          "related": "https://yourdomain.commercelayer.io/api/customers/XAyRWNUzyN/customer_subscriptions"
        }
      },
      "orders": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/customers/XAyRWNUzyN/relationships/orders",
          "related": "https://yourdomain.commercelayer.io/api/customers/XAyRWNUzyN/orders"
        }
      },
      "order_subscriptions": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/customers/XAyRWNUzyN/relationships/order_subscriptions",
          "related": "https://yourdomain.commercelayer.io/api/customers/XAyRWNUzyN/order_subscriptions"
        }
      },
      "returns": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/customers/XAyRWNUzyN/relationships/returns",
          "related": "https://yourdomain.commercelayer.io/api/customers/XAyRWNUzyN/returns"
        }
      },
      "sku_lists": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/customers/XAyRWNUzyN/relationships/sku_lists",
          "related": "https://yourdomain.commercelayer.io/api/customers/XAyRWNUzyN/sku_lists"
        }
      },
      "attachments": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/customers/XAyRWNUzyN/relationships/attachments",
          "related": "https://yourdomain.commercelayer.io/api/customers/XAyRWNUzyN/attachments"
        }
      },
      "events": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/customers/XAyRWNUzyN/relationships/events",
          "related": "https://yourdomain.commercelayer.io/api/customers/XAyRWNUzyN/events"
        }
      },
      "tags": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/customers/XAyRWNUzyN/relationships/tags",
          "related": "https://yourdomain.commercelayer.io/api/customers/XAyRWNUzyN/tags"
        }
      },
      "jwt_customer": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/customers/XAyRWNUzyN/relationships/jwt_customer",
          "related": "https://yourdomain.commercelayer.io/api/customers/XAyRWNUzyN/jwt_customer"
        }
      },
      "jwt_markets": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/customers/XAyRWNUzyN/relationships/jwt_markets",
          "related": "https://yourdomain.commercelayer.io/api/customers/XAyRWNUzyN/jwt_markets"
        }
      },
      "jwt_stock_locations": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/customers/XAyRWNUzyN/relationships/jwt_stock_locations",
          "related": "https://yourdomain.commercelayer.io/api/customers/XAyRWNUzyN/jwt_stock_locations"
        }
      },
      "event_stores": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/customers/XAyRWNUzyN/relationships/event_stores",
          "related": "https://yourdomain.commercelayer.io/api/customers/XAyRWNUzyN/event_stores"
        }
      }
    },
    "meta": {
      "mode": "test",
      "organization_id": "xRRkjDFafe",
      "trace_id": "69abaa3545913c78132e5578bd26208d44aa9043647d78698fd0021f3958cd74"
    }
  }
}
```

{% endtab %}
{% endtabs %}
