# Bulk Delete Business Drivers

Operation ID: `bulkDeleteBusinessDrivers`

Group: Value Accounting › Business Drivers › Business Driver Definitions

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

`POST /value-accounting/business-drivers/bulk-delete`

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

Delete several business driver definitions in one call, DEACTIVATING each one that holds recorded values and leaving each system driver untouched, and report every outcome. WRITES. Every id must exist: if any does not, the whole call is rejected with NOT_FOUND listing exactly those ids and NOTHING is written. No driver the call would hard-delete (one without recorded values; system drivers aside) may be one an allocation rule allocates by: if any is, the whole call is rejected with IN_USE naming the drivers and rules and NOTHING is written. A rule-used driver that holds values is not refused — it is deactivated, and an inactive driver still answers its weights. Then each driver is handled on its own: without recorded values it is hard-deleted with its dormant combination lines, their history and its recording contexts — DESTRUCTIVE, no undo — and listed in deletedIds; with recorded values it is kept and deactivated, listed in deactivatedIds (setBusinessDriversActive (POST value-accounting/business-drivers/set-active) re-opens it); a SYSTEM driver is neither deleted nor deactivated, listed in blockedIds. A kept driver is a success, not a failure of the batch: the three lists together name every distinct id sent. POST rather than DELETE because the ids travel in a request body, which a DELETE does not dependably deliver.

Deletes several business driver definitions in one call, keeping the ones that must stay, and reports each outcome.

Every id must exist: if any does not, the whole call is rejected with `NOT_FOUND` listing exactly those ids, and NOTHING is written. Likewise, if an allocation rule allocates by any driver the call would hard-delete (one without recorded values; system drivers aside), the whole call is rejected with `IN_USE` naming the drivers and rules, and NOTHING is written. A rule-used driver that holds values does not refuse the call: it is deactivated, and the rule keeps allocating by it. Then each driver is handled on its own: one without recorded values is hard-deleted (DESTRUCTIVE, no undo) and listed in `deletedIds`; one that holds values is kept and deactivated, listed in `deactivatedIds`; a system driver is left completely untouched, listed in `blockedIds`. A kept driver is a success, not a failure of the batch: the three lists together name every distinct id sent.

POST rather than DELETE because the ids travel in a body, and a DELETE body is not dependably delivered.

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

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `ids` | array<string> | yes | Ids (UUIDs) of the drivers to delete, as returned by the businessDrivers data-set (GET value-accounting/business-drivers). Every id must exist, or the whole batch is rejected with NOT_FOUND. Duplicates are collapsed. An empty array is a valid no-op that deletes nothing and returns three empty lists. Ids are matched case-insensitively and returned in canonical lowercase. Example: `["0f1e4b9a-6a71-4a2c-8a0d-2f9c5d3b7e10","6d2c8f31-b4a7-4e19-9f2b-77c0a1d4e5b2"]`. |

```json
{
  "ids": [
    "0f1e4b9a-6a71-4a2c-8a0d-2f9c5d3b7e10",
    "6d2c8f31-b4a7-4e19-9f2b-77c0a1d4e5b2"
  ]
}
```

## Response

`200` Success

Under `data` (bulkDeleteBusinessDriversOutput):

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `deletedIds` | array<string> | yes | Ids (UUIDs) of the drivers that were hard-deleted — they held no recorded value — in the order they were first sent. These ids no longer resolve. |
| `deactivatedIds` | array<string> | yes | Ids (UUIDs) of the drivers that hold recorded values and were therefore kept and DEACTIVATED instead of deleted, in the order they were first sent. They still exist with every value and their names; never treat one as removed. |
| `blockedIds` | array<string> | yes | Ids (UUIDs) of the SYSTEM drivers the call left completely untouched — neither deleted nor deactivated — in the order they were first sent. A system driver cannot be removed; switch its feed off with setBusinessDriversActive (POST value-accounting/business-drivers/set-active) instead. |

```json
{
  "data": {
    "deletedIds": [
      "<deletedIds>"
    ],
    "deactivatedIds": [
      "<deactivatedIds>"
    ],
    "blockedIds": [
      "<blockedIds>"
    ]
  },
  "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 |
| `IN_USE` | 400 |
| `IDEMPOTENCY_KEY_CONFLICT` | 409 |
| `IDEMPOTENCY_PAYLOAD_MISMATCH` | 422 |

## Statuses

- `400` — Invalid request or business failure. Codes: NOT_FOUND, IN_USE
- `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
