Skip to main content
POST
/
v1
/
employee-historic
/
bulk
/
csv
CSV Upload
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/employee-historic/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>",
  "organization_id": "<string>"
}

CSV Upload

Generate a presigned S3 URL for bulk importing employee commuting periods via CSV. After uploading the file, the system processes each row to create commuting period records and trigger emission calculations.

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 uploadExample: commuting-data-2025.csv

CSV Format

The CSV file should contain the following columns:
ColumnRequiredDescription
employee_emailYesEmployee email for lookup
employee_nameNoEmployee name (fallback if email not found)
start_dateYesPeriod start date (YYYY-MM-DD)
end_dateYesPeriod end date (YYYY-MM-DD)
commuting_typeYesin_itinere or in_labore
transport_typeYescar, bus, metro, train, bicycle, walking, telecommuting, etc.
vehicle_sizeConditionalsmall/medium/large (required for car)
fuel_typeConditionalpetrol, diesel, electric, hybrid, etc.
renewable_energyConditionalyes/no/do_not_know (for electric vehicles)
carpoolConditionaltrue/false (required for car)
total_kmYesDistance per trip (km)
daily_tripsYesNumber of daily trips
weekly_travelsNoDays of week, semicolon-separated (e.g., 0;1;2;3;4 for Mon-Fri)
originNoOrigin address
destinationNoDestination address

Response

upload_url
string
Presigned S3 URL — upload your CSV via PUT to this URL
file_name
string
File name as stored
file_id
string
UUID of the created file record
destination_file_key
string
S3 object key where the file will be stored
message
string
Confirmation message
organization_id
string
UUID of the organization the file belongs to

Example

# Step 1: Get presigned URL
RESPONSE=$(curl -s -X POST "https://api.dcycle.io/v1/employee-historic/bulk/csv" \
  -H "x-api-key: ${DCYCLE_API_KEY}" \
  -H "x-organization-id: ${DCYCLE_ORG_ID}" \
  -H "Content-Type: application/json" \
  -d '{"file_name": "commuting-data-2025.csv"}')

# Step 2: Upload CSV to presigned URL
UPLOAD_URL=$(echo $RESPONSE | jq -r '.upload_url')
curl -X PUT "$UPLOAD_URL" -H "Content-Type: text/csv" --data-binary @commuting-data-2025.csv

echo "File ID: $(echo $RESPONSE | jq -r '.file_id')"

Successful Response

{
  "upload_url": "https://s3.eu-west-1.amazonaws.com/dcycle-uploads/...",
  "file_name": "commuting-data-2025.csv",
  "file_id": "file-uuid",
  "destination_file_key": "organizations/org-uuid/employee-commuting/file-uuid.csv",
  "message": "Upload URL generated successfully",
  "organization_id": "org-uuid"
}

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

List Commuting Periods

Browse imported commuting periods

Create Commuting Period

Create a single commuting period manually