> ## Documentation Index
> Fetch the complete documentation index at: https://developers.mageloyalty.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Update a customer

> Update editable fields on a customer.

Update editable fields on a customer. The `identifier` can be a Shopify customer ID or email.

The request body may be sent in either JSON:API format (attributes nested under `data.attributes`) or as a flat object. Both forms accept the same field names.

Only the fields listed below are updatable. Any other field in the body is ignored. At least one updatable field must be present, otherwise the request returns `400`.

## Query parameters

| Parameter     | Type   | Description                                                                    |
| ------------- | ------ | ------------------------------------------------------------------------------ |
| `exclude_vip` | `true` | When set to `true`, omits the VIP tier lookup and returns `vip_tier` as `null` |

## Request body

| Field              | Type           | Description                                               |
| ------------------ | -------------- | --------------------------------------------------------- |
| `date_of_birth`    | string \| null | ISO 8601 date. Pass `null` to clear.                      |
| `is_excluded`      | boolean        | Whether the customer is excluded from the loyalty program |
| `anniversary_date` | string \| null | ISO 8601 date. Pass `null` to clear.                      |

**JSON:API format:**

```json theme={null}
{
  "data": {
    "attributes": {
      "date_of_birth": "1990-05-15T00:00:00.000Z",
      "is_excluded": false,
      "anniversary_date": "2023-03-10T09:00:00.000Z"
    }
  }
}
```

**Flat format:**

```json theme={null}
{
  "date_of_birth": "1990-05-15T00:00:00.000Z",
  "is_excluded": false,
  "anniversary_date": "2023-03-10T09:00:00.000Z"
}
```

## Response

Returns the updated [customer object](/api-reference/customers/object).

## Errors

| Status | Scenario                                           |
| ------ | -------------------------------------------------- |
| `400`  | Invalid JSON body, or no updatable fields provided |
| `404`  | Customer not found                                 |

<RequestExample>
  ```bash cURL theme={null}
  # JSON:API format
  curl --request PUT \
    --url https://api.mageloyalty.com/v1/customers/6789012345 \
    --header 'Authorization: <api-key>' \
    --header 'Content-Type: application/json' \
    --data '{
    "data": {
      "attributes": {
        "date_of_birth": "1990-05-15T00:00:00.000Z",
        "is_excluded": false,
        "anniversary_date": "2023-03-10T09:00:00.000Z"
      }
    }
  }'

  # Flat format
  curl --request PUT \
    --url https://api.mageloyalty.com/v1/customers/6789012345 \
    --header 'Authorization: <api-key>' \
    --header 'Content-Type: application/json' \
    --data '{
    "date_of_birth": "1990-05-15T00:00:00.000Z",
    "is_excluded": false,
    "anniversary_date": "2023-03-10T09:00:00.000Z"
  }'
  ```

  ```javascript Node theme={null}
  // JSON:API format
  const response = await fetch(
    "https://api.mageloyalty.com/v1/customers/6789012345",
    {
      method: "PUT",
      headers: {
        Authorization: "<api-key>",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        data: {
          attributes: {
            date_of_birth: "1990-05-15T00:00:00.000Z",
            is_excluded: false,
            anniversary_date: "2023-03-10T09:00:00.000Z",
          },
        },
      }),
    }
  );

  const data = await response.json();
  ```

  ```python Python theme={null}
  import requests

  # Flat format
  response = requests.put(
      "https://api.mageloyalty.com/v1/customers/6789012345",
      headers={"Authorization": "<api-key>"},
      json={
          "date_of_birth": "1990-05-15T00:00:00.000Z",
          "is_excluded": False,
          "anniversary_date": "2023-03-10T09:00:00.000Z",
      },
  )

  data = response.json()
  ```

  ```php PHP theme={null}
  <?php
  // Flat format
  $ch = curl_init("https://api.mageloyalty.com/v1/customers/6789012345");
  curl_setopt_array($ch, [
      CURLOPT_CUSTOMREQUEST => "PUT",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_HTTPHEADER => [
          "Authorization: <api-key>",
          "Content-Type: application/json",
      ],
      CURLOPT_POSTFIELDS => json_encode([
          "date_of_birth" => "1990-05-15T00:00:00.000Z",
          "is_excluded" => false,
          "anniversary_date" => "2023-03-10T09:00:00.000Z",
      ]),
  ]);
  $data = json_decode(curl_exec($ch), true);
  ```
</RequestExample>

<ResponseExample>
  ```json 200 OK theme={null}
  {
    "data": {
      "type": "customer",
      "id": "6789012345",
      "attributes": {
        "shopify_customer_id": "6789012345",
        "email": "jane@example.com",
        "first_name": "Jane",
        "last_name": "Doe",
        "current_points": 450,
        "lifetime_points": 1200,
        "redeemed_points": 750,
        "loyalty_status": "member",
        "date_of_birth": "1990-05-15T00:00:00.000Z",
        "referral_url": "https://mystore.myshopify.com?referral_code=ABC123",
        "referral_code": "ABC123",
        "vip_tier": {
          "id": "tier_abc",
          "name": "Gold",
          "threshold": 500,
          "points_multiplier": 1.5,
          "badge_image_url": null,
          "badge_color": "#FFD700"
        },      "created_at": "2024-01-15T10:00:00.000Z",
        "updated_at": "2026-06-23T12:00:00.000Z"
      }
    }
  }
  ```

  ```json 400 Bad Request theme={null}
  {
    "errors": [
      {
        "status": "400",
        "title": "Bad Request",
        "detail": "No updatable fields provided"
      }
    ]
  }
  ```

  ```json 404 Not Found theme={null}
  {
    "errors": [
      {
        "status": "404",
        "title": "Not Found",
        "detail": "Customer '6789012345' not found"
      }
    ]
  }
  ```
</ResponseExample>
