---
title: "Save a customer segment"
description: "Every filter is validated against the customer list's own allow-list, field by field and value by value, so a stored segment can never hold a predicate the list would later refuse."
canonical_url: "https://twominutebilling.com/help/developers/api-reference/customer-segments/save-a-customer-segment"
---
# Save a customer segment

> Every filter is validated against the customer list's own allow-list, field by field and value by value, so a stored segment can never hold a predicate the list would later refuse.

<api-operation method="POST" path="/v1/businesses/{biz}/customer_segments">
<template v-slot:docs="">

An attribute the stored data cannot express is refused with a 400 that NAMES it and says why — never answered slowly by rebuilding the book. A filter on `mrr` compares in the business's default currency: each live subscription's MRR is converted at the business's stored rate before comparing, and the value is minor units of that currency. Pin `currency is X` to compare natively in X instead. A held currency with no usable rate is refused, naming it.

## Path parameters

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Required
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        biz
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        yes
      </strong>
    </td>
    
    <td>
      Business id (biz_…)
    </td>
  </tr>
</tbody>
</table>

## Headers

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Required
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        Idempotency-Key
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      no
    </td>
    
    <td>
      Safely retry writes — repeats return the original response. If a write FAILED after it had already taken effect, that failure is what repeats: the key is spent, and a new attempt needs a new key.
    </td>
  </tr>
</tbody>
</table>

## Body

The request body is **required**.

<table>
<thead>
  <tr>
    <th>
      Field
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Required
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        name
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        yes
      </strong>
    </td>
    
    <td>
      The segment's name.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        description
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      no
    </td>
    
    <td>
      The segment's description.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        filters
      </code>
    </td>
    
    <td>
      <code>
        array of object
      </code>
    </td>
    
    <td>
      <strong>
        yes
      </strong>
    </td>
    
    <td>
      At least one. An empty set is 'all customers' wearing a name, which the screen already has an entry for.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        filters.field
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        yes
      </strong>
    </td>
    
    <td>
      A customer attribute, e.g. <code>
        country
      </code>
      
      , <code>
        mrr
      </code>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        filters.op
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        yes
      </strong>
    </td>
    
    <td>
      is, in, gt, gte, lt, between, in_last, …
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        filters.value
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <strong>
        yes
      </strong>
    </td>
    
    <td>
      Comma-separated for <code>
        in
      </code>
      
       and <code>
        between
      </code>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        starter_key
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      no
    </td>
    
    <td>
      Set when duplicating a starter, so the copy records where it came from.
    </td>
  </tr>
</tbody>
</table>

## Response

<table>
<thead>
  <tr>
    <th>
      Field
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        object
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The object type; always <code>
        customer_segment
      </code>
      
      . One of <code>
        customer_segment
      </code>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        id
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      seg_…, or seg_starter_… for a starter
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        name
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The segment's name.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        description
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The segment's description.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        filters
      </code>
    </td>
    
    <td>
      <code>
        array of object
      </code>
    </td>
    
    <td>
      The predicate, in the customer list's own filter grammar.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        is_starter
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      A definition that ships with the product. Present on every business, read-only, and not stored as a row.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        starter_key
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      Which starter this was copied from, if any.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        created_at
      </code>
    </td>
    
    <td>
      <code>
        string · ISO-8601
      </code>
    </td>
    
    <td>
      When the customer segment was created (ISO-8601 UTC).
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        updated_at
      </code>
    </td>
    
    <td>
      <code>
        string · ISO-8601
      </code>
    </td>
    
    <td>
      When the customer segment was last changed (ISO-8601 UTC).
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        answerable
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      On the list only: whether this business can resolve the segment. False for an <code>
        mrr
      </code>
      
       threshold with no currency pinned on a book billing in several currencies.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        refusal
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      On the list only: why it cannot be resolved here, or null when it can.
    </td>
  </tr>
</tbody>
</table>

## Status codes

<table>
<thead>
  <tr>
    <th>
      Status
    </th>
    
    <th>
      Meaning
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        201
      </code>
    </td>
    
    <td>
      Created
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        400
      </code>
    </td>
    
    <td>
      Invalid or refused filter set
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        409
      </code>
    </td>
    
    <td>
      A segment with that name already exists
    </td>
  </tr>
</tbody>
</table>
</template>

<template v-slot:request="">

```bash [Request]
curl -X POST "$TMBILLING_URL/v1/businesses/biz_XXXXXXXXXXXX01/customer_segments" \
  -H "Authorization: Bearer $TMBILLING_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Maya Castillo",
    "description": "Everything a growing team needs.",
    "filters": [
      {
        "field": "country",
        "op": "gte",
        "value": "West"
      }
    ]
  }'
```

</template>

<template v-slot:response="">
<code-group>

```json [201 Created]
{
  "object": "customer_segment",
  "id": "seg_XXXXXXXXXXXX01",
  "name": "Maya Castillo",
  "description": "Everything a growing team needs.",
  "filters": [
    {
      "field": "country",
      "op": "gte",
      "value": "West"
    }
  ],
  "is_starter": false,
  "starter_key": "high_mrr",
  "created_at": "2026-03-14T09:30:00Z",
  "updated_at": "2026-03-14T09:30:00Z",
  "answerable": false,
  "refusal": "This filter compares MRR across several currencies."
}
```

```json [400 Bad Request]
{
  "error": {
    "type": "invalid_request_error",
    "message": "Invalid or refused filter set"
  }
}
```

```json [409 Conflict]
{
  "error": {
    "type": "conflict_error",
    "message": "A segment with that name already exists"
  }
}
```

</code-group>
</template>
</api-operation>


## Sitemap

See the full [sitemap](https://twominutebilling.com/sitemap.md) for all pages.
