---
title: "Replace mutable segment fields"
method: PUT
path: "/api/v1/user/segments/{id}"
tags: ["User"]
---

# Replace mutable segment fields

`PUT /api/v1/user/segments/{id}`

When filters_json is present it follows UserSegmentFilters. Invalid or legacy fields return 400; unsupported indexed combinations return 422.

## Path parameters

- `id` integer, required

## Headers

- `X-CSRF-Token` string, required

## Request body

- UserSegmentUpdateRequest
  - `name` string
  - `description` string
  - `filters_json` UserSegmentFilters — Corporate-only filters executed exclusively over the immutable company_public_v2 sidecar. At least one effective anchor is required: provincia, cnae_prefix, a capital bound, a year bound or recent_days. `forma` and `estado` are deliberately not accepted; stored legacy filters containing either fail closed. Without provincia/cnae_prefix, capital and temporal anchors cannot be combined; capital-only anchors accept only capital_desc/capital_asc (or the default), and temporal-only anchors accept only recent/oldest (or the default).
    - `provincia` string — Canonical Spanish province name or supported alias; matched exactly after normalization.
    - `cnae_prefix` string
    - `capital_min` integer — Euros. Must not exceed capital_max when both are present.
    - `capital_max` integer — Euros. Must be greater than or equal to capital_min when both are present.
    - `year_min` integer — Inclusive year of the first documentary record; must not exceed year_max.
    - `year_max` integer — Inclusive year of the first documentary record; must be greater than or equal to year_min.
    - `recent_days` integer — First documentary record within this rolling number of days.
    - `sort` 'capital_desc' | 'capital_asc' | 'acts_desc' | 'oldest' | 'recent' — Indexed ordering. The accepted value depends on the effective anchor as documented in x-rejected-combinations.
  - `icon` string, nullable
  - `pinned` boolean

## Response `200`

Updated

- OkResponse
  - `ok` boolean, required

## Other responses

- `400` — Malformed/unknown or legally unavailable filter
- `401` — Authentication required (no active session)
- `403` — Invalid CSRF
- `404` — Resource not found
- `422` — Individually valid filters do not have a safe indexed combination

---

[API](https://skmtc.net/openmercantil/apis/openmercantil-public-api.md) · [All operations](https://skmtc.net/openmercantil/apis/openmercantil-public-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/openmercantil/openmercantil-public-api/versions/996f96a11758/schema)
