# Subledgers

> A loyalty subledger is an individual loyalty points wallet within a loyalty program. You can create multiple subledgers for one loyalty program to control where your customers earn and redeem their loyalty points.

> For the complete documentation index, see [llms.txt](https://docs.talon.one/llms.txt).

They are useful in a situation where you are running multiple stores. For example,
subledgers allow you to specify that points earned in a store can only be redeemed at that
same store. This enables customers to have multiple separate balances concurrently without
creating a separate loyalty program for each store.

You can use subledgers in
[conditions or effects within the Rule Builder](/docs/product/rules/overview.md), or when you set the
[points required for a reward](/docs/product/rewards/create-rewards.md#set-points-required).

## Before you start

Ensure that you have:

- [Created a campaign](/docs/product/campaigns/create-and-manage-campaigns.md).
- [Enabled the loyalty feature](/docs/product/campaigns/settings/manage-campaign-features.md) in your campaign.
- Created a loyalty program that [supports subledgers](/docs/product/loyalty-programs/profile-based/create-pb-programs.md).

## Use a subledger in conditions

You can set a condition to validate the [loyalty points balance](/docs/product/tutorials/loyalty/loyalty-points-program.md)
in a subledger.

### Create a subledger

Creating a subledger accessor allows you to create a subledger and to use it in a condition.

1. Select the **Application** you want to use the loyalty feature in.
1. Click the **campaign** where you want to validate the loyalty points balance.
1. Click **Rule Builder** on the left-side menu.
1. Click **Access subledgers** at the top of the page.

   :::note
   - If you have not [created any rules yet](/docs/product/rules/create-and-manage-rules.md#create-a-rule),
     click **Create Rule** to see the button at the top of the Rule Builder page.
   - If you have already created one or more subledger accessors in the same campaign, click
     **Add Subledger Accessor** to create new ones.
   :::

1. In **Select loyalty program**, use the drop-down menu to choose a loyalty program that supports subledgers.
1. In **Subledger**, enter the name of the subledger. You can enter the name of a subledger created
   in a different campaign or Application to reuse it. If you enter a new name, a new subledger will be created.
1. In **Save as**, choose the name of the subledger accessor. This name appears in
   the [Attribute Selector](/docs/product/rules/overview.md#attribute-selector) when you create a condition.
1. Click **Save Subledger Balance**.

You see the subledger accessor in the **Access subledgers** section, above the rules. The
corresponding subledger is available in the Rule Builder, ready to be used in a condition.

### Validate the subledger balance

The subledger accessor created in the previous section automatically contains three balance attributes
that we can evaluate in a condition. To check the subledger balance:

1. Open the **Rule Builder** for your loyalty campaign.
1. Click **Create Rule**.
1. In **Conditions**, click **Add Condition**.
1. Select **Attribute** > **Check attribute value**.
1. Select the attribute you want to evaluate. In the Attribute Selector, your subledger accessor appears
   in the **Subledgers** category. Every subledger contains the following attributes:

   - <Attribute name="Current Balance (<subledger name>)" type="builtin" />: Points awarded immediately after a purchase.
   - <Attribute name="Pending Balance (<subledger name>)" type="builtin" />: Points awarded after a purchase but available after a specific period of time.
   - <Attribute name="Tentative Current Balance (<subledger name>)" type="builtin" />: Total points, including additions and deductions, during an active customer session.

1. Finish setting your validation check.
1. Click **Done**.

The condition is saved. You can set the effects of this condition by using the **Effects** section.

## Use a subledger in effects

Use the Rule Builder to add loyalty points to the balance of a subledger or redeem them
from a subledger that you created earlier.

- **Redeeming points from a subledger:** use the [**Redeem loyalty points** effect](/docs/product/rules/effects/use-effects.md#redeem-loyalty-points).

- **Adding points to a subledger:** use the [**Add Loyalty points**](/docs/product/rules/effects/use-effects.md#add-loyalty-points)
  and [**Add loyalty points per item** effects](/docs/product/rules/effects/use-effects.md#add-loyalty-points-per-cart-item).

## Related pages

- [Manage loyalty programs](/docs/product/loyalty-programs/manage-loyalty-programs.md)
- [Add loyalty points as an effect](/docs/product/rules/effects/use-effects.md#add-loyalty-points)
- [Rewards](/docs/product/rewards/overview.md)
