---
title: "Update a segment"
method: PATCH
path: "/api/v1/segments/{id}"
tags: ["Segments"]
---

# Update a segment

`PATCH /api/v1/segments/{id}`

## Request

- Base URL: `https://api.sendly.now`
- URL: `https://api.sendly.now/api/v1/segments/{id}`
- Auth: one of:
  - HTTP bearer
  - API key in cookie `better-auth.session_token`
  - OAuth 2 (authorization code, authorization URL `https://app.sendly.now/api/auth/oauth2/authorize`, token URL `https://app.sendly.now/api/auth/oauth2/token`, scopes: `segments:write`)

Partial update: an omitted field is left untouched. Changing a `DYNAMIC` segment's `condition` recomputes `member_count` in the same call, so the returned object never states a size that belongs to the previous filter. `condition` is ignored on a `STATIC` segment, whose membership is the explicit list.

`type` is not accepted here — see the create operation.

Requires the `segments:write` scope — Create, edit, and delete your segments.

## Path parameters

- `id` string, uuid, required: Resource id.

## Request body

- SegmentV1Update: Body for PATCH /api/v1/segments/{id}. `type` is deliberately absent — it is fixed at creation. `condition` is ignored on a STATIC segment.
  - `condition` FilterConditionV1: A filter condition: one or more groups combined with `logic`.
    - `groups` FilterGroupV1[], required
      - `conditions` FilterConditionV1 (recursive)
      - `filters` SegmentFilterV1[], required
        - `field` string, required
        - `operator` 'equals' | 'notEquals' | 'contains' | 'notContains' | 'greaterThan' | 'lessThan' | 'greaterThanOrEqual' | 'lessThanOrEqual' | 'exists' | 'notExists' | 'within' | 'olderThan' | 'triggered' | 'triggeredWithin' | 'triggeredOlderThan' | 'notTriggered' | 'notTriggeredWithin' | 'isMemberOf', required
        - `unit` 'days' | 'hours' | 'minutes'
        - `value` unknown
    - `logic` 'AND' | 'OR', required
  - `description` string
  - `name` string
  - `track_membership` boolean

## Response `200`

The updated segment

- SegmentV1: A segment as exposed on the v1 API.
  - `condition` FilterConditionV1, required: A filter condition: one or more groups combined with `logic`.
    - `groups` FilterGroupV1[], required
      - `conditions` FilterConditionV1 (recursive)
      - `filters` SegmentFilterV1[], required
        - `field` string, required
        - `operator` 'equals' | 'notEquals' | 'contains' | 'notContains' | 'greaterThan' | 'lessThan' | 'greaterThanOrEqual' | 'lessThanOrEqual' | 'exists' | 'notExists' | 'within' | 'olderThan' | 'triggered' | 'triggeredWithin' | 'triggeredOlderThan' | 'notTriggered' | 'notTriggeredWithin' | 'isMemberOf', required
        - `unit` 'days' | 'hours' | 'minutes'
        - `value` unknown
    - `logic` 'AND' | 'OR', required
  - `created_at` string, date-time, required
  - `description` string, nullable, required
  - `id` string, uuid, required
  - `member_count` integer, required
  - `name` string, required
  - `track_membership` boolean, required
  - `type` 'DYNAMIC' | 'STATIC', required
  - `updated_at` string, date-time, required

## Other responses

- `400`: `validation_error` — the new `condition` filters on a field contacts cannot be filtered on or uses an operator that field does not have.
- `401`: `invalid_api_key` or `invalid_session` — missing or invalid credentials.
- `403`: `scope_missing`, `project_access_denied`, or `project_disabled`.
- `404`: `resource_not_found` — no segment with this id belongs to the authenticated project.
- `422`: `validation_error` — query, path, or body parameters did not match the schema.
- `429`: `rate_limited` — see `Retry-After` and the `RateLimit` headers.
- `500`: `internal_error`.

---

[API](https://skmtc.dev/sendly/apis/sendly-api.md) · [All operations](https://skmtc.dev/sendly/apis/sendly-api/llms.txt) · [OpenAPI document](https://skmtc.dev/sendly/apis/sendly-api/revisions/ce7cfb7f7c7e?raw)
