Deprecated. Use POST /v2/vehicle-consumptions: the consumptions as JSON records in the request, all or nothing, idempotent, with no file to upload. This endpoint keeps working; its responses carry Deprecation and Link: </v2/vehicle-consumptions>; rel="successor-version" headers. Its responses also carry Sunset: Fri, 30 Apr 2027 00:00:00 GMT: the endpoint is retired on April 30, 2027 (see the changelog).
Generate a presigned S3 upload URL for bulk importing vehicle consumption records via CSV file. After uploading the CSV to the returned URL, the system processes the file asynchronously and creates the consumption records.
Request
Headers
string
required
Your API key for authenticationExample:sk_live_1234567890abcdef
string
required
Your organization UUIDExample:a8315ef3-dd50-43f8-b7ce-d839e68d51fa
Body Parameters
string
required
Name of the CSV file to upload (must end in .csv)Example:fleet-fuel-q1-2025.csv
Response
string
Presigned S3 URL to upload the CSV file via PUT request
string
The file name as stored
string
UUID of the created file record for tracking
string
S3 key where the file will be stored
string
Confirmation message
Example
# Step 1: Get presigned upload URLRESPONSE=$(curl -s -X POST "https://api.dcycle.io/v1/vehicle_consumptions/bulk/csv" \ -H "x-api-key: ${DCYCLE_API_KEY}" \ -H "x-organization-id: ${DCYCLE_ORG_ID}" \ -H "Content-Type: application/json" \ -d '{"file_name": "fleet-fuel-q1-2025.csv"}')UPLOAD_URL=$(echo $RESPONSE | jq -r '.upload_url')# Step 2: Upload the CSV to the presigned URLcurl -X PUT "$UPLOAD_URL" \ -H "Content-Type: text/csv" \ --data-binary @fleet-fuel-q1-2025.csv
import requestsimport osheaders = { "x-api-key": os.getenv("DCYCLE_API_KEY"), "x-organization-id": os.getenv("DCYCLE_ORG_ID"), "Content-Type": "application/json",}# Step 1: Get presigned upload URLresponse = requests.post( "https://api.dcycle.io/v1/vehicle_consumptions/bulk/csv", headers=headers, json={"file_name": "fleet-fuel-q1-2025.csv"},)result = response.json()upload_url = result["upload_url"]print(f"File ID: {result['file_id']}")# Step 2: Upload the CSVwith open("fleet-fuel-q1-2025.csv", "rb") as f: requests.put(upload_url, data=f, headers={"Content-Type": "text/csv"})print("Upload complete — processing will begin shortly")
Each row’s unit_measure must be one of the units its consumption’s fuel accepts (the fuel_units of
List Vehicle Fuels). The consumption’s fuel is the row’s
fuel(optional) value, or the vehicle’s primary fuel when that cell is blank, so on a multi-fuel
vehicle the same unit can be valid on one row and refused on another. A refused row is stored in
error with ERR_UNIT_NOT_ALLOWED_FOR_FUEL and is not calculated.
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"}
422 Unprocessable Entity
Cause: Invalid or missing file name in the request body