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

# Update Segment

`PATCH /v1/segments/{id}`

Update a segment. Requires API key with audience:write.

## Path parameters

- `id` string, required

## Request body

- UpdateAudienceRequest
  - `name` string
  - `description` string
  - `filters` AudienceFilters
    - `tags` string[]
    - `excludeTags` string[]
    - `status` 'subscribed' | 'unsubscribed' | 'non-subscribed' | 'bounced'
    - `validationStatus` 'valid' | 'invalid' | 'risky' | 'unknown'
    - `customFields` object
    - `fields` object[]
      - `key` string, required
      - `mode` 'is' | 'is_not' | 'starts_with' | 'ends_with' | 'contains' | 'not_contains' | 'date_after' | 'date_before' | 'date_on' | 'date_between' | 'number_gt' | 'number_gte' | 'number_lt' | 'number_lte' | 'number_between'
      - `values` string[], required
    - `activity` object[]
      - `action` 'sent' | 'opened' | 'clicked', required
      - `channel` 'email' — Email is the only supported activity channel today.
      - `mode` 'within' | 'before' | 'never' | 'between', required — between is reserved and currently rejected.
      - `unit` 'hours' | 'days'
      - `amount` integer — Required for within/before. days: 1-365, hours: 1-8760.
      - `from` string, date-time
      - `to` string, date-time
      - `campaignId` string
  - `projectId` string, required

## Response `200`

Segment updated

- ApiResponseAudience
  - `success` boolean, required
  - `data` object, nullable
    - `id` string
    - `name` string
    - `description` string
    - `filters` AudienceFilters
      - `tags` string[]
      - `excludeTags` string[]
      - `status` 'subscribed' | 'unsubscribed' | 'non-subscribed' | 'bounced'
      - `validationStatus` 'valid' | 'invalid' | 'risky' | 'unknown'
      - `customFields` object
      - `fields` object[]
        - `key` string, required
        - `mode` 'is' | 'is_not' | 'starts_with' | 'ends_with' | 'contains' | 'not_contains' | 'date_after' | 'date_before' | 'date_on' | 'date_between' | 'number_gt' | 'number_gte' | 'number_lt' | 'number_lte' | 'number_between'
        - `values` string[], required
      - `activity` object[]
        - `action` 'sent' | 'opened' | 'clicked', required
        - `channel` 'email' — Email is the only supported activity channel today.
        - `mode` 'within' | 'before' | 'never' | 'between', required — between is reserved and currently rejected.
        - `unit` 'hours' | 'days'
        - `amount` integer — Required for within/before. days: 1-365, hours: 1-8760.
        - `from` string, date-time
        - `to` string, date-time
        - `campaignId` string
    - `count` integer — Number of contacts matching the segment filters
    - `createdAt` string, date-time
    - `updatedAt` string, date-time
  - `error` string, nullable

## Other responses

- `400` — Bad request
- `401` — Unauthorized
- `404` — Resource not found

---

[API](https://skmtc.net/migma/apis/migma-ai-api-v1.md) · [All operations](https://skmtc.net/migma/apis/migma-ai-api-v1/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/migma/migma-ai-api-v1/revisions/3f3dba69574b/schema)
