Skip to main content
Glama

Create Segment

create_segment
Destructive

Create a segment of the specified subtype. Segments are the typed cohort definitions — audiences are composition wrappers built from segments. filter: reusable filter definition — returns immediately with status active and an unset count unless count_snapshot is supplied. Call count_segment to calculate its saved count. similarity: provide seed_description (natural language) OR seed_segment_id — triggers async icp-segment workflow, returns status pending + workflow_run_id. Call wait_for_segment(segment_id) to block until active. propensity: provide positive_class_segment_id — triggers async ml-model workflow, returns status pending + workflow_run_id. Training can take 10–60 min. Call wait_for_segment(segment_id) to monitor. matched: upload a file — returns upload_url (30-min presigned), or upload_urls (an array, one per shard) when shard_count > 1. The upload is staged (not resolved automatically): PUT the raw file bytes to each returned URL with Content-Type matching file_format: csv=text/csv, avro=application/avro, json=application/json, jsonl=application/x-ndjson. Do not include the MCP bearer token in this upload. After uploading (all shards, if multiple), call analyze_audience_upload(segment_id) (analyzes the first shard only when sharded — all shards must share one schema), present the mappings to the user and wait for their response, then confirm_column_mappings(segment_id) to start resolution (or cancel_matched_upload(segment_id) if they decline) — only THEN call wait_for_segment(segment_id). Upload, analysis, and completed matched resolution emit no usage; the first successful delivery emits one aggregate platform_match usage set together with normal delivery usage. HITL: similarity and propensity default to hitl=false (auto-proceed through all gates). Set hitl=true to pause at review gates. Use file_format to specify csv (default), avro, json, or jsonl and compression=gzip for gzip bytes. Set shard_count > 1 for multiple same-format files; all shards must use the same compression and every CSV shard must include its own header row. Set create_audience=true to automatically wrap the new segment in an audience for immediate delivery. Optional campaign_id records the campaign the segment is built for and links that wrapper audience to it; omit it to leave both outside any campaign. Requires 'creator' scope.

Input Schema

NameRequiredDescriptionDefault
hitlNo(similarity/propensity) Enable human-in-the-loop gates. Default false = auto-proceed through all gates. Set true for interactive review.
nameYesHuman-readable segment name
filtersNo(filter) AND-combined conditions, reusable directly from discovery_count. Supply filters OR filter_groups, not both.
subtypeYesSegment subtype
campaign_idNoOptional campaign this segment is built for (see list_campaigns). Stored as origin_campaign_id; with create_audience, the wrapper audience is linked to it. An unknown ID is rejected with INVALID_CAMPAIGN_ID and nothing is created.
compressionNo(matched) Input transport compression. Use gzip for .csv.gz/.json.gz/.jsonl.gz bytes; object names remain based on file_format. gzip is NOT supported with file_format=avro (avro is already internally compressed) — the API rejects that combination with UNSUPPORTED_INPUT_COMPRESSION.none
file_formatNo(matched) Input file format. csv (default): every column is a single scalar value — multi-value/array fields are not supported. avro/json/jsonl: native array columns supported.
match_levelNo(matched) Restrict identity resolution to these match levels (Individual/Household/Digital/Spatial/Address). Omit to use the platform default (all levels).
shard_countNo(matched) Set > 1 for multiple same-format shards. All shards must use the same compression; every CSV shard must contain its own header row.
webhook_urlNo(similarity/propensity/matched) URL to receive a POST notification when the segment becomes active
record_limitNo(filter) Cap the segment at this many people (e.g. "up to 1,000"). Requires State, City, or ZIP Code filters narrowing every OR branch to at most 100 three-digit ZIP prefixes. Audiences and deliveries inherit the cap.
spatial_modeNo(matched) Spatial trade-area mode. residential is the default; use work for workplace-oriented spatial matching, or auto for dynamic commercial workplace routing.residential
filter_groupsNo(filter) Grouped conditions, reusable directly from discovery_count. Supply filters OR filter_groups, not both.
count_snapshotNo(filter) Existing verified count snapshot to store on the new segment; omit to leave the count unknown, then call count_segment for a fresh count
create_audienceNoWhen true, automatically creates an audience wrapper around the new segment for immediate delivery use. Returns both segment_id and audience_id.
seed_segment_idNo(similarity) Existing segment ID to use as seed — provide either seed_description or seed_segment_id, not both
seed_descriptionNo(similarity) Natural language ICP narrative describing the target segment persona
positive_class_segment_idNo(propensity) Segment ID whose members represent the positive class for ML training

Output Schema

NameRequiredDescriptionDefault
nameYes
statusYes
subtypeYes
guidanceNoInterpretation or recovery guidance for this result
count_unitNo
page_countNoNumber of objects on this page, not the organization total
segment_idYes
upload_urlNo
audience_idNo
count_stateNoUnknown means no count; available does not guarantee freshness. Recount for a current value.
upload_urlsNo
next_actionsNoSuggested next calls using returned IDs and available scopes. Not executed and not user consent.
record_countNoStored count; null means unknown. Call count_segment for a current count.
record_limitNoMaximum members; null means no explicit cap
filter_groupsNoComplete saved filter definition; one AND group also represents a simple flat filter list
money_displayNoCurrency amounts formatted once from source paths ending in _cents. Use verbatim; do not divide again. Null/missing source amounts are omitted, not zero.
current_versionNo
workflow_run_idNo
population_inputNoPopulation input used for the preview; IDs refer to their current saved definitions
upload_expires_atNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Added
  2. Removed
  3. First observed

TDQS

A4.8/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Adds substantial context beyond annotations: async workflow behavior, pending statuses, 10–60 minute training, staged uploads with presigned URLs, token-handling warning, HITL defaults, usage-emission behavior, and creator scope requirement. These details materially help an agent understand side effects and operational sequencing.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is long but justified by four distinct subtypes and a complex matched-upload workflow. It is front-loaded with purpose and subtype distinctions, though the single dense paragraph and repeated wait_for_segment guidance reduce readability slightly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given an output schema and rich annotations, the description still covers the operational gaps an agent needs: subtype-specific prerequisites, async monitoring, upload resolution sequence, HITL behavior, scope requirements, and campaign linkage. Nothing critical appears missing for correct invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so parameter documentation is already strong, but the description adds subtype-specific meaning: seed_description vs seed_segment_id, positive_class_segment_id, file_format/compression/shard interactions, campaign_id linkage, and create_audience behavior. It does not explain every parameter, but it adds useful semantics beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ("Create a segment") and immediately clarifies segment subtypes and how segments differ from audiences. The subtype-specific behavior makes it easy to distinguish from sibling tools like create_audience, count_segment, and wait_for_segment.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly explains when to use each subtype and which follow-up tools to call: count_segment for filter counts, wait_for_segment for async similarity/propensity, and the analyze/confirm/cancel sequence for matched uploads. It also names the alternative actions when upload mappings are declined.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources