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

# Update Segment

> Update a saved subscriber segment

Update a segment name or filter definition. You can send either legacy `filters` or a nested `root`, not both.

## Request

<ParamField path="segmentId" type="string" required>
  Segment ID.
</ParamField>

<ParamField body="name" type="string">
  New segment name.
</ParamField>

<ParamField body="filters" type="FilterLeaf[]">
  Legacy v1 filter array.
</ParamField>

<ParamField body="filterJoinOperator" type="string">
  `and` or `or` for legacy v1 filters.
</ParamField>

<ParamField body="root" type="FilterGroup">
  Nested v2 filter group for nested logic, event filters, or segment filters.
</ParamField>

Stripe trial subfilters stay under `field: "stripeTrialProduct"`:
`prod_123:is_canceled`, `prod_123:end_at:2026-05-26`, or
`prod_123:start_at:7 days ago`.

Every filter field validates its own operator set:

* `status`, `segment`: `is`, `is_not`
* `tag`: `contains`, `not_contains`, `is_empty`, `is_not_empty`
* `email`: `contains`, `not_contains`
* `emailProvider`, `list`: `is`, `is_not`, `is_empty`, `is_not_empty`
* `firstName`, `lastName`: `contains`, `not_contains`, `is_empty`, `is_not_empty`
* `added`: `less_than`, `more_than`
* `attribute`: equality, empty checks, numeric/date comparisons, and contains checks
* `event`, email engagement fields: `is`, `is_not`, `at_least`, `less_than_count`
* `emailBounced`: also supports `is_temporary_bounce`, `is_permanent_bounce`
* Stripe product fields: product-specific purchase/current/trial/date operators

```bash theme={null}
curl -X PATCH "https://api.sequenzy.com/api/v1/segments/seg_active_non_buyers" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Active non-buyers - 30 days",
    "root": {
      "kind": "group",
      "id": "root",
      "joinOperator": "and",
      "children": [
        {
          "kind": "filter",
          "id": "filter-1",
          "field": "event",
          "operator": "is_not",
          "value": "saas.purchase:30d"
        }
      ]
    }
  }'
```

## Responses

<ResponseExample>
  ```json 200 theme={null}
  {
    "success": true,
    "segment": {
      "id": "seg_active_non_buyers",
      "name": "Active non-buyers - 30 days",
      "filters": [
        {
          "id": "filter-1",
          "field": "event",
          "operator": "is_not",
          "value": "saas.purchase:30d"
        }
      ],
      "filterJoinOperator": "and",
      "format": "v2",
      "root": {
        "kind": "group",
        "id": "root",
        "joinOperator": "and",
        "children": [
          {
            "kind": "filter",
            "id": "filter-1",
            "field": "event",
            "operator": "is_not",
            "value": "saas.purchase:30d"
          }
        ]
      }
    }
  }
  ```

  ```json 400 theme={null}
  {
    "success": false,
    "error": "Provide either root or filters, not both"
  }
  ```

  ```json 400 theme={null}
  {
    "success": false,
    "error": "Operator \"is not\" is not supported for Tag filters. Use one of: contains, does not contain, is empty, is not empty."
  }
  ```

  ```json 401 theme={null}
  {
    "success": false,
    "error": "Unauthorized"
  }
  ```

  ```json 404 theme={null}
  {
    "success": false,
    "error": "Segment not found"
  }
  ```
</ResponseExample>
