Skip to main content
DELETE
https://api.dcycle.io
/
v1
/
business-travels
/
{business_travel_id}
Delete Business Travel
const options = {
  method: 'DELETE',
  headers: {Authorization: '<authorization>', 'x-organization-id': '<x-organization-id>'}
};

fetch('https://api.dcycle.io/v1/business-travels/{business_travel_id}', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));

Delete Business Travel

Permanently delete a business travel record from your organization. This action cannot be undone.
Permanent Action: Deleting a business travel record is permanent and cannot be undone. The associated emissions data will also be removed from your organization’s totals.

Request

Headers

Authorization
string
required
Bearer token for authenticationExample: Bearer sk_live_1234567890abcdef
x-organization-id
string
required
Your organization UUIDExample: a8315ef3-dd50-43f8-b7ce-d839e68d51fa

Path Parameters

business_travel_id
string
required
The unique identifier (UUID) of the business travel record to deleteExample: 550e8400-e29b-41d4-a716-446655440000

Response

Returns 204 No Content on successful deletion.

Example

curl -X DELETE "https://api.dcycle.io/v1/business-travels/550e8400-e29b-41d4-a716-446655440000" \
  -H "Authorization: Bearer ${DCYCLE_API_KEY}" \
  -H "x-organization-id: ${DCYCLE_ORG_ID}"

Successful Response

HTTP/1.1 204 No Content
No response body is returned on successful deletion.

Common Errors

401 Unauthorized

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

404 Not Found

Cause: Business travel not found or doesn’t belong to your organization
{
  "detail": "BusinessTravel with id=550e8400-e29b-41d4-a716-446655440000 not found",
  "code": "BUSINESS_TRAVEL_NOT_FOUND"
}
Solution: Verify that:
  1. The business travel ID is correct
  2. The business travel belongs to the organization specified in x-organization-id
  3. The record hasn’t already been deleted

Use Cases

Delete with Confirmation

Always verify before deleting:
def delete_business_travel(travel_id: str, confirm: bool = False):
    """Delete a business travel with optional confirmation"""
    # First, get the travel details
    response = requests.get(
        f"https://api.dcycle.io/v1/business-travels/{travel_id}",
        headers=headers
    )

    if response.status_code != 200:
        print(f"Travel not found: {travel_id}")
        return False

    travel = response.json()

    if not confirm:
        print(f"About to delete:")
        print(f"  Date: {travel['travel_date']}")
        print(f"  Route: {travel.get('origin', 'N/A')} -> {travel.get('destination', 'N/A')}")
        print(f"  Emissions: {travel['co2e']} kg CO2e")
        return False

    # Proceed with deletion
    response = requests.delete(
        f"https://api.dcycle.io/v1/business-travels/{travel_id}",
        headers=headers
    )

    return response.status_code == 204

# Preview deletion
delete_business_travel("550e8400-e29b-41d4-a716-446655440000")

# Confirm deletion
delete_business_travel("550e8400-e29b-41d4-a716-446655440000", confirm=True)

Bulk Delete by Date Range

Delete all business travels within a date range:
def delete_travels_in_range(start_date: str, end_date: str):
    """Delete all business travels in a date range"""
    # Get all travels in range
    response = requests.get(
        "https://api.dcycle.io/v1/business-travels",
        headers=headers,
        params={
            "start_date": start_date,
            "end_date": end_date,
            "size": 100
        }
    )

    travels = response.json()["items"]
    deleted = 0

    for travel in travels:
        response = requests.delete(
            f"https://api.dcycle.io/v1/business-travels/{travel['id']}",
            headers=headers
        )
        if response.status_code == 204:
            deleted += 1

    print(f"Deleted {deleted} business travels")
    return deleted

# Delete all travels from January 2024
delete_travels_in_range("2024-01-01", "2024-01-31")