Skip to navigation

Segments

A segment is a named set of customers, such as “Key accounts” or “EMEA”. Sales teams manage classes of customers rather than one at a time, and finance reports by the same classes. Segments give those classes a home in billing: one named class, kept in one place, and usage reports that split by it, without metadata conventions that reports can’t read.

Use a segment to:

Segments are in the segments=v1 private beta: send Paid-Beta: segments=v1 with each request.

How segments work

  1. You create a segment with a key, such as key_accounts, which is how code and reports name it.
  2. You put customers in it with segments when you create a customer, and addSegments and removeSegments when you update one. A customer can be in up to 20 segments, and draft customers can be members.
  3. Reports read membership when you query them.

Segments, parents and units answer different questions:

UseWhenExample
SegmentCustomers that share a reporting class, but nothing elseKey accounts, EMEA, startups
Parent customerA customer that belongs to another, which pays for its orders by defaultA subsidiary under its group
Customer unitA part of one customer that shares its contractA team, environment or person

Create a segment

Trey Research tracks its 50 largest accounts as a class, and reviews the list each quarter:

Create a segment with a key and a name:

{
"key": "key_accounts",
"name": "Key accounts",
"description": "Top 50 accounts by ARR, reviewed each quarter",
"metadata": { "owner": "sales-ops" }
}
FieldWhat it’s for
keyYour stable name for the segment: 1 to 64 lowercase letters, digits and _. Unique on your account, archived segments included, and can’t change.
nameShown in the dashboard. Customers never see it.
descriptionWhat the segment is for, up to 500 characters.

Anywhere the API asks for a segment, pass its key or its seg_ ID. Responses name segments by key.

An account can have up to 500 segments, archived ones included. Creating another returns 400 segment_limit_reached. Archiving a segment doesn’t free a place, so reuse one where you can.

Add customers to a segment

Membership is set on the customer. Update the customer with the segments to add and the segments to remove:

PATCH /v1/customers/cus_8HqL2xT
{
"addSegments": ["key_accounts", "emea"],
"removeSegments": ["trial"]
}

Only the segments you name change, so two systems can add segments to the same customer at once without losing each other’s. Adding a segment the customer is already in, or removing one it isn’t in (an archived one included), is skipped, and a call that changes nothing returns the customer as it is. A segment that doesn’t exist, adding an archived segment, or naming one segment in both lists rejects the whole call, and nothing changes. The response’s segments is the customer’s full list, by key.

You can also set the starting segments when you create a customer. To see a segment’s members, list customers with the segment filter:

GET /v1/customers
?segment=key_accounts

Report by segment

Usage summaries filter by segment, or split by it with groupBy:

GET /v1/usage-summaries
?meters[]=output_tokens
&startsAt=2027-01-01T00:00:00Z
&endsAt=2027-04-01T00:00:00Z
&granularity=month
&groupBy[]=segment

A customer in two segments appears in both groups, so the groups can add up to more than the overall total. Customers in no segment are grouped under null. segment can’t be sent with customer.

Reports read membership when you query them, and there’s no membership history, so moving a customer between segments also changes how its past usage appears in segment reports.

Change or archive a segment

Update a segment to change its name, description or metadata. Its key can’t change.

Archive a segment when the class no longer exists. It’s removed from every customer’s segments, can’t be given to a customer, and stays readable with its key reserved.