Update Business Travel
Update an existing business travel record. Only provide the fields you want to change. Emissions will be recalculated automatically if relevant fields are modified.
Request
Bearer token for authenticationExample: Bearer sk_live_1234567890abcdef
Your organization UUIDExample: a8315ef3-dd50-43f8-b7ce-d839e68d51fa
Path Parameters
The unique identifier (UUID) of the business travel recordExample: 550e8400-e29b-41d4-a716-446655440000
Body Parameters
All fields are optional. Only include the fields you want to update.
Date of the business travelFormat: YYYY-MM-DD
Mode of transportAvailable values: car, metro, train, trolleybus, bus, motorbike, aircraft, ferry
Distance traveled in kilometersConstraints: Must be positive
Starting location address
Number of travelersConstraints: 1 to 1000
Whether this is a round trip
Vehicle size (for car or motorbike)Available values: small, medium, large, average
Fuel type (for car or motorbike)Available values: petrol, diesel, cng, lpg, unknown, plug_in_hybrid_electric, battery_electric
Flight type (for aircraft)Available values: domestic, short_haul_international, long_haul_international
Cabin class (for aircraft)Available values: economy, premium_economy, business, first, average
Response
Returns the updated business travel object.
Example
curl -X PATCH "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}" \
-H "Content-Type: application/json" \
-d '{
"travel_number": 3,
"round_trip": true
}'
Successful Response
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"travel_date": "2024-12-01",
"transport_type": "train",
"distance_km": 621.5,
"origin": "Madrid, Spain",
"destination": "Barcelona, Spain",
"travel_number": 3,
"round_trip": true,
"vehicle_size": null,
"fuel_type": null,
"flight_type": null,
"cabin_class": null,
"status": "pending",
"co2e": 24.86,
"created_at": "2024-12-01T10:30:00Z",
"updated_at": "2024-12-01T14:45:00Z"
}
When updating fields that affect emissions (distance, transport type, travel number, round trip), the co2e value will be recalculated asynchronously. The status may temporarily change to pending.
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"
}
422 Validation Error
Cause: Invalid field values
{
"detail": [
{
"loc": ["body", "travel_number"],
"msg": "ensure this value is less than or equal to 1000",
"type": "value_error.number.not_le"
}
]
}
Use Cases
Update Flight Class
Change the cabin class for an existing flight:
response = requests.patch(
f"https://api.dcycle.io/v1/business-travels/{travel_id}",
headers=headers,
json={"cabin_class": "business"}
)
# Emissions will be recalculated for business class
Change Route with Distance Recalculation
Update origin and destination to recalculate distance:
response = requests.patch(
f"https://api.dcycle.io/v1/business-travels/{travel_id}",
headers=headers,
json={
"origin": "Paris, France",
"destination": "Berlin, Germany"
}
)
# Distance will be recalculated automatically
Correct Number of Travelers
response = requests.patch(
f"https://api.dcycle.io/v1/business-travels/{travel_id}",
headers=headers,
json={"travel_number": 5}
)