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

# getEarningRules

> List all active earning rules for the shop.

Retrieve all active earning rules configured for the shop. Use this to display how customers can earn points.

## Usage

```javascript theme={null}
MageSDK.getEarningRules().then(function(resp) {
  if (resp.success) {
    resp.data.earningRules.forEach(function(rule) {
      console.log(rule.name, rule.pointsToGive);
    });
  }
});
```

## Response

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

<ResponseField name="data.earningRules" type="array">
  List of active earning rules.

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

    <ResponseField name="name" type="string">
      Internal name of the rule.
    </ResponseField>

    <ResponseField name="description" type="string">
      Description of how points are earned.
    </ResponseField>

    <ResponseField name="action" type="string">
      The trigger action (e.g. `"place_order"`, `"create_account"`, `"birthday"`).
    </ResponseField>

    <ResponseField name="category" type="string">
      Rule category (e.g. `"purchase"`, `"social"`, `"engagement"`).
    </ResponseField>

    <ResponseField name="isActive" type="boolean">
      Whether the rule is currently active.
    </ResponseField>

    <ResponseField name="pointsToGive" type="number">
      Number of points awarded.
    </ResponseField>

    <ResponseField name="customerFacingLabel" type="string">
      Label to display to customers.
    </ResponseField>

    <ResponseField name="callToActionUrl" type="string | null">
      URL for the call-to-action button, or `null` if not set.
    </ResponseField>

    <ResponseField name="customerEarningRule" type="object | null">
      The customer's specific earning record for this rule, or `null` if the customer hasn't triggered it.
    </ResponseField>
  </Expandable>
</ResponseField>

## Sample response

```json theme={null}
{
  "success": true,
  "data": {
    "earningRules": [
      {
        "id": "rule_abc",
        "name": "Points for purchase",
        "description": "Earn 10 points per \u00a31 spent",
        "action": "place_order",
        "category": "purchase",
        "isActive": true,
        "pointsToGive": 10,
        "customerFacingLabel": "Earn 10 points per \u00a31 spent",
        "callToActionUrl": null,
        "customerEarningRule": null
      }
    ]
  }
}
```
