# Update Value Object

Operation ID: `updateValueObject`

Group: Value Accounting › Value Objects

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

`PATCH /value-accounting/value-objects/{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 object — its fields 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, 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 object that already ended moves the mappings ending on its previous day with it; null clears an end of today or later and is REFUSED with REACTIVATE_VIA_FLOW on an end before today — re-open with reactivateValueObjects (POST value-accounting/value-objects/reactivate)), objectNumber, categoryId (null clears). Mappings: createMappings adds records (the same record on two entries with different dates is DUPLICATE_MAPPING_ROW, judged first; one this value object 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 object's own startDate when that is later, unless startDate is sent, and without an endDate it ends with the value object — it inherits the value object's endDate as the request leaves it, open-ended only when there is none; a mapping never outlives its value object, so an endDate later than the value object'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 object 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 getValueObject (GET value-accounting/value-objects/:id) and must belong to this value object (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. The value object must keep at least one mapping (MAPPING_REQUIRED, counted over the whole request). A system-maintained mirror (isSystemManaged) refuses changes to name, startDate, categoryId and mappings with SYSTEM_MANAGED; re-sending a stored value is not a change. Dates are judged on the end state the request leaves: END_BEFORE_START (the value object), 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 object'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); an updateMappings row healed to the value object's end is listed in healedMappingIds; deleteMappings, and updateMappings rows under an earlier end, are applied before the value object is written. Other refusals: NOT_FOUND, NAME_REQUIRED, OBJECT_NUMBER_REQUIRED, OBJECT_NUMBER_TAKEN, CATEGORY_NOT_FOUND, and for createMappings UNSUPPORTED_DIMENSION_CODE / RECORD_NOT_FOUND. A request leaving this value object standing alone for a record another value object 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 object, 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 object 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 object represents one-to-one with an open mapping. That move is the one re-open door besides reactivateValueObjects (POST value-accounting/value-objects/reactivate) and runs its screens too: a later endDate or a null on a custom value object's SHADOW whose end has already passed is REACTIVATE_VIA_FLOW (the shadow's end date follows the value — re-open all three with POST value-accounting/custom-value-objects/reactivate; a shadow end of today or later is moved or cleared through the value, the three together), and a move to today or later whose re-opened mappings name a record that no longer exists is REFERENCE_NOT_FOUND.

Partially updates one value object — its own fields 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. `categoryId: null` clears the category. 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 getValueObject (GET value-accounting/value-objects/:id), and only this value object's own mappings can be named (`MAPPING_MISMATCH` otherwise). A record is linked once at a time: `createMappings` naming a record this value object 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 object'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 object's mappings reads `inCluster: true` — adding a second record to a 1:1 value object makes it a cluster, and removing all but one makes it 1:1 again. 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 object 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.

A value object must always keep at least one mapping: a request that would leave none fails with `MAPPING_REQUIRED` — counted over the whole request, so replacing the last mapping with a new one in the same call passes.

Ending is a plain write, re-opening is not: an `endDate` DATE on the value object or on a mapping ends it, but `endDate: null` on the value object 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 object and its mappings are re-opened together by reactivateValueObjects (POST value-accounting/value-objects/reactivate). On a value object 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 object: a `createMappings` row sent without an `endDate` ends with the value object — it inherits the value object'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 object — 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 object's life and is DELETED — `removedMappingIds` in the response lists it. Moving the `endDate` of a value object that already ended to a LATER day moves its mappings ending on the previous day — the ones its retirement closed — with it; that is the one re-open door besides reactivateValueObjects (POST value-accounting/value-objects/reactivate), under the same screens: on a custom value object's shadow whose end has already passed it fails with `REACTIVATE_VIA_FLOW` (the shadow's end date follows the value — re-open all three with POST value-accounting/custom-value-objects/reactivate; a shadow end of today or later is moved or cleared here, through the value, the three together), and re-opening mappings that name a record that no longer exists fails with `REFERENCE_NOT_FOUND`. 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 object 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 object (`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 object with an end date, an `updateMappings` row sending a `startDate` but no `endDate` for a mapping left open (or ending after the value object) is written with the value object's end and listed in `healedMappingIds`. `deleteMappings`, and `updateMappings` rows under an earlier end, are applied before the value object itself is written, so a mapping the request deletes or re-dates never blocks it.

A value object the system maintains as the mirror of one master-data record (`isSystemManaged` on the reads) refuses changes to its name, objectNumber, startDate, categoryId and mappings with `SYSTEM_MANAGED`, because the record's next change would overwrite them (the objectNumber is how the system recognises it); its endDate stays editable. Re-sending a stored value is never a change.

A record has at most one OPEN one-to-one value object, 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 object standing alone for a record ANOTHER value object 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 object and its mapping; end that link first or delete that value object (for a cut-back cluster: end or delete this whole value object). A value object 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 object 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 object 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 object to change; bound from the :id path segment. An id that matches no value object 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`: updateValueObjectInput.

| 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 system-maintained mirror, whose name follows its record — rename the record instead. Example: `"Sales and Marketing"`. |
| `startDate` | date | no | New first valid day, inclusive. Format YYYY-MM-DD. OMIT TO LEAVE IT UNCHANGED. Refused with SYSTEM_MANAGED on a system-maintained mirror. Must not fall after the endDate the value object 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 object — 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 object 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) — the set deleteValueObject (DELETE value-accounting/value-objects/:id) closes on a value object in use — so reactivateValueObjects re-opens them with it; a later date on a value object that already ended moves the mappings ending on its previous day with it. Editable on a mirror 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 object whose end date is BEFORE today null is REFUSED with REACTIVATE_VIA_FLOW and nothing is written — re-open it with reactivateValueObjects (POST value-accounting/value-objects/reactivate), which re-opens the mappings with it. On the SHADOW of a custom value object every end written here — set, moved earlier or later, cleared — goes THROUGH THAT RECORD (as PATCH value-accounting/custom-value-objects/:id writes it): the custom value object, its shadow and their mapping take it together, the record's other rows following as on that action, and that move is screened as there (MAPPING_EXISTS, ONE_TO_ONE_EXISTS) — a shadow never ends on its own. A shadow end that has already PASSED is not moved later or cleared here (REACTIVATE_VIA_FLOW): re-open the trio with reactivateCustomValueObjects (POST value-accounting/custom-value-objects/reactivate). |
| `objectNumber` | string | no | New business number. OMIT TO LEAVE IT UNCHANGED; it cannot be cleared — an empty or whitespace-only number is refused with OBJECT_NUMBER_REQUIRED. Must be unused by any other value object (OBJECT_NUMBER_TAKEN); re-sending the number it already has is a valid no-op. NOT editable on a system-managed value object (a mirror, or a custom value object's shadow): the number is adopted from the source record and is how a shadow is recognised, so a new one is refused with SYSTEM_MANAGED. |
| `categoryId` | string \| null | no | Id (a UUID) of the category to file the value object 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 system-maintained mirror. |
| `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 object 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 mirror, which stands for exactly one record. Omit for no additions. Example: `[{"record":{"dimensionCode":"team","id":"0f1e4b9a-6a71-4a2c-8a0d-2f9c5d3b7e10"}}]`. |
| `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'. |
| `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 object'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 object: it inherits the value object's endDate as this request leaves it (an endDate sent in the same request included), and is open-ended only when the value object has none — a mapping never outlives its value object. 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 mirror when a date would change. Omit for no changes. |
| `updateMappings[].id` | string | yes | Id (a UUID) of the mapping — mappings[].id of getValueObject (GET value-accounting/value-objects/:id). An id that matches no mapping is MAPPING_NOT_FOUND; one of another value object 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 object by reactivateValueObjects (POST value-accounting/value-objects/reactivate). On a value object that has ended, a date today or later that would leave the mapping open after the value object's own end date is refused the same way; any other date later than the value object'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 getValueObject (GET value-accounting/value-objects/:id). Each must belong to this value object (MAPPING_NOT_FOUND, MAPPING_MISMATCH). The value object must keep at least one mapping after the whole request (MAPPING_REQUIRED); when the open mappings left name one record they become a 1:1 mapping again (inCluster false). Refused with SYSTEM_MANAGED on a mirror. Omit for no removals. |

```json
{}
```

## Response

`200` Success

Under `data` (updateValueObjectOutput):

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `removedMappingIds` | array<string> | no | Present only when this request moved the value object's end date EARLIER and that DELETED mappings it did not name itself: the ids (UUIDs) of the value object's mappings that would only have started after the new end date. Such a mapping is never in effect inside the value object's life, so it is deleted rather than ended before its own start (a mapping never outlives its value object 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). |
| `healedMappingIds` | array<string> | no | Present only when the request HEALED mappings: the ids (UUIDs, mappings[].id of getValueObject) of updateMappings rows sent with a startDate but no endDate while the stored mapping was OPEN, or ended after the value object's endDate (a legacy row), which were therefore written with the value object's endDate as the request leaves it — a mapping never outlives its value object. An end the request did not send was written for them; read the value object 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 |
| `REFERENCE_NOT_FOUND` | 400 |
| `SYSTEM_MANAGED` | 400 |
| `NAME_REQUIRED` | 400 |
| `OBJECT_NUMBER_REQUIRED` | 400 |
| `OBJECT_NUMBER_TAKEN` | 400 |
| `CATEGORY_NOT_FOUND` | 400 |
| `MAPPING_EXISTS` | 400 |
| `MAPPING_REQUIRED` | 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, REFERENCE_NOT_FOUND, SYSTEM_MANAGED, NAME_REQUIRED, OBJECT_NUMBER_REQUIRED, OBJECT_NUMBER_TAKEN, CATEGORY_NOT_FOUND, MAPPING_EXISTS, MAPPING_REQUIRED, 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
