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

# Update a segment condition

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

## Request

- Base URL: `https://app.convertflow.co`
- URL: `https://app.convertflow.co/api/v1/segments/{id}/conditions/{condition_id}`
- Auth: HTTP bearer

Replaces one or more values of a segment condition and republishes the website script, so every live campaign targeting the segment changes for visitors at once. The body keys are the settings of the condition type as GET /api/v1/segments/condition_types lists them: free-text settings take any value, number settings a whole number, select settings one of the available options (ids for campaigns, segments and tags; values for device type and contact fields; field slugs for custom fields; comma-separated ISO alpha-2 codes for countries). Region and city keywords are comma-separated full names and replace the whole list; two-letter region abbreviations are refused because visitor geolocation reports full names. A key that is not a setting of the condition type answers 422, as do condition types without settings and integration conditions. Requires segments:write.

## Request body

- object
  - `keyword` string: Text or number setting (region/city names comma-separated)
  - `url` string: URL, cookie or global variable name
  - `count` integer: Number setting
  - `country` string: ISO alpha-2 country codes, comma-separated
  - `condition_cta` integer: Campaign id
  - `tag_id` integer: Tag id
  - `device` string: desktop or mobile
  - `conditions_group_id` integer: Segment id
  - `attribute` string: Contact field name
  - `slug` string: Custom field slug
  - `operator` 'and' | 'or': How the condition combines with the others in the segment

## Response `200`

condition updated; the website republishes only when a value changed

- object
  - `id` integer
  - `name` string
  - `website_id` integer
  - `conditions` object[]
    - `id` integer
    - `condition_type` string
    - `operator` string
    - `keyword` string, nullable
    - `country` string, nullable
    - `url` unknown
    - `count` integer
    - `condition_cta` integer
    - `tag_id` unknown
    - `data` object
      - `conditions_group_id` string
      - `device` string
  - `created_at` string, date-time
  - `updated_at` string, date-time

## Other responses

- `403`: token lacks the segments:write scope
- `404`: condition belongs to another segment
- `422`: segment cannot nest itself, directly or through another segment

---

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