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

> Delete multiple business travel records and their associated emissions in a single request

# Bulk Delete

Permanently deletes multiple business travel records and their associated `total_impacts` rows in a single request. Records that belong to a different organization are reported as failed rather than raising an error. Progress is tracked via a processing job.

<Warning>
  **Permanent Action**: Deleted records cannot be recovered. The associated emissions data will also be removed from your organization's totals.
</Warning>

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

<ParamField header="Content-Type" type="string" required>
  Must be `application/json`
</ParamField>

### Body Parameters

<ParamField body="business_travel_ids" type="array[uuid]" required>
  List of business travel UUIDs to delete

  **Constraints:** 1 to 100,000 items per request
</ParamField>

## Response

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

<ResponseField name="success_ids" type="array[string]">
  UUIDs of business travels that were successfully deleted
</ResponseField>

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

<ResponseField name="failed_ids" type="array[string]">
  UUIDs that could not be deleted (not found, belong to a different organization, or deletion error)
</ResponseField>

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

## Example

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

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

  response = requests.post(
      "https://api.dcycle.io/v1/business-travels/bulk-delete",
      headers={
          "x-api-key": os.getenv("DCYCLE_API_KEY"),
          "x-organization-id": os.getenv("DCYCLE_ORG_ID"),
      },
      json={
          "business_travel_ids": [
              "550e8400-e29b-41d4-a716-446655440000",
              "550e8400-e29b-41d4-a716-446655440001",
          ]
      },
  )

  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');

  axios.post(
    'https://api.dcycle.io/v1/business-travels/bulk-delete',
    {
      business_travel_ids: [
        '550e8400-e29b-41d4-a716-446655440000',
        '550e8400-e29b-41d4-a716-446655440001',
      ],
    },
    {
      headers: {
        'x-api-key': process.env.DCYCLE_API_KEY,
        'x-organization-id': process.env.DCYCLE_ORG_ID,
      },
    }
  )
  .then(({ data }) => {
    console.log(`Deleted: ${data.success_count}, Failed: ${data.failed_count}`);
    console.log(data.message);
  })
  .catch(error => console.error(error));
  ```
</CodeGroup>

### Successful Response

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "success_count": 1,
  "success_ids": ["550e8400-e29b-41d4-a716-446655440000"],
  "failed_count": 1,
  "failed_ids": ["550e8400-e29b-41d4-a716-446655440001"],
  "message": "Bulk delete completed: 1 deleted, 1 failed"
}
```

## 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"}
```

### 422 Unprocessable Entity

**Cause:** Empty list or exceeds 100,000 items

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

## Related Endpoints

<CardGroup cols={2}>
  <Card title="Delete" icon="trash" href="/api-reference/business-travels/delete">
    Delete a single business travel
  </Card>

  <Card title="Bulk Delete by Filters" icon="filter" href="/api-reference/business-travels/bulk-delete-by-filters">
    Delete all records matching filter criteria
  </Card>

  <Card title="List Business Travels" icon="list" href="/api-reference/business-travels/list">
    Browse all business travels
  </Card>
</CardGroup>
