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

# Earning rule object

> The earning rule object defines how customers earn points.

Earning rules define the actions customers can take to earn points. Rules are categorized by type — purchase, social, engagement, birthday, anniversary, etc.

## Attributes

| Field                   | Type           | Description                                                                                        |
| ----------------------- | -------------- | -------------------------------------------------------------------------------------------------- |
| `name`                  | string         | Rule display name                                                                                  |
| `description`           | string \| null | Optional description                                                                               |
| `action`                | string         | The action type (e.g. `place_order`, `follow_on_instagram`, `signup`)                              |
| `category`              | string         | Rule category: `purchase`, `social`, `engagement`, `birthday`, `anniversary`, `signup`, `referral` |
| `is_active`             | boolean        | Whether the rule is currently active                                                               |
| `points_to_give`        | integer        | Base points awarded when the rule is completed                                                     |
| `customer_facing_label` | string \| null | Label shown to customers (e.g. "Earn 10 points per £1 spent")                                      |
| `call_to_action_url`    | string \| null | URL for the action (e.g. Instagram profile link)                                                   |
| `created_at`            | string         | ISO 8601 timestamp                                                                                 |
| `updated_at`            | string         | ISO 8601 timestamp                                                                                 |

## Example

```json theme={null}
{
  "type": "earning_rule",
  "id": "rule_abc",
  "attributes": {
    "name": "Points for purchase",
    "description": null,
    "action": "place_order",
    "category": "purchase",
    "is_active": true,
    "points_to_give": 10,
    "customer_facing_label": "Earn 10 points per £1 spent",
    "call_to_action_url": null,
    "created_at": "2024-01-01T00:00:00.000Z",
    "updated_at": "2024-01-01T00:00:00.000Z"
  }
}
```
