> ## Documentation Index
> Fetch the complete documentation index at: https://docs.solya.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Tagging rules — anatomy

> The tag model, the tagging-rule shape, and how rules assign tags to entities.

**Tags** label your entities; **tagging rules** assign them automatically. Tags drive
[alerts](/en/signals/alerts) and [workflow triggers](/en/developers/workflows/triggers),
so this is the "classify" half of *ingest → classify → automate*. For the user guide, see
[Tags & tagging rules](/en/automation/tags).

## Tag model

| Field         | Meaning                                                                                    |
| ------------- | ------------------------------------------------------------------------------------------ |
| `name`        | Tag name (unique per organization).                                                        |
| `type`        | **Kind**: `DATA` (auto-assigned by rules), `BUSINESS` (manual classification), or `MIXED`. |
| `color`       | Optional UI color.                                                                         |
| `description` | Optional.                                                                                  |
| `labels`      | Optional free-form metadata (string array).                                                |

A tag is applied to an entity through a **tag assignment**:

| Field                         | Meaning                                                                   |
| ----------------------------- | ------------------------------------------------------------------------- |
| `tagId`                       | The tag.                                                                  |
| `resourceId` + `resourceType` | The entity and its kind: `PRODUCT`, `BRAND`, `VARIANT`, `INVENTORY_ITEM`. |

Assignments are unique on `(tagId, resourceId, resourceType, organizationId)` — a tag can
be on an entity at most once.

## Tagging rule shape

A rule binds a **tag** to a set of **conditions** (and an optional **scope**):

| Field         | Meaning                                                                                                                      |
| ------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| `tagId`       | The tag this rule assigns.                                                                                                   |
| `name`        | Rule name (also the stable matching key on upsert).                                                                          |
| `description` | Optional.                                                                                                                    |
| `conditions`  | What must be true — see [Conditions](/en/developers/tagging-rules/conditions).                                               |
| `scope`       | Which entities to evaluate, and propagation — see [Scope & propagation](/en/developers/tagging-rules/scope-and-propagation). |
| `isActive`    | Whether the rule runs in automated evaluations.                                                                              |

```json theme={null}
{
  "name": "Auto-tag: Stockout in 7 days",
  "tagId": "<uuid>",
  "conditions": { "operator": "AND", "rules": [ /* … */ ] },
  "scope": { "entityType": "INVENTORY_ITEM" },
  "isActive": true
}
```

<Note>
  A rule has no kind of its own — it inherits its tag's `type`. Multiple rules can target
  the same tag.
</Note>

## How rules apply

Tags aren't applied live on edit; they're (re)computed by a **tag evaluation run** that
evaluates active rules and creates/removes assignments accordingly — see
[Runs & examples](/en/developers/tagging-rules/runs-and-examples).

```mermaid theme={null}
flowchart TB
  A["Define Rule<br/>(tag + conditions + scope)"] -->|Trigger| B["Tag Evaluation Run"]
  B -->|Evaluate Active Rules| C["Conditions Match"]
  C -->|Create/Remove<br/>Assignments| D["Tag Assignment Applied"]
```
