# Create Custom Value Object

Operation ID: `createCustomValueObject`

Group: Value Accounting › Custom Value Objects

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

`POST /value-accounting/custom-value-objects`

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

Create one custom value object — a new value on an existing custom value dimension, e.g. 'North' on the axis 'Region'. WRITES — three rows in ONE transaction: the value, the shadow value object that value allocations tag against, and the mapping between them, so the value is usable for tagging as soon as this returns and there is nothing further to call. Returns only the id of the new value; read it back with getCustomValueObject (GET value-accounting/custom-value-objects/:id) for the stored form. Names are unique PER DIMENSION: a name already used on the same dimension is rejected with NAME_TAKEN (which carries the id of the value holding it — reuse that instead of retrying a variant spelling); the same name on another dimension is fine. The dimension must exist (CUSTOM_VALUE_DIMENSION_NOT_FOUND otherwise — create one with createCustomValueDimension (POST value-accounting/custom-value-dimensions)), a supplied category must exist (CATEGORY_NOT_FOUND), the name must not be blank (NAME_REQUIRED) and an endDate must not fall before the startDate (END_BEFORE_START). Every check runs before the first write, so a rejected call writes none of the three rows.

Creates one custom value object — a new value on an existing custom value dimension — and returns only the `id` the platform assigns.

The create is COMPLETE: in the same transaction it writes the value, the shadow value object value allocations tag against, and the 1:1 mapping tying the two together, so the value can be tagged the moment this call returns and there is nothing further to call. The shadow takes the value's name, start date and business number (a generated VO-n instead when another value object already holds that number — object numbers are unique across all value objects), and follows every later change to the value; it is maintained by this resource and never needs to be addressed directly.

Uniqueness is PER DIMENSION: (customValueDimensionId, name) is the semantic key, so the same name on another dimension is fine, while a repeat on the same dimension fails with `NAME_TAKEN`, naming the value that holds it. Both references are checked before anything is written — an unknown dimension fails with `CUSTOM_VALUE_DIMENSION_NOT_FOUND`, an unknown category with `CATEGORY_NOT_FOUND`. An empty name fails with `NAME_REQUIRED`, and an endDate before the startDate with `END_BEFORE_START`. In every case none of the three rows is written.

## 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. |

## Request body

Required, `application/json`: createCustomValueObjectInput.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `customValueDimensionId` | string | yes | Id (a UUID) of the custom value dimension the new value belongs to — the axis it is a value OF — as listed by the customValueDimensions data-set (GET value-accounting/custom-value-dimensions) or returned by createCustomValueDimension (POST value-accounting/custom-value-dimensions). Required. An id that names no dimension is rejected with CUSTOM_VALUE_DIMENSION_NOT_FOUND and nothing is written. Matched case-insensitively. Example: `"0f1e4b9a-6a71-4a2c-8a0d-2f9c5d3b7e10"`. |
| `name` | string | yes | Display name of the new value, e.g. 'North'. Required and must not be empty or whitespace only (NAME_REQUIRED). Must be unused on the given dimension (NAME_TAKEN); the same name on another dimension is allowed. Stored exactly as sent, untrimmed — leading or trailing spaces make a distinct name — and the shadow value object gets the same text. Example: `"North"`. |
| `startDate` | date | yes | First day the value is valid, inclusive. Format YYYY-MM-DD. Required — there is no default. The shadow value object and its mapping start on the same day. Example: `"2026-01-01"`. |
| `endDate` | date | no | Last day the value is valid, inclusive. Format YYYY-MM-DD. Omit for an open-ended value, the normal case. Must be on or after startDate (END_BEFORE_START otherwise); the same day is a valid one-day value. The shadow value object and its mapping end with the value on the same day, so reactivateCustomValueObjects (POST value-accounting/custom-value-objects/reactivate) re-opens the three together. |
| `categoryId` | string | no | Id (a UUID) of the category to file the value under, as listed by the categories data-set (GET value-accounting/categories). Omit to leave the value uncategorised. An id that names no category is rejected with CATEGORY_NOT_FOUND and nothing is written. Matched case-insensitively. |

```json
{
  "customValueDimensionId": "0f1e4b9a-6a71-4a2c-8a0d-2f9c5d3b7e10",
  "name": "North",
  "startDate": "2026-01-01"
}
```

## Response

`200` Success

Under `data` (createCustomValueObjectOutput):

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | yes | Id (a UUID) the platform assigned to the new custom value object. This is the whole of the response: it is the one thing the caller did not already send, and it is what getCustomValueObject, updateCustomValueObject and deleteCustomValueObject (GET, PATCH and DELETE value-accounting/custom-value-objects/:id) are keyed by. |

```json
{
  "data": {
    "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
  },
  "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 |
| --- | --- |
| `NAME_REQUIRED` | 400 |
| `END_BEFORE_START` | 400 |
| `CUSTOM_VALUE_DIMENSION_NOT_FOUND` | 400 |
| `NAME_TAKEN` | 400 |
| `CATEGORY_NOT_FOUND` | 400 |
| `IDEMPOTENCY_KEY_CONFLICT` | 409 |
| `IDEMPOTENCY_PAYLOAD_MISMATCH` | 422 |

## Statuses

- `400` — Invalid request or business failure. Codes: NAME_REQUIRED, END_BEFORE_START, CUSTOM_VALUE_DIMENSION_NOT_FOUND, NAME_TAKEN, CATEGORY_NOT_FOUND
- `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
