---
title: "Replace the active defect priority mapping (priority values only)"
method: PUT
path: "/defect-priority-mapping"
tags: ["Assets"]
---

# Replace the active defect priority mapping (priority values only)

`PUT /defect-priority-mapping`

Versioned write: deactivates the prior active row and inserts a
new one with `version+1`. Customer-facing edits are LIMITED TO
priority values: the `(Equipment, Type, Defect)` keyset is
immutable from this endpoint. Adding or removing keys requires a
super-admin re-import via the admin API after the CVAT project
schema is updated -- 409 with `code='schema_keys_immutable'`
when the request would change the keyset.

Optional `applyToExisting` (default false) bulk-rewrites every
existing defect row whose `(asset_type, defect_name)`
tuple has a changed priority value, while preserving rows
marked `priority_source='manual'`.

Permission: `defects:write`.

## Headers

- `Idempotency-Key` string, uuid

## Request body

- object
  - `mapping` object, required — Three-level Equipment / Type / Defect JSONB. See voltair-admin-api/src/service/defect_priority_mapping.go::validateMappingShape for the canonical shape; it is enforced server-side.
  - `applyToExisting` boolean

## Response `200`

Success

- object
  - `data` object, required
    - `id` string, uuid, required
    - `version` integer, required
    - `mapping` object, required
    - `defectsUpdated` integer, required
    - `assetsRecomputed` integer, required
    - `sitesRecomputed` integer, required
  - `transactionId` string, uuid, required

## Other responses

- `400` — Bad request or validation error
- `401` — Authentication required
- `403` — Insufficient permissions
- `409` — Mapping keyset differs from the active version (or asset_type changed).
- `429` — Rate limit exceeded
- `500` — Internal server error

---

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