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

# getCustomerDetails

> Retrieve details for the logged-in customer, including balance, VIP tier, and earning history.

Retrieve the full profile for the currently logged-in customer. Returns their loyalty balance, VIP tier, earning history, and referral earnings, along with the shop's loyalty mode and currency.

## Usage

```javascript theme={null}
MageSDK.getCustomerDetails().then(function(resp) {
  if (resp.success) {
    console.log(resp.data.customer);
    console.log(resp.data.loyaltyMode); // 'points' | 'store_credit'
  }
});
```

## Response

<ResponseField name="success" type="boolean">
  Whether the request was successful.
</ResponseField>

<ResponseField name="data.loyaltyMode" type="string">
  The shop's loyalty mode, `"points"` or `"store_credit"`. In store-credit mode every loyalty number below is in the currency's minor units. See [Loyalty modes](/js-sdk/loyalty-modes).
</ResponseField>

<ResponseField name="data.currency" type="string">
  The shop's ISO currency code, e.g. `"USD"`.
</ResponseField>

<ResponseField name="data.customer" type="object">
  The customer object.

  <Expandable title="Customer properties">
    <ResponseField name="id" type="string">
      Internal Mage customer ID.
    </ResponseField>

    <ResponseField name="shopifyCustomerId" type="string">
      The Shopify customer ID.
    </ResponseField>

    <ResponseField name="email" type="string">
      Customer email address.
    </ResponseField>

    <ResponseField name="firstName" type="string">
      Customer first name.
    </ResponseField>

    <ResponseField name="lastName" type="string">
      Customer last name.
    </ResponseField>

    <ResponseField name="points" type="number">
      Current available balance. Points in points mode, minor currency units in store-credit mode.
    </ResponseField>

    <ResponseField name="lifetimePoints" type="number">
      Total earned over the customer's lifetime, in the same unit as `points`.
    </ResponseField>

    <ResponseField name="redeemedPoints" type="number">
      Total redeemed, in the same unit as `points`.
    </ResponseField>

    <ResponseField name="isExcluded" type="boolean">
      Whether the customer is excluded from the loyalty program.
    </ResponseField>

    <ResponseField name="dateOfBirth" type="string | null">
      Customer date of birth in ISO 8601 format.
    </ResponseField>

    <ResponseField name="referralCode" type="string | null">
      The customer's unique referral code.
    </ResponseField>

    <ResponseField name="referralUrl" type="string | null">
      The customer's full referral URL that can be shared.
    </ResponseField>

    <ResponseField name="tier" type="object | null">
      The customer's current VIP tier, or `null` if no tier is assigned. See [getShopVipTiers](/js-sdk/vip-tiers/get-shop-vip-tiers) for the tier shape.
    </ResponseField>

    <ResponseField name="tierProgressValue" type="number">
      The customer's progress value toward the next tier, measured by the shop's primary entry method.
    </ResponseField>

    <ResponseField name="tierProgressValueExtra" type="number | null">
      Progress toward the secondary tier-entry threshold, when the shop combines two entry methods. `null` otherwise.
    </ResponseField>

    <ResponseField name="customerEarningRule" type="array">
      List of the customer's point earning events, newest first.

      <Expandable title="Earning entry properties">
        <ResponseField name="id" type="string">
          The earning record ID.
        </ResponseField>

        <ResponseField name="earningRuleId" type="string">
          ID of the earning rule that produced this entry.
        </ResponseField>

        <ResponseField name="status" type="string">
          Status of the entry, e.g. `"APPROVED"`. Expired rows are surfaced as `"EXPIRED"`.
        </ResponseField>

        <ResponseField name="points" type="number">
          Amount earned, in the shop's loyalty unit.
        </ResponseField>

        <ResponseField name="refundedPoints" type="number">
          Amount later reversed (for example after an order refund).
        </ResponseField>

        <ResponseField name="action" type="string | null">
          The earning rule action, e.g. `"purchase"`, `"birthday"`, `"points_drop"`.
        </ResponseField>

        <ResponseField name="name" type="string">
          A display name for the row.
        </ResponseField>

        <ResponseField name="pointsExpiryAt" type="string | null">
          Expiry timestamp. Set only for future-dated points drops, `null` otherwise.
        </ResponseField>

        <ResponseField name="earningRule" type="object | null">
          The related earning rule, `{ id, name }`, or `null`.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="earningHistory" type="array">
      Backwards-compatible alias of `customerEarningRule`. New code should read `customerEarningRule`.
    </ResponseField>

    <ResponseField name="referralEarnings" type="array">
      List of earnings from referrals.
    </ResponseField>

    <ResponseField name="storeCredit" type="object | null">
      In store-credit mode, a ready-to-display view of the balance (`balanceMinor`, `balance`, `balanceFormatted`, `currency`). `null` in points mode. See [Loyalty modes](/js-sdk/loyalty-modes).
    </ResponseField>

    <ResponseField name="createdAt" type="string">
      ISO 8601 timestamp of when the customer was enrolled.
    </ResponseField>

    <ResponseField name="updatedAt" type="string">
      ISO 8601 timestamp of the last update.
    </ResponseField>
  </Expandable>
</ResponseField>

## Sample response

```json theme={null}
{
  "success": true,
  "data": {
    "loyaltyMode": "points",
    "currency": "GBP",
    "customer": {
      "id": "abc123",
      "shopifyCustomerId": "6789012345",
      "email": "jane@example.com",
      "firstName": "Jane",
      "lastName": "Doe",
      "points": 450,
      "lifetimePoints": 1200,
      "redeemedPoints": 750,
      "isExcluded": false,
      "dateOfBirth": "1990-05-15T00:00:00.000Z",
      "referralCode": "ABC123",
      "referralUrl": "https://mystore.com?referral_code=ABC123",
      "tier": {
        "id": "tier_abc",
        "name": "Gold",
        "description": "Our most valued customers",
        "threshold": 500,
        "thresholdPoints": 500,
        "thresholdSpend": null,
        "thresholdOrders": null,
        "pointsMultiplier": 1.5,
        "badgeImageUrl": null,
        "badgeColor": "#FFD700"
      },
      "tierProgressValue": 1200,
      "tierProgressValueExtra": null,
      "customerEarningRule": [
        {
          "id": "cer_abc",
          "earningRuleId": "rule_abc",
          "status": "APPROVED",
          "points": 150,
          "refundedPoints": 0,
          "action": "purchase",
          "name": "Points for purchase",
          "pointsExpiryAt": null,
          "earningRule": {
            "id": "rule_abc",
            "name": "Points for purchase"
          }
        }
      ],
      "referralEarnings": [],
      "storeCredit": null,
      "createdAt": "2024-01-15T10:00:00.000Z",
      "updatedAt": "2024-06-20T14:30:00.000Z"
    }
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.