Bulk Upload Vehicle Consumptions
Bulk Upload Vehicle Consumptions
Get a presigned URL to upload multiple vehicle consumption records via CSV
POST
Bulk Upload Vehicle Consumptions
Bulk Upload Vehicle Consumptions
Upload hundreds of vehicle fuel consumption records at once via a CSV file. This endpoint returns a presigned S3 URL so you can upload your file, which will be processed asynchronously.This method is recommended for bulk uploads. Consumption records are persisted in the database and emissions are calculated automatically based on fuel type and quantity.
Upload Flow
Request presigned URL
Make a POST request to
/api/v1/vehicle_consumptions/bulk/csv with your file nameAsynchronous processing
The system processes your file in the background, creating consumption records and calculating emissions
Verify results
Check consumption records with the List Vehicle Consumptions endpoint
Step 1: Request Presigned URL
Request
Headers
Your API key for authenticationExample:
sk_live_1234567890abcdefYour organization UUIDExample:
ff4adcc7-8172-45fe-9cf1-e90a6de53aa9Your user UUIDExample:
a1b2c3d4-e5f6-7890-abcd-ef1234567890Body Parameters
Name of the CSV file you’re going to uploadExample:
"2024_vehicle_fuel_records.csv"Response
Presigned S3 URL to upload the consumption records file
Sanitized file name (alphanumeric only)
File UUID for tracking
Full S3 key where file will be stored
Confirmation message
Example
Successful Response
Step 2: Upload CSV to S3
Use the presigned URL to upload your CSV file directly to S3:CSV Format
The CSV must follow this structure for creating vehicle consumption records:Required Columns
| Column | Description | Valid Values | Example |
|---|---|---|---|
vehicle_id | UUID of the vehicle | UUID from /api/v1/vehicles | a1b2c3d4-... |
quantity | Fuel quantity consumed | Positive number | 45.5 |
unit_id | UUID of measurement unit | UUID from /api/v1/units | liter-unit-uuid |
start_date | Consumption period start | YYYY-MM-DD format | 2024-01-15 |
end_date | Consumption period end | YYYY-MM-DD format | 2024-01-15 |
Optional Columns
| Column | Description | Example |
|---|---|---|
custom_id | External reference ID (fuel card, invoice number) | FUELCARD-2024-001 |
base_total_spend | Total cost of the consumption (must be >= 0) | 120.50 |
currency_unit | Currency name for the spend amount | euros_(eur) |
Column Details
vehicle_id:- Must be a valid UUID from your vehicles list
- Get valid vehicle IDs:
GET /api/v1/vehicles - Vehicle must belong to your organization
- Must be positive number
- No negative values allowed
- Precision: up to 6 decimal places
- Must be a valid UUID from the Units endpoint
- Typically liquid units (L, gal) for combustion vehicles
- Energy units (kWh) for electric vehicles
- Get valid unit IDs:
GET /api/v1/units
- Format:
YYYY-MM-DD - Must be today or in the past
- end_date must be >= start_date
- Can be same day for single refueling events
- Used to track consumption periods
- External reference for tracking
- Examples: fuel card transaction ID, invoice number, receipt ID
- Useful for reconciliation with fuel card systems
- Max length: 255 characters
- Total monetary cost of the consumption
- Must be a non-negative number (>= 0)
- Can be provided independently of
currency_unit
- Name of the currency for the spend amount
- Must match a valid fiat currency unit name (e.g.,
euros_(eur),us_dollar_(usd),british_pound_(gbp)) - Can be provided independently of
base_total_spend - Get valid currency names:
GET /api/v1/units?type=fiat_currency
Download Template
Download CSV Template
Template with correct format and sample data
Step 3: Asynchronous Processing
Once the CSV is uploaded:- Validation: The system validates format, vehicle IDs, units, and dates
- Processing: Each row is processed and consumption records are created
- Emission Calculation: CO2e values calculated using vehicle fuel type and emission factors
- Status Update: Records marked as
activeorerrorbased on processing result - Notification: (Coming soon) You’ll receive a webhook when complete
Processing can take from a few seconds to several minutes depending on file size and number of records.
Step 4: Verify Results
After processing, you can query consumption records for each vehicle:Complete Example Script
Common Errors
400 Bad Request - Missing file_name
file_name parameter in the request body.
403 Forbidden - URL Expired
Cause: The presigned URL expired (15 minutes) Solution: Request a new presigned URL and upload the file immediately.422 Validation Error - CSV Format
Cause: The CSV has incorrect format or missing required columns Solution: Verify that your CSV has all required columns (vehicle_id, quantity, unit_id, start_date, end_date) and correct format.
422 Validation Error - Invalid Vehicle ID
Cause:vehicle_id doesn’t exist or doesn’t belong to your organization
Solution: Use the Vehicles endpoint to get valid vehicle IDs from your fleet.
422 Validation Error - Invalid Unit ID
Cause:unit_id doesn’t exist or is not compatible with vehicle fuel type
Solution: Use the Units endpoint to get valid unit IDs. For liquid fuels use L, for electric use kWh.
422 Validation Error - Invalid Date
Cause: Date is in the future or incorrectly formatted Solution: Ensure all dates are today or in the past, and useYYYY-MM-DD format.
422 Validation Error - End Date Before Start Date
Cause:end_date is earlier than start_date
Solution: Ensure end_date >= start_date.
Limits and Recommendations
| Limit | Value |
|---|---|
| Maximum file size | 100 MB |
| Maximum rows per CSV | 100,000 |
| URL expiration time | 15 minutes |
| Processing time | ~1 second per 200 records |
Best Practices
Data Preparation
- Get Vehicle IDs first: Query your vehicles before creating the CSV
- Get Unit IDs: Ensure unit IDs match vehicle fuel types (L for liquid fuels, kWh for electric)
- Validate dates: All dates must be today or in the past
- Use custom_id: Include external references (fuel card IDs) for reconciliation
- Group by refueling events: One row per refueling event or period
Error Handling
After upload, check for consumption records withstatus: "error":
Incremental Updates
To add new consumption records:- Get latest consumption date for each vehicle
- Export new records from fuel card system
- Upload only new records (avoid duplicates)
Data Sources
Common sources for vehicle consumption data:- Fuel Card Systems: Transaction exports from providers (Shell, BP, Repsol)
- Telematics: GPS fleet tracking systems with fuel monitoring
- Manual Logs: Driver-reported fuel purchases
- Accounting Systems: Fuel expense records
- Electric Vehicle Charging: Charging station APIs or apps
Integration Examples
Fuel Card System Integration
Electric Vehicle Charging Integration
Related Endpoints
List Vehicle Consumptions
View uploaded consumption records
List Vehicles
Get vehicle IDs for your fleet
List Units
Get measurement units for consumptions
Authentication
Learn about API authentication

