Skip to main content
POST
/
v1
/
vehicle_consumptions
/
bulk
/
csv
Consumptions CSV Import
const options = {
  method: 'POST',
  headers: {
    'x-api-key': '<x-api-key>',
    'x-organization-id': '<x-organization-id>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({file_name: '<string>'})
};

fetch('https://api.dcycle.io/v1/vehicle_consumptions/bulk/csv', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
{
  "upload_url": "<string>",
  "file_name": "<string>",
  "file_id": "<string>",
  "destination_file_key": "<string>",
  "message": "<string>"
}

Consumptions CSV Import

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

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

Body Parameters

file_name
string
required
Name of the CSV file to upload (must end in .csv)Example: fleet-fuel-q1-2025.csv

Response

upload_url
string
Presigned S3 URL to upload the CSV file via PUT request
file_name
string
The file name as stored
file_id
string
UUID of the created file record for tracking
destination_file_key
string
S3 key where the file will be stored
message
string
Confirmation message

Example

# Step 1: Get presigned upload URL
RESPONSE=$(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 URL
curl -X PUT "$UPLOAD_URL" \
  -H "Content-Type: text/csv" \
  --data-binary @fleet-fuel-q1-2025.csv

Successful Response

{
  "upload_url": "https://s3.eu-west-1.amazonaws.com/dcycle-uploads/...",
  "file_name": "fleet-fuel-q1-2025.csv",
  "file_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "destination_file_key": "organizations/org-uuid/vehicle-consumptions/a1b2c3d4.csv",
  "message": "Upload URL generated successfully"
}

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
{
  "detail": [
    {
      "loc": ["body", "file_name"],
      "msg": "field required",
      "type": "value_error.missing"
    }
  ]
}

List Consumptions

Browse imported consumption records

Delete by File

Delete all consumptions from a specific import