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

# Update a segment

`PATCH /segments/{id}`

## Request

- Base URL: `https://api.poststack.dev`
- URL: `https://api.poststack.dev/segments/{id}`
- Auth: one of:
  - HTTP bearer
  - OAuth 2
    - Authorization code: `https://poststack.dev/oauth/authorize`
    - Token URL: `https://poststack.dev/oauth/token`
- TypeScript: <https://skmtc.dev/poststack/apis/poststack-api/docs/segments/:id/patch.ts> (a function with typed inputs; its response is checked against the schema)

Partial update: send only what changes. `rules: null` turns a dynamic segment into a manual one; omitting `rules` keeps them.

## Path parameters

- `id` string, required

## Request body

- UpdateSegmentInput
  - `name` string
  - `rules` object, nullable
    - `operator` 'and' | 'or', required
    - `conditions` object[], required
      - `field` string, required
      - `comparator` 'equals' | 'not_equals' | 'contains' | 'starts_with' | 'ends_with' | 'greater_than' | 'less_than' | 'greater_than_or_equal' | 'less_than_or_equal' | 'before' | 'after' | 'in_last_days' | 'is_set' | 'is_not_set', required
      - `value` string
      - `windowDays` integer

## Response `200`

Updated.

- object
  - `segment` Segment, required
    - `id` integer, required
    - `publicId` string, required: `seg_…` id.
    - `name` string, required
    - `rules` object, nullable: Rules tree for a dynamic segment; null for a manual segment.
    - `contactCount` integer
    - `countUnavailable` boolean: Present and `true` when the count could not be computed.
    - `createdAt` string, date-time
    - `updatedAt` string, date-time

## Other responses

- `400`: Validation failed — `error` names each offending field (`field: message`).
- `401`: Missing, malformed or unknown credentials (`WWW-Authenticate: Bearer …` is set).
- `403`: The credential lacks the `contacts:manage` scope (body `{ error: "insufficient_scope", required, missing }`), or the team is suspended.
- `404`: No such resource on this team.
- `409`: Another segment already has that name.

## Changes

- **2026-09-30** `4dc1e20989c8`: 15 warning
  - added the new `daily_limit_exceeded` enum value to the `anyOf[#/components/schemas/Error]/code` response property for the response status `403`
  - added the new `daily_limit_exceeded` enum value to the `code` response property for the response status `400`
  - added the new `daily_limit_exceeded` enum value to the `code` response property for the response status `401`
  - added the new `daily_limit_exceeded` enum value to the `code` response property for the response status `404`
  - …11 more
- **2026-09-29** `ef5b22b98333`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/poststack/apis/poststack-api/changes/segments/:id/patch.md)

---

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