Skip to main content
POST
/
v1
/
business-travels
/
bulk-delete-by-filters
Bulk Delete by Filters
const options = {
  method: 'POST',
  headers: {
    'x-api-key': '<x-api-key>',
    'x-organization-id': '<x-organization-id>',
    'Content-Type': '<content-type>'
  },
  body: JSON.stringify({filter_hash: '<string>'})
};

fetch('https://api.dcycle.io/v1/business-travels/bulk-delete-by-filters', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
import requests

url = "https://api.dcycle.io/v1/business-travels/bulk-delete-by-filters"

payload = { "filter_hash": "<string>" }
headers = {
    "x-api-key": "<x-api-key>",
    "x-organization-id": "<x-organization-id>",
    "Content-Type": "<content-type>"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
curl --request POST \
  --url https://api.dcycle.io/v1/business-travels/bulk-delete-by-filters \
  --header 'Content-Type: <content-type>' \
  --header 'x-api-key: <x-api-key>' \
  --header 'x-organization-id: <x-organization-id>' \
  --data '
{
  "filter_hash": "<string>"
}
'
{
  "success_count": 123,
  "success_ids": {},
  "failed_count": 123,
  "failed_ids": {},
  "message": "<string>"
}

Bulk Delete by Filters

Deletes all business travels matching the provided filter parameters. Requires at least one filter to prevent accidental mass deletion. A filter_hash from the list endpoint must be provided to confirm the filters haven’t changed since the user reviewed them.
Permanent Action: Deleted records and their associated emissions cannot be recovered.

Request

Headers

x-api-key
string
required
Your API key for authenticationExample: sk_live_1234567890abcdef
x-organization-id
string
required
Your organization UUIDExample: a8315ef3-dd50-43f8-b7ce-d839e68d51fa
Content-Type
string
required
Must be application/json

Query Parameters

Same filter parameters as the list endpoint:
transport_type[]
array[string]
Filter by transport typeAvailable values: car, metro, train, trolleybus, bus, motorbike, aircraft, ferry
status[]
array[string]
Filter by statusAvailable values: active, pending, loading, completed, error
start_date
date
Filter by minimum travel date (inclusive)Format: YYYY-MM-DD
end_date
date
Filter by maximum travel date (inclusive)Format: YYYY-MM-DD
name
string
Search by name (case-insensitive substring match)
name[]
array[string]
Filter by exact name values (multi-select, OR logic)
file_id[]
array[uuid]
Filter by source file UUID
created_at_from
datetime
Filter records created on or after this timestampFormat: YYYY-MM-DDTHH:MM:SSZ
created_at_to
datetime
Filter records created on or before this timestampFormat: YYYY-MM-DDTHH:MM:SSZ
co2e_status
string
Filter by CO2e calculation statusAvailable values: calculated, not_calculated

Body Parameters

filter_hash
string
required
Hash returned by the list endpoint for the current filter combination. Prevents deleting records from a stale filter state.

Response

success_count
integer
Number of items successfully deleted
success_ids
array[string]
UUIDs of business travels that were successfully deleted
failed_count
integer
Number of items that failed to delete
failed_ids
array[string]
UUIDs that could not be deleted (not found or deletion error)
message
string
Human-readable summary message

Example

# Step 1: List with filters to get the filter_hash
FILTER_HASH=$(curl -s -X GET "https://api.dcycle.io/v1/business-travels?transport_type[]=aircraft&start_date=2024-01-01&end_date=2024-12-31" \
  -H "x-api-key: ${DCYCLE_API_KEY}" \
  -H "x-organization-id: ${DCYCLE_ORG_ID}" | jq -r '.filter_hash')

# Step 2: Delete all matching records
curl -X POST "https://api.dcycle.io/v1/business-travels/bulk-delete-by-filters?transport_type[]=aircraft&start_date=2024-01-01&end_date=2024-12-31" \
  -H "x-api-key: ${DCYCLE_API_KEY}" \
  -H "x-organization-id: ${DCYCLE_ORG_ID}" \
  -H "Content-Type: application/json" \
  -d "{\"filter_hash\": \"${FILTER_HASH}\"}"
import requests
import os

headers = {
    "x-api-key": os.getenv("DCYCLE_API_KEY"),
    "x-organization-id": os.getenv("DCYCLE_ORG_ID"),
}
filters = {
    "transport_type[]": ["aircraft"],
    "start_date": "2024-01-01",
    "end_date": "2024-12-31",
}

# Step 1: Get the filter_hash
list_response = requests.get(
    "https://api.dcycle.io/v1/business-travels",
    headers=headers,
    params=filters,
)
filter_hash = list_response.json()["filter_hash"]

# Step 2: Delete all matching records
response = requests.post(
    "https://api.dcycle.io/v1/business-travels/bulk-delete-by-filters",
    headers=headers,
    params=filters,
    json={"filter_hash": filter_hash},
)

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

const headers = {
  'x-api-key': process.env.DCYCLE_API_KEY,
  'x-organization-id': process.env.DCYCLE_ORG_ID,
};
const filters = {
  'transport_type[]': ['aircraft'],
  start_date: '2024-01-01',
  end_date: '2024-12-31',
};

// Step 1: Get filter_hash
const { data: listData } = await axios.get(
  'https://api.dcycle.io/v1/business-travels',
  { headers, params: filters }
);

// Step 2: Delete matching records
const { data: result } = await axios.post(
  'https://api.dcycle.io/v1/business-travels/bulk-delete-by-filters',
  { filter_hash: listData.filter_hash },
  { headers: { ...headers, 'Content-Type': 'application/json' }, params: filters }
);

console.log(`Deleted: ${result.success_count}, Failed: ${result.failed_count}`);
console.log(result.message);

Successful Response

{
  "success_count": 42,
  "success_ids": [
    "550e8400-e29b-41d4-a716-446655440000",
    "550e8400-e29b-41d4-a716-446655440001"
  ],
  "failed_count": 0,
  "failed_ids": [],
  "message": "Bulk delete completed: 42 deleted, 0 failed"
}

Common Errors

401 Unauthorized

Cause: Missing or invalid API key
{"detail": "Invalid API key for organization", "code": "INVALID_API_KEY"}

403 Forbidden

Cause: The authenticated user is not a member of the organization
{"detail": "Logged User is not Member of Organization", "code": "LOGGED_USER_NOT_MEMBER"}

409 Conflict

Cause: Filters changed since the list was loaded
{
  "detail": "Filter hash mismatch. The filters have changed since the list was loaded. Please refresh and try again."
}

422 Unprocessable Entity

Cause: No filter parameters provided
{
  "detail": "At least one filter parameter is required for bulk delete by filters."
}

Bulk Delete

Delete specific records by ID

List

Browse and filter business travels

Delete

Delete a single business travel