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

> Delete up to 100,000 transport routes in a single request by providing their IDs

# Bulk Delete Transport Routes

Delete multiple transport routes at once by providing a list of IDs. All associated transport sections and their `total_impacts` records are removed automatically. Progress is tracked asynchronously and a notification is published via SSE when the operation completes.

IDs that do not exist or belong to a different organization are silently reported as failures in the response — the rest of the batch still proceeds.

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

<ParamField body="transport_ids" type="array" required>
  List of transport route UUIDs to delete. Minimum 1, maximum 100,000 per request.

  **Example:** `["010ed3b6-b513-40f3-b9fe-0f0a338d9274", "550e8400-e29b-41d4-a716-446655440000"]`
</ParamField>

## Response

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

<ResponseField name="success_ids" type="array">
  UUIDs of the transport routes that were successfully deleted
</ResponseField>

<ResponseField name="failed_count" type="integer">
  Number of transport routes that could not be deleted
</ResponseField>

<ResponseField name="failed_ids" type="array">
  UUIDs of the transport routes that failed (e.g. ID not found or belongs to a different organization)
</ResponseField>

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

<Note>
  A partial success is possible: if some IDs fail validation the rest are still deleted. Check `failed_ids` to identify which routes were not removed and why.
</Note>

## Example

<CodeGroup>
  ```bash cURL (API Key) theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl -X POST "https://api.dcycle.io/v1/transports/bulk-delete" \
    -H "x-api-key: ${DCYCLE_API_KEY}" \
    -H "x-organization-id: ${DCYCLE_ORG_ID}" \
    -H "Content-Type: application/json" \
    -d '{
      "transport_ids": [
        "010ed3b6-b513-40f3-b9fe-0f0a338d9274",
        "550e8400-e29b-41d4-a716-446655440000",
        "7c9e6679-7425-40de-944b-e07fc1f90ae7"
      ]
    }'
  ```

  ```bash cURL (JWT) theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl -X POST "https://api.dcycle.io/v1/transports/bulk-delete" \
    -H "x-organization-id: ${DCYCLE_ORG_ID}" \
    -H "Content-Type: application/json" \
    -d '{
      "transport_ids": [
        "010ed3b6-b513-40f3-b9fe-0f0a338d9274",
        "550e8400-e29b-41d4-a716-446655440000",
        "7c9e6679-7425-40de-944b-e07fc1f90ae7"
      ]
    }'
  ```

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

  transport_ids = [
      "010ed3b6-b513-40f3-b9fe-0f0a338d9274",
      "550e8400-e29b-41d4-a716-446655440000",
      "7c9e6679-7425-40de-944b-e07fc1f90ae7",
  ]

  response = requests.post(
      "https://api.dcycle.io/v1/transports/bulk-delete",
      headers={
          "x-api-key": os.getenv("DCYCLE_API_KEY"),
          "x-organization-id": os.getenv("DCYCLE_ORG_ID"),
      },
      json={"transport_ids": transport_ids},
  )

  result = response.json()
  print(f"Deleted: {result['success_count']} routes")
  if result["failed_ids"]:
      print(f"Failed IDs: {result['failed_ids']}")
  ```

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

  const transportIds = [
    '010ed3b6-b513-40f3-b9fe-0f0a338d9274',
    '550e8400-e29b-41d4-a716-446655440000',
    '7c9e6679-7425-40de-944b-e07fc1f90ae7',
  ];

  axios.post(
    'https://api.dcycle.io/v1/transports/bulk-delete',
    { transport_ids: transportIds },
    {
      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} routes`);
    if (data.failed_ids.length > 0) {
      console.log('Failed IDs:', data.failed_ids);
    }
  })
  .catch(error => console.error(error));
  ```
</CodeGroup>

### Successful Response

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "success_count": 2,
  "success_ids": [
    "010ed3b6-b513-40f3-b9fe-0f0a338d9274",
    "550e8400-e29b-41d4-a716-446655440000"
  ],
  "failed_count": 1,
  "failed_ids": [
    "7c9e6679-7425-40de-944b-e07fc1f90ae7"
  ],
  "message": "Successfully deleted 2 transport route(s), 1 failed or not found"
}
```

### All routes deleted

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "success_count": 3,
  "success_ids": [
    "010ed3b6-b513-40f3-b9fe-0f0a338d9274",
    "550e8400-e29b-41d4-a716-446655440000",
    "7c9e6679-7425-40de-944b-e07fc1f90ae7"
  ],
  "failed_count": 0,
  "failed_ids": [],
  "message": "Successfully deleted 3 transport route(s)"
}
```

## Common Errors

### 401 Unauthorized

**Cause:** Missing or invalid API key / JWT token

```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:** `transport_ids` is empty or exceeds 100,000 items

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

## Related Endpoints

<CardGroup cols={2}>
  <Card title="List Transport Routes" icon="list" href="/api-reference/transport/list">
    Retrieve all transport routes with filtering and pagination
  </Card>

  <Card title="Bulk Delete by Filters" icon="filter" href="/api-reference/transport/bulk-delete-by-filters">
    Delete all routes matching a set of filters at once
  </Card>

  <Card title="Delete Transport Route" icon="trash" href="/api-reference/transport/delete">
    Delete a single transport route by ID
  </Card>

  <Card title="Transport Overview" icon="book" href="/api-reference/transport/overview">
    Full data model and distance calculation reference
  </Card>
</CardGroup>
