> ## 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 Vehicle Consumptions (Organization)

> Delete multiple consumption records by ID, across any vehicle in the organization

# Bulk Delete Vehicle Consumptions (Organization)

Delete multiple consumption records by their IDs in a single call — the consumptions don't need to belong to the same vehicle. Use this from an "all consumptions" table view where a user has selected specific rows across multiple vehicles.

<Warning>
  **Permanent Action**: Deleting consumption records is permanent and cannot be undone. All associated emissions data will be removed from your organization's totals.
</Warning>

<Note>
  Consumption IDs that don't exist, or whose vehicle belongs to a different organization, are reported in `failed_ids` rather than causing the whole request to fail. Always check `failed_count` after a `200` response.
</Note>

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

### Body Parameters

<ParamField body="consumption_ids" type="array[string]" required>
  Array of consumption record UUIDs to delete, from any vehicle in the organization. Minimum 1, maximum 100,000 IDs per request.

  **Example:** `["660e8400-e29b-41d4-a716-446655440000", "770e8400-e29b-41d4-a716-446655440001"]`
</ParamField>

## Response

Returns `200 OK` with a JSON summary of the operation.

<ResponseField name="success_count" type="integer">
  Number of consumption records successfully deleted
</ResponseField>

<ResponseField name="success_ids" type="array[string]">
  UUIDs of successfully deleted consumption records
</ResponseField>

<ResponseField name="failed_count" type="integer">
  Number of records that failed to delete
</ResponseField>

<ResponseField name="failed_ids" type="array[string]">
  UUIDs of records that failed to delete (not found, or owned by a different organization)
</ResponseField>

<ResponseField name="message" type="string">
  Human-readable summary of the operation
</ResponseField>

## Example

<CodeGroup>
  ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl -X POST "https://api.dcycle.io/v2/vehicle_consumptions/bulk-delete" \
    -H "x-api-key: ${DCYCLE_API_KEY}" \
    -H "x-organization-id: ${DCYCLE_ORG_ID}" \
    -H "Content-Type: application/json" \
    -d '{
      "consumption_ids": [
        "660e8400-e29b-41d4-a716-446655440000",
        "770e8400-e29b-41d4-a716-446655440001"
      ]
    }'
  ```

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

  api_key = os.getenv("DCYCLE_API_KEY")
  org_id = os.getenv("DCYCLE_ORG_ID")

  headers = {
      "x-api-key": api_key,
      "x-organization-id": org_id,
      "Content-Type": "application/json"
  }

  payload = {
      "consumption_ids": [
          "660e8400-e29b-41d4-a716-446655440000",
          "770e8400-e29b-41d4-a716-446655440001"
      ]
  }

  response = requests.post(
      "https://api.dcycle.io/v2/vehicle_consumptions/bulk-delete",
      headers=headers,
      json=payload
  )

  result = response.json()
  print(f"Deleted: {result['success_count']}, Failed: {result['failed_count']}")
  print(result["message"])
  ```

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

  const apiKey = process.env.DCYCLE_API_KEY;
  const orgId = process.env.DCYCLE_ORG_ID;

  const headers = {
    'x-api-key': apiKey,
    'x-organization-id': orgId,
    'Content-Type': 'application/json'
  };

  const payload = {
    consumption_ids: [
      '660e8400-e29b-41d4-a716-446655440000',
      '770e8400-e29b-41d4-a716-446655440001'
    ]
  };

  axios.post(
    'https://api.dcycle.io/v2/vehicle_consumptions/bulk-delete',
    payload,
    { headers }
  )
  .then(response => {
    const result = response.data;
    console.log(`Deleted: ${result.success_count}, Failed: ${result.failed_count}`);
    console.log(result.message);
  })
  .catch(error => console.error(error));
  ```
</CodeGroup>

### Successful Response

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "success_count": 2,
  "success_ids": [
    "660e8400-e29b-41d4-a716-446655440000",
    "770e8400-e29b-41d4-a716-446655440001"
  ],
  "failed_count": 0,
  "failed_ids": [],
  "message": "Successfully deleted 2 vehicle consumption(s)"
}
```

## Common Errors

### 401 Unauthorized

**Cause:** Missing or invalid API key

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

### 422 Validation Error

**Cause:** Invalid request body (e.g. empty `consumption_ids` array or exceeding 100,000 IDs)

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "detail": [
    {
      "loc": ["body", "consumption_ids"],
      "msg": "ensure this value has at least 1 items",
      "type": "value_error.list.min_items"
    }
  ]
}
```

## Related Endpoints

<CardGroup cols={2}>
  <Card title="List Vehicle Consumptions (Organization)" icon="list" href="/api-reference/vehicles/consumptions-org-list">
    List all consumptions across every vehicle, with filters
  </Card>

  <Card title="Bulk Delete by Filters (Organization)" icon="filter" href="/api-reference/vehicles/consumptions-org-bulk-delete-by-filters">
    Delete every consumption matching the current filters, e.g. an entire uploaded file
  </Card>

  <Card title="Bulk Delete Consumptions" icon="trash" href="/api-reference/vehicles/consumptions-bulk-delete">
    Delete consumptions scoped to a single vehicle
  </Card>
</CardGroup>
