# Segments and allocation rules

The **Segments** page, under Reporting, assigns each cost line in a workspace to one owner. The principles are in [Allocation model](/concepts/allocation-model); this page covers the steps.

## Before you start

- Viewing segments needs any team role. Adding and changing segments and rules needs the Owner or Editor team role in a workspace your team can edit.
- Your plan limits how many allocation rules a workspace can have; see the [pricing page](https://costfluent.com/pricing).
- Tagged resources make rules simpler. Check [tag coverage](/allocation/tags) first.

## Add a segment

1. Under **Segments**, select **Add segment**.
2. Enter the **Team**, **Product** and **Cost centre** and save. The team is a name, so an owner does not have to exist as a team in Costfluent first.

The Public API can also link a segment to one of your organization's teams (`teamId`) or create a shared cost bucket (`isShared`), whose cost is spread across the direct segments. A shared bucket appears in the product as **Shared cost** and can be chosen as a rule's segment.

Team, product and cost centre together identify a segment, so two segments cannot have the same three. Rules point at a segment by identity, so renaming one changes no rule.

## Add a rule

1. Under **Rules**, select **Add rule** and give it a **Name**.
2. Under **Matches**, choose the **Field** (Account or subscription, Resource group, Resource name or Tag), the **Comparison** (equals, starts with, ends with or contains) and the **Value**. For Tag, also enter the **Tag key**. Values are compared as literal text, with no wildcards and no regular expressions.
3. Choose the **Segment** the rule assigns cost to.
4. Set the **Priority**. Lower wins. Leave gaps, such as 10, 20, 30, so a later rule can be placed in between.
5. Select **Preview**. **What this rule would move** shows the amount and how coverage would change, computed on the same committed cost a report reads. Nothing is saved yet.
6. Save the rule.

**Claims cost** turns a rule on or off without deleting it. **Move up** and **Move down** reorder rules.

## Read coverage

**Coverage** shows, for the window it names, the **Total** and how much of it is **Direct**, **Shared** and **Unallocated**. When shared cost has no direct segment to spread across, the page says how much was counted as unallocated for that reason.

To see cost per segment over time, open a cost report and set **Group by** to Segment.

## How it behaves

- Rules are evaluated when a report is read. Adding, disabling, reordering or deleting a rule changes what every past month says, not just future ones.
- The first matching rule claims a cost line; nothing is claimed twice.
- Deleting a rule makes the cost it claimed unallocated in every month.
- A segment cannot be deleted while a rule still assigns cost to it. Re-point or delete those rules first.

## Related

- [Allocation model](/concepts/allocation-model)
- [Virtual tags](/allocation/virtual-tags)
- [Budgets](/planning/budgets)
