# Update Value Center

Operation ID: `updateValueCenter`

Group: Value Accounting › Value Centers

[Open in the interactive reference](https://lensing.ai/api-docs/lensing/v1/endpoints/updateValueCenter)

`PATCH /value-accounting/value-centers/{id}`

Retry-safe: A write that accepts Idempotency-Key: repeating a request with the same key replays the stored answer instead of executing twice.

Partially update one value center — its fields, its place in the tree and its master-data mappings — in one transaction. WRITES; returns an empty body unless it deleted or healed mappings (removedMappingIds, healedMappingIds). Only what is sent is written. Fields: name, description (null clears), centerCode (null clears), startDate, endDate (a date ends it together with every mapping still open after that day, which ends on the same day; a later date on a value center that already ended moves the mappings ending on its previous day with it; null CLEARS an end of today or later (a schedule that never took effect; the mappings ending with it follow) and is REFUSED with REACTIVATE_VIA_FLOW on an end before today — re-open with reactivateValueCenters (POST value-accounting/value-centers/reactivate)), categoryId (null clears), parentId (moves it; null makes it a root; never under itself or a descendant — CYCLE). Mappings: createMappings adds records (the same record on two entries with different dates is DUPLICATE_MAPPING_ROW, judged first; one this value center maps with an OPEN mapping is MAPPING_EXISTS unless the same request deletes that mapping — an ended mapping is history and does not count, judged on the end dates as the request leaves them: a mapping ended in the same request no longer counts, one re-opened in it does; a new mapping starts today, or on the value center's own startDate when that is later, unless startDate is sent, and without an endDate it ends with the value center — it inherits the value center's endDate as the request leaves it, open-ended only when there is none; a mapping never outlives its value center, so an endDate later than the value center's on a createMappings or updateMappings row is MAPPING_OUTLIVES_END), updateMappings re-dates existing mappings by their id (endDate: null refused the same way; an id sent twice counts once, its first row; on a value center that has ended — its endDate as the request leaves it, before today — an endDate today or later on a createMappings or updateMappings row is refused with REACTIVATE_VIA_FLOW too), deleteMappings removes mappings by their id; mapping ids are mappings[].id of getValueCenter (GET value-accounting/value-centers/:id) and must belong to this value center (MAPPING_NOT_FOUND, MAPPING_MISMATCH). inCluster follows the OPEN mapping set: true on every mapping while more than one record is mapped by mappings open today; a mapping that ended in the past does not count, so a link moved by ending one mapping and creating another stays 1:1. It is settled by a request that adds or removes mappings, or ends or re-opens one as of today. A value center may be left with no mapping. A value center the system maintains for a department or team (isSystemManaged) refuses changes to name, centerCode, startDate, categoryId and mappings with SYSTEM_MANAGED (its parentId stays editable: no Department/Team hook places it in the tree), and a null description with DESCRIPTION_NOT_CLEARABLE; its mappings end with it (send endDate on the value center, never on a mapping); re-sending a stored value is not a change. Dates are judged on the end state the request leaves: END_BEFORE_START (the value center), INVALID_DATE_RANGE (a mapping starting after its own end, an end it follows included), MAPPING_STARTS_BEFORE_OWNER (a sent mapping start before the value center's), START_AFTER_MAPPING_HISTORY (a later start past a mapping that already ended; the running mappings move with it). Ending it earlier DELETES a mapping that would only start after the new end (removedMappingIds), and ends other value centers' mappings naming it on that day (deleting, and listing, those that would only start after it); an updateMappings row healed to the value center's end is listed in healedMappingIds; deleteMappings, and updateMappings rows under an earlier end, are applied before the value center is written. Other refusals: NOT_FOUND, NAME_REQUIRED, CENTER_CODE_TAKEN, PARENT_NOT_FOUND, CATEGORY_NOT_FOUND, and for createMappings UNSUPPORTED_DIMENSION_CODE / RECORD_NOT_FOUND / MAPPING_EXISTS (MAPPING_EXISTS also for an updateMappings row re-opening an ended mapping onto a record another open mapping names). A request leaving this value center standing alone for a record another value center already represents one-to-one (open, non-cluster) — a first mapping, or a cluster cut back to one record — is ONE_TO_ONE_EXISTS: a record has at most one open one-to-one value center, whoever made it. Every check runs first, so a rejected call writes nothing. A PATCH that changes nothing — an empty body, or every field sent with its stored value — is not written, so lastModifiedDate does not move; the same holds for each updateMappings row. An endDate moved into the future on a value center that already ended re-opens the mappings that move with it and is refused with ONE_TO_ONE_EXISTS when that leaves it standing alone for a record another value center represents one-to-one with an open mapping.

Partially updates one value center — its own fields, its place in the tree and its master-data mappings — in one transaction, and returns an empty body — or, only when it deleted or healed mappings, their ids (`removedMappingIds`, `healedMappingIds`).

Only what you send is written: omit a field to leave it unchanged. `description: null`, `centerCode: null` and `categoryId: null` clear. `parentId` moves the value center under another value center; `parentId: null` makes it a root — it stays in the tree. A move can never hang a value center under itself or one of its own descendants (`CYCLE`): such a loop would silently remove every value center in it from the tree.

The mappings are edited through three verb arrays beside the fields: `createMappings` adds mappings to new records, `updateMappings` changes the dates of existing mappings (by mapping id), `deleteMappings` removes mappings (by mapping id). Mapping ids are the `mappings[].id` of getValueCenter (GET value-accounting/value-centers/:id), and only this value center's own mappings can be named (`MAPPING_MISMATCH` otherwise). A value center may be left with no mapping at all. A record is linked once at a time: `createMappings` naming a record this value center maps with an OPEN mapping fails with `MAPPING_EXISTS` — unless the same request deletes that mapping; a mapping that already ended is history, so naming its record again (moving a link back) adds a new mapping. Openness is judged on the end dates as the request leaves them: a mapping ended by `updateMappings` in the same request no longer counts (end it yesterday and link its record afresh in one call), and one re-opened there with a future `endDate` does — re-opening an ended mapping onto a record another open mapping names fails with `MAPPING_EXISTS` too. A new mapping starts today unless you send its `startDate`, or on the value center's own start date when that is later. Whenever more than one record is mapped by mappings open today (no `endDate`, or one not yet passed), every one of the value center's mappings reads `inCluster: true`, and none of those records resolves to it as its own value center. A mapping that ended in the past does not count: ending the old mapping with `updateMappings` and adding the new record with `createMappings` in one request MOVES the link, and the value center stays 1:1, resolving under its new record. The flag is settled by a request that adds or removes mappings, or whose `updateMappings` end or re-open a mapping as of today; a date change that leaves every mapping open or closed today as it was leaves it as it stands.

Ending is a plain write, re-opening is not: an `endDate` DATE on the value center or on a mapping ends it, but `endDate: null` on the value center clears an end of today or later (a schedule that never took effect; the mappings ending with it follow), and fails with `REACTIVATE_VIA_FLOW` on an end before today and on any mapping — a value center and its mappings are re-opened together, and never under an ended parent, by reactivateValueCenters (POST value-accounting/value-centers/reactivate). On a value center that has ended — its `endDate`, as the request leaves it, before today — the same code refuses any mapping the request would leave open after that day: an `endDate` today or later on a `createMappings` or `updateMappings` row. A link cannot outlive its value center: a `createMappings` row sent without an `endDate` ends with the value center — it inherits the value center's `endDate` as the request leaves it (open-ended only when it has none) — and any row sending an `endDate` later than that fails with `MAPPING_OUTLIVES_END`. An `updateMappings` id sent twice counts once, its first row; a `createMappings` entry repeated with the same dates counts once, while the same record on two `createMappings` entries with different dates is refused with `DUPLICATE_MAPPING_ROW` (one entry per record per request; a second link period is a second request). Ending the value center — an `endDate` on an open one, or an earlier one than stored — ends every mapping still open after that day on the same day, as a delete would close them (a mapping that ended earlier keeps its day); a mapping that would only start after that day is never in effect inside the value center's life and is DELETED — `removedMappingIds` in the response lists it. The mappings of OTHER value centers that name this value center as their record follow the same closing: they end on that day, or are deleted and listed in `removedMappingIds` too. Moving the `endDate` of a value center that already ended to a LATER day moves its mappings ending on the previous day — the ones its retirement closed — with it. Either way reactivating re-opens exactly those mappings together; a mapping ended on another day stays.

Dates are judged on the END STATE the request leaves: the value center must not end before it starts (`END_BEFORE_START`); a mapping must not start after its own end (`INVALID_DATE_RANGE`, on the dates it is left with — an end it follows included) nor before the value center (`MAPPING_STARTS_BEFORE_OWNER`, on a start the request sends); a `startDate` moved LATER takes the mappings still running on the new day along, and a mapping that ended before it refuses the move (`START_AFTER_MAPPING_HISTORY`). On a value center with an end date, an `updateMappings` row sending a `startDate` but no `endDate` for a mapping left open (or ending after the value center) is written with the value center's end and listed in `healedMappingIds`. `deleteMappings`, and `updateMappings` rows under an earlier end, are applied before the value center itself is written, so a mapping the request deletes or re-dates never blocks it.

A value center the system maintains for a department or team (`isSystemManaged` on the reads) refuses changes to its name, centerCode, startDate, categoryId and mappings with `SYSTEM_MANAGED`, because the record's next change would overwrite them; its endDate, its description and its place in the tree (`parentId` — no Department/Team hook ever moves it, so you place it; `CYCLE`, `PARENT_NOT_FOUND` and `PARENT_INACTIVE` still apply) stay editable, and its description can be replaced but not cleared (`DESCRIPTION_NOT_CLEARABLE`). A mapping of such a value center ends with the value center: send `endDate` on the value center (or DELETE it), never on one of its mappings. Re-sending a stored value is never a change.

A record has at most one OPEN one-to-one value center, whoever made it — the automation, an import or a user; the first link stands and a second is refused. A request that leaves this value center standing alone for a record ANOTHER value center already represents one-to-one — its first mapping, or a cluster cut back to one record by `deleteMappings` or an `updateMappings` end date — fails with `ONE_TO_ONE_EXISTS`, naming the other value center and its mapping; end that link first or delete that value center (for a cut-back cluster: end or delete this whole value center). A value center that already stands alone for its record stays editable.

Every check runs before anything is written. A PATCH that changes nothing is not written at all and leaves lastModifiedDate untouched — this holds per mapping too: an `updateMappings` row that sends the stored dates is not written. Moving the end date of a value center that already ended into the future re-opens the mappings that move with it, and is refused with ONE_TO_ONE_EXISTS when another value center already holds an open one-to-one link to the record they name: end that link first.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `Api-Version` | header | string · v1 | yes | The API version this request targets, named by its public identifier. Required on every request; omitting it, or naming a version this company does not have, is answered with 400. This document describes version `v1`. |
| `Idempotency-Key` | header | string | no | An opaque caller-chosen string (1-255 characters) that makes this request safe to retry. Repeating the same key with an identical request body replays the original response instead of re-executing - but only once that original request succeeded; a failed attempt re-executes on retry. Repeating the key with a different body is answered with 422. A key still in flight is answered with 409 - as is a key whose original request was interrupted before it finished, for a few minutes afterwards, until that attempt is presumed dead. A completed response stays replayable for 24 hours. The key is scoped to the caller, not to the action: reusing it for a different action is answered with 409 or 422 rather than treated independently. On read actions this header is ignored. On write actions that cannot offer the guarantee it is answered with `400 IDEMPOTENCY_NOT_SUPPORTED` rather than silently ignored. |
| `id` | path | string | yes | Id (a UUID) of the value center to change; bound from the :id path segment. An id that matches no value center is rejected with NOT_FOUND. Ids are matched case-insensitively and returned in canonical lowercase. Example: `"6d2c8f31-b4a7-4e19-9f2b-77c0a1d4e5b2"`. |

## Request body

Required, `application/json`: updateValueCenterInput.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | string | no | New display name. OMIT TO LEAVE IT UNCHANGED; it cannot be cleared. When sent it must not be empty or whitespace only (NAME_REQUIRED). Stored exactly as sent, untrimmed. Refused with SYSTEM_MANAGED on a value center the system maintains, whose name follows its record — rename the record instead. |
| `description` | string \| null | no | New free-text explanation. OMIT TO LEAVE IT UNCHANGED; send null to clear it. Editable on a value center the system maintains too, but there it can only be REPLACED: null is refused with DESCRIPTION_NOT_CLEARABLE. |
| `centerCode` | string \| null | no | New tenant-assigned code. OMIT TO LEAVE IT UNCHANGED; send null, or an empty string, to clear it. Must be unused by any other value center (CENTER_CODE_TAKEN); re-sending the code it already has is a valid no-op. Refused with SYSTEM_MANAGED on a value center the system maintains. |
| `startDate` | date | no | New first valid day, inclusive. Format YYYY-MM-DD. OMIT TO LEAVE IT UNCHANGED. Refused with SYSTEM_MANAGED on a value center the system maintains. Must not fall after the endDate the value center will have (END_BEFORE_START). Moved LATER, every mapping still running on the new day (open-ended, or ending on or after it) moves its startDate to it — a mapping never starts before its value center — and a mapping that ENDED before the new day refuses the move (START_AFTER_MAPPING_HISTORY); moved earlier, the mappings keep their own start dates (move them with updateMappings). |
| `endDate` | date \| null | no | New last valid day, inclusive. Format YYYY-MM-DD. OMIT TO LEAVE IT UNCHANGED. Setting it ends the value center by hand together with its mappings: every mapping still open after that day ends on the same day (one that ended earlier keeps its own date; one that would only start after it is DELETED and listed in removedMappingIds; other value centers' mappings naming this one follow the same closing) — the set deleteValueCenter (DELETE value-accounting/value-centers/:id) closes on a value center in use — so reactivateValueCenters re-opens them with it; a later date on a value center that already ended moves the mappings ending on its previous day with it. A child that reads active or planned still blocks its parent's delete. Editable on a value center the system maintains too. null CLEARS an end of TODAY OR LATER — a schedule that never took effect: the mappings ending with it follow to no end. ⛔ On a value center whose end date is BEFORE today null is REFUSED with REACTIVATE_VIA_FLOW and nothing is written — re-open with reactivateValueCenters (POST value-accounting/value-centers/reactivate), which re-opens the mappings with it and checks the parent. |
| `categoryId` | string \| null | no | Id (a UUID) of the category to file the value center under, from the categories data-set (GET value-accounting/categories). OMIT TO LEAVE IT UNCHANGED; send null to clear it back to uncategorised. An id that names no category is rejected with CATEGORY_NOT_FOUND; null is a clear, never rejected. Refused with SYSTEM_MANAGED on a value center the system maintains. |
| `parentId` | string \| null | no | Id (a UUID) of the value center to hang this one under, from the valueCenters data-set (GET value-accounting/value-centers). OMIT TO LEAVE IT WHERE IT IS; send null to make it a ROOT — it stays in the tree, with no parent. An id that names no value center is rejected with PARENT_NOT_FOUND; the value center itself or one of its own descendants with CYCLE, because a loop would silently remove every value center in it from the tree — move the descendant out first. Its children move with it. Editable on a value center the system maintains too: no Department/Team hook places one in the tree. Example: `"0f1e4b9a-6a71-4a2c-8a0d-2f9c5d3b7e10"`. |
| `createMappings` | array<object> | no | Mappings to ADD, one per master-data record — full rows with no id. Entries naming the same record with the same dates are collapsed; the same record with different dates is refused with DUPLICATE_MAPPING_ROW. A record this value center maps with an OPEN mapping is refused with MAPPING_EXISTS, unless deleteMappings of the same request removes that mapping or updateMappings of it ends that mapping before today (judged on the end dates as the request leaves them); a mapping that already ended is history, so naming its record again adds a new mapping. Refused with SYSTEM_MANAGED on a value center the system maintains, which the automation finds through its mapping. Omit for no additions. Example: `[{"record":{"dimensionCode":"team","id":"3c4d5e6f-1a2b-4c3d-8e9f-0a1b2c3d4e5f"}}]`. |
| `createMappings[].record` | object | yes | The master-data record to map, as the pair ensureRelationship (POST value-accounting/associations) takes. An unknown dimension code is UNSUPPORTED_DIMENSION_CODE, a record that does not exist RECORD_NOT_FOUND. |
| `createMappings[].record.dimensionCode` | string | yes | Dimension the record belongs to. One of 'department', 'businessUnit', 'team', 'location', 'region', 'employee', 'vendor', 'customer', 'valueCenter', 'custom'. The product's own screens map departments and teams; the tenant's VALUE_CENTER_MAPPING_REFERENCE setting governs which ones the automation creates value centers for and does not limit what is mapped here. |
| `createMappings[].record.id` | string | yes | Id (a UUID) of the master-data record. Matched case-insensitively. |
| `createMappings[].startDate` | date | no | First day the mapping is valid, inclusive. Format YYYY-MM-DD. Defaults to TODAY, or to the value center's own startDate when that is later; send the day the relationship really began when it began earlier. |
| `createMappings[].endDate` | date | no | Last day the mapping is valid, inclusive. Format YYYY-MM-DD. Omit and the mapping ends with the value center: it inherits the value center's endDate as this request leaves it (an endDate sent in the same request included), and is open-ended only when the value center has none — a mapping never outlives its value center. A date later than that endDate is refused with MAPPING_OUTLIVES_END. |
| `updateMappings` | array<object> | no | Existing mappings to RE-DATE, each keyed by its mapping id. Only the dates can change: a mapping names its record once, so pointing at another record is deleteMappings plus createMappings. A row whose dates equal the stored ones is not written. Refused with SYSTEM_MANAGED on a value center the system maintains when a date would change — such a mapping ends with its value center, so send endDate on the value center instead. Omit for no changes. |
| `updateMappings[].id` | string | yes | Id (a UUID) of the mapping — mappings[].id of getValueCenter (GET value-accounting/value-centers/:id). An id that matches no mapping is MAPPING_NOT_FOUND; one of another value center MAPPING_MISMATCH. |
| `updateMappings[].startDate` | date | no | New first valid day of the mapping, inclusive. Format YYYY-MM-DD. OMIT TO LEAVE IT UNCHANGED. |
| `updateMappings[].endDate` | date \| null | no | New last valid day of the mapping, inclusive. Format YYYY-MM-DD. OMIT TO LEAVE IT UNCHANGED; a date ends the mapping. ⛔ null is REFUSED with REACTIVATE_VIA_FLOW — a mapping is re-opened with its value center by reactivateValueCenters (POST value-accounting/value-centers/reactivate). On a value center that has ended, a date today or later that would leave the mapping open after the value center's own end date is refused the same way; any other date later than the value center's endDate as the request leaves it is refused with MAPPING_OUTLIVES_END. |
| `deleteMappings` | array<string> | no | Ids (UUIDs) of mappings to REMOVE — mappings[].id of getValueCenter (GET value-accounting/value-centers/:id). Each must belong to this value center (MAPPING_NOT_FOUND, MAPPING_MISMATCH). Removing the last one is allowed: a value center need not stand for any record. When the open mappings left name one record they become a 1:1 mapping again (inCluster false). Refused with SYSTEM_MANAGED on a value center the system maintains. Omit for no removals. |

```json
{}
```

## Response

`200` Success

Under `data` (updateValueCenterOutput):

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `removedMappingIds` | array<string> | no | Present only when this request moved the value center's end date EARLIER and that DELETED mappings it did not name itself: the ids (UUIDs) of the value center's mappings that would only have started after the new end date. Such a mapping is never in effect inside the value center's life, so it is deleted rather than ended before its own start (a mapping never outlives its value center and is never left canceled); every other mapping still open after that day ends on it. The request is judged on what it leaves: a mapping this same request removes through deleteMappings is removed by it (before the end date is written) and is not listed here, and an updateMappings row is written before an earlier end date so the end judges its new dates. The ids no longer exist. Absent when nothing was deleted (the body is then empty, as before). Also the mappings (UUIDs) of OTHER value centers that name this value center as their record and would only have started after the new end date: a record is never represented past its own end, so they are deleted too, while the ones still open after that day end on it — the closing a deactivation applies. |
| `healedMappingIds` | array<string> | no | Present only when the request HEALED mappings: the ids (UUIDs, mappings[].id of getValueCenter) of updateMappings rows sent with a startDate but no endDate while the stored mapping was OPEN, or ended after the value center's endDate (a legacy row), which were therefore written with the value center's endDate as the request leaves it — a mapping never outlives its value center. An end the request did not send was written for them; read the value center back for the stored dates. A healed row the same request's earlier end then deleted is not listed (it is in removedMappingIds). |

```json
{
  "data": {
    "removedMappingIds": [
      "<removedMappingIds>"
    ],
    "healedMappingIds": [
      "<healedMappingIds>"
    ]
  },
  "diagnostics": [
    {
      "code": "<code>",
      "message": "<message>",
      "severity": "error",
      "path": [
        "<path>"
      ],
      "details": "<details>"
    }
  ]
}
```

## Response headers

- `Idempotency-Replayed` — Present and `true` only when this response replays a previously stored one for the same Idempotency-Key, rather than reflecting a live execution. Absent on a live response - never sent as `false`.

## Errors

| Code | Status |
| --- | --- |
| `NOT_FOUND` | 400 |
| `MAPPING_NOT_FOUND` | 400 |
| `MAPPING_MISMATCH` | 400 |
| `UNSUPPORTED_DIMENSION_CODE` | 400 |
| `RECORD_NOT_FOUND` | 400 |
| `DUPLICATE_MAPPING_ROW` | 400 |
| `END_BEFORE_START` | 400 |
| `INVALID_DATE_RANGE` | 400 |
| `REACTIVATE_VIA_FLOW` | 400 |
| `MAPPING_OUTLIVES_END` | 400 |
| `MAPPING_STARTS_BEFORE_OWNER` | 400 |
| `START_AFTER_MAPPING_HISTORY` | 400 |
| `SYSTEM_MANAGED` | 400 |
| `DESCRIPTION_NOT_CLEARABLE` | 400 |
| `NAME_REQUIRED` | 400 |
| `CENTER_CODE_TAKEN` | 400 |
| `PARENT_NOT_FOUND` | 400 |
| `CYCLE` | 400 |
| `CATEGORY_NOT_FOUND` | 400 |
| `MAPPING_EXISTS` | 400 |
| `PARENT_INACTIVE` | 400 |
| `HAS_ACTIVE_CHILDREN` | 400 |
| `ONE_TO_ONE_EXISTS` | 400 |
| `IDEMPOTENCY_KEY_CONFLICT` | 409 |
| `IDEMPOTENCY_PAYLOAD_MISMATCH` | 422 |

## Statuses

- `400` — Invalid request or business failure. Codes: NOT_FOUND, MAPPING_NOT_FOUND, MAPPING_MISMATCH, UNSUPPORTED_DIMENSION_CODE, RECORD_NOT_FOUND, DUPLICATE_MAPPING_ROW, END_BEFORE_START, INVALID_DATE_RANGE, REACTIVATE_VIA_FLOW, MAPPING_OUTLIVES_END, MAPPING_STARTS_BEFORE_OWNER, START_AFTER_MAPPING_HISTORY, SYSTEM_MANAGED, DESCRIPTION_NOT_CLEARABLE, NAME_REQUIRED, CENTER_CODE_TAKEN, PARENT_NOT_FOUND, CYCLE, CATEGORY_NOT_FOUND, MAPPING_EXISTS, PARENT_INACTIVE, HAS_ACTIVE_CHILDREN, ONE_TO_ONE_EXISTS
- `401` — The request carries no valid access token.
- `403` — Not authorized
- `404` — Not found
- `409` — The Idempotency-Key is still being processed by another request.
- `422` — The Idempotency-Key was already used with a different request payload.
- `429` — Too many requests from this client address. The response has no body and no `Retry-After` header.
- `500` — Internal server error
