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

# Segment tools

> MCP tools for creating and editing audience segments.

Segment tools define who a campaign targets. A segment is a set of visitor conditions, such as device, location, or custom data, and every campaign that uses it targets only the visitors who match.

## Tools

| Tool | Description | Example prompt |
| - | - | - |
| `segment_list` | Browse segments on a site, with usage counts. | "List segments for site `d1alzzxd7k`." |
| `segment_get` | Inspect a segment's condition tree (raw JSON plus a human-readable summary). | "Show segment `200604`." |
| `segment_create` | Create an audience segment from a condition tree. It accepts every condition type of the segment builder, such as geolocation, device, browser, custom data, visitor code, cookie, and conversions. A tree has at most two levels. | "Create a segment for desktop visitors in France." |
| `segment_update` | Change a segment's name, description, or conditions, using any condition type of the segment builder. Every campaign that uses the segment targets the new audience right away. Changing the conditions of a segment used by anything other than draft experiments, or referenced by another segment, needs confirmation. | "Add Belgium to segment `200604`." |
| `segment_delete` | Delete a segment. The tool blocks deletion by default when the segment is in use, including when another segment uses it; override with `force`. | "Delete segment `200604`." |

> [!NOTE]
>
> Segment conditions take at most two levels: groups of conditions joined by a top-level `AND` or `OR`. The tool refuses a deeper condition tree with an explanation instead of flattening it, because flattening can widen the audience. Ask your AI assistant to rewrite the tree in two levels.

## Condition types

`segment_create` and `segment_update` accept every condition type of the segment builder. The existing conditions, such as geolocation, device type, browser, and custom data, stay available. The following groups are also available:

* Visitor code (`VISITOR_CODE`), cookie (`COOKIE`), JS code (`JS_CODE`), and ad blocker (`AD_BLOCKER`).
* SDK language and app version (`SDK_LANGUAGE`, `APPLICATION_VERSION`).
* Conversions (`CONVERSIONS`).
* AI Targeting (`HEAT_SLICE`).
* Targeted experiment, personalization, or feature flag (`TARGET_EXPERIMENT`, `TARGET_PERSONALIZATION`, `TARGET_FEATURE_FLAG`).
* Exclusive experiment (`EXCLUSIVE_EXPERIMENT`).
* Segment in segment (`SEGMENT`).
* Tealium audiences and badges (`TEALIUM_AUDIENCE`, `TEALIUM_BADGE`).

A condition that can't exclude, namely exclusive experiment, new or returning visitors, and event, refuses `include=false` instead of switching to include. Deleting a segment that another segment uses requires `force`, and changing its conditions needs confirmation with `confirm`. The tools refuse references to the goals, experiments, feature flags, or segments of another site.

## Parameters

Use the exact parameter names that `tools/list` returns.

| Tool | Required parameters | Optional parameters |
| - | - | - |
| `segment_list` | None | `siteCode`, `query`, `page`, `perPage` |
| `segment_get` | `segmentId` | None |
| `segment_create` | `name`, `siteCode` | `conditionDataTree` (any condition type of the segment builder), `description` |
| `segment_update` | `segmentId` | `name`, `description`, `conditionDataTree` (replaces the whole tree; any condition type of the segment builder), `confirm` (required when the conditions change on a segment used by anything other than a draft experiment, or by another segment) |
| `segment_delete` | `segmentId` | `force` (required when an experiment, personalization, feature flag, or another segment uses the segment) |
