# End Driver Combination

Operation ID: `endDriverCombination`

Group: Value Accounting › Business Drivers › Driver Values

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

`POST /value-accounting/driver-values/end`

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

End a combination from an accounting period on — the member set stops existing there; returns an empty body. WRITES and is DESTRUCTIVE for derived data. The combination becomes inactive from fromPeriodId (included), an End entry is written to the audit history at that boundary, and every system-carried row from there on is removed, also in later locked periods (derived data). Only the boundary period must be open and not in the future (PERIOD_LOCKED). A recorded value at or after the boundary refuses the call (END_COMBO_EXPLICIT_AFTER) — recorded values are never discarded. Reversible with reactivateDriverCombination (POST value-accounting/driver-values/reactivate). Refused for an already ended combination (LINE_ENDED), an inactive driver (DRIVER_INACTIVE) and a system driver (SYSTEM_DRIVER). It runs in one transaction, so a refusal writes nothing.

Ends a combination from an accounting period on — 'this member set stops existing from here' — and returns an empty body. The alternative to deleting values one by one.

The combination is marked inactive from `fromPeriodId` (that period included), an End entry is written to the audit history at that boundary, and every system-carried row from there on is removed, also in later locked periods: they are derived data, so only the boundary period itself must be open (`PERIOD_LOCKED`).

Recorded values are never discarded: if one exists at or after the boundary, the call is refused (`END_COMBO_EXPLICIT_AFTER`) — delete it first, or end later.

Reversible with reactivateDriverCombination (POST value-accounting/driver-values/reactivate). Refused for an already ended combination (`LINE_ENDED`), an inactive driver and a system driver. It runs in one transaction, so a refusal writes nothing.

## 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`: endDriverCombinationInput.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `combinationId` | string | yes | Id (a UUID) of the combination to end — the combinationId of a row of searchDriverValues (POST value-accounting/driver-values/search). Matched case-insensitively. Example: `"5a6b7c8d-9e0f-4a1b-8c2d-3e4f5a6b7c8d"`. |
| `fromPeriodId` | string | yes | Id (a UUID) of the accounting period the combination stops existing FROM, that period included. It must be open for the entity and book and not in the future. Matched case-insensitively. Example: `"d8b3b2a3-89b1-4040-99f5-8f550f28f23c"`. |

```json
{
  "combinationId": "5a6b7c8d-9e0f-4a1b-8c2d-3e4f5a6b7c8d",
  "fromPeriodId": "d8b3b2a3-89b1-4040-99f5-8f550f28f23c"
}
```

## Response

`200` Success

```json
{
  "data": {},
  "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 |
| --- | --- |
| `COMBINATION_NOT_FOUND` | 400 |
| `PERIOD_NOT_FOUND` | 400 |
| `PERIOD_CALENDAR_MISMATCH` | 400 |
| `SYSTEM_DRIVER` | 400 |
| `LINE_NOT_FOUND` | 400 |
| `LINE_ENDED` | 400 |
| `DRIVER_NOT_FOUND` | 400 |
| `DRIVER_INACTIVE` | 400 |
| `PERIOD_LOCKED` | 400 |
| `END_COMBO_EXPLICIT_AFTER` | 400 |
| `IDEMPOTENCY_KEY_CONFLICT` | 409 |
| `IDEMPOTENCY_PAYLOAD_MISMATCH` | 422 |

## Statuses

- `400` — Invalid request or business failure. Codes: COMBINATION_NOT_FOUND, PERIOD_NOT_FOUND, PERIOD_CALENDAR_MISMATCH, SYSTEM_DRIVER, LINE_NOT_FOUND, LINE_ENDED, DRIVER_NOT_FOUND, DRIVER_INACTIVE, PERIOD_LOCKED, END_COMBO_EXPLICIT_AFTER
- `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
