> ## Documentation Index
> Fetch the complete documentation index at: https://code.dcycle.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Bulk Delete Recharges by Filters

> Delete all logistics recharges matching filter criteria with concurrency guard

# Bulk Delete Recharges by Filters

Delete all logistics fuel recharges matching the given filter criteria. Uses `filter_hash` for optimistic concurrency.

## Request

### Headers

<ParamField header="x-api-key" type="string" required>
  Your API key for authentication

  **Example:** `sk_live_1234567890abcdef`
</ParamField>

<ParamField header="x-organization-id" type="string" required>
  Your organization UUID

  **Example:** `a8315ef3-dd50-43f8-b7ce-d839e68d51fa`
</ParamField>

### Query Parameters

At least one filter parameter is required.

<ParamField query="search" type="string">
  Search by vehicle license plate
</ParamField>

<ParamField query="vehicle_type[]" type="string[]">
  Filter by vehicle type(s)
</ParamField>

<ParamField query="fuel_id[]" type="string[]">
  Filter by fuel UUID(s)
</ParamField>

<ParamField query="vehicle_license_plate[]" type="string[]">
  Filter by vehicle license plate(s)
</ParamField>

<ParamField query="file_id[]" type="string[]">
  Filter by file UUID(s)
</ParamField>

<ParamField query="date_from" type="string">
  Filter by recharge date on or after (YYYY-MM-DD)
</ParamField>

<ParamField query="date_until" type="string">
  Filter by recharge date on or before (YYYY-MM-DD)
</ParamField>

<ParamField query="status" type="string">
  Filter by recharge status
</ParamField>

<ParamField query="project_id" type="string">
  Filter by project UUID
</ParamField>

### Body Parameters

<ParamField body="filter_hash" type="string" required>
  Hash from the list endpoint response. Must match the current filter set.
</ParamField>

## Example

<CodeGroup>
  ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
  RESPONSE=$(curl -s "https://api.dcycle.io/v1/logistics/recharges?status=error" \
    -H "x-api-key: ${DCYCLE_API_KEY}" \
    -H "x-organization-id: ${DCYCLE_ORG_ID}")

  FILTER_HASH=$(echo $RESPONSE | jq -r '.filter_hash')

  curl -X POST "https://api.dcycle.io/v1/logistics/recharges/bulk-delete-by-filters?status=error" \
    -H "x-api-key: ${DCYCLE_API_KEY}" \
    -H "x-organization-id: ${DCYCLE_ORG_ID}" \
    -H "Content-Type: application/json" \
    -d "{\"filter_hash\": \"${FILTER_HASH}\"}"
  ```

  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import requests
  import os

  headers = {
      "x-api-key": os.getenv("DCYCLE_API_KEY"),
      "x-organization-id": os.getenv("DCYCLE_ORG_ID"),
  }

  filters = {"status": "error"}

  list_resp = requests.get("https://api.dcycle.io/v1/logistics/recharges", headers=headers, params=filters)
  filter_hash = list_resp.json()["filter_hash"]

  delete_resp = requests.post(
      "https://api.dcycle.io/v1/logistics/recharges/bulk-delete-by-filters",
      headers={**headers, "Content-Type": "application/json"},
      params=filters,
      json={"filter_hash": filter_hash},
  )

  print(f"Deleted: {len(delete_resp.json()['deleted'])}")
  ```

  ```javascript JavaScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
  const axios = require('axios');

  const headers = {
    'x-api-key': process.env.DCYCLE_API_KEY,
    'x-organization-id': process.env.DCYCLE_ORG_ID,
  };

  const filters = { status: 'error' };

  const listResp = await axios.get('https://api.dcycle.io/v1/logistics/recharges', { headers, params: filters });

  const deleteResp = await axios.post(
    'https://api.dcycle.io/v1/logistics/recharges/bulk-delete-by-filters',
    { filter_hash: listResp.data.filter_hash },
    { headers: { ...headers, 'Content-Type': 'application/json' }, params: filters },
  );

  console.log(`Deleted: ${deleteResp.data.deleted.length}`);
  ```
</CodeGroup>

### Successful Response

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "deleted": [
    "660e8400-e29b-41d4-a716-446655440000",
    "770e8400-e29b-41d4-a716-446655440000"
  ],
  "failed": []
}
```

<ResponseField name="deleted" type="string[]">
  UUIDs of deleted recharges.
</ResponseField>

<ResponseField name="failed" type="object[]">
  Failed deletions with reason.
</ResponseField>

## Common Errors

### 401 Unauthorized

**Cause:** Missing or invalid API key

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{"detail": "Invalid API key for organization", "code": "INVALID_API_KEY"}
```

### 403 Forbidden

**Cause:** The authenticated user is not a member of the organization

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{"detail": "Logged User is not Member of Organization", "code": "LOGGED_USER_NOT_MEMBER"}
```

### 409 Conflict

**Cause:** Filter hash mismatch. The filters have changed since the list was loaded. Please refresh and try again.

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{ "detail": "Filter hash mismatch. The filters have changed since the list was loaded. Please refresh and try again." }
```

## Related Endpoints

<CardGroup cols={2}>
  <Card title="Batch Delete Recharges" icon="trash" href="/api-reference/logistics/batch-delete-recharges">
    Delete specific recharges by ID
  </Card>

  <Card title="List Recharges" icon="list" href="/api-reference/logistics/get-recharges">
    Browse logistics recharges
  </Card>
</CardGroup>
