Skip to main content

Employees API

The Employees API allows you to create, retrieve, update, and delete employee records for tracking commuting patterns and calculating Scope 3 Category 7 (Employee Commuting) emissions. Each employee can have multiple commuting periods with detailed transport information for accurate CO2e calculations.
GHG Protocol Scope 3 Category 7Employee commuting covers emissions from transportation of employees between their homes and worksites. This API helps you collect and manage the data needed for accurate Category 7 reporting.

Key Features

  • Employee Management: Create and manage employee records with contact information
  • Commuting Periods: Track multiple commuting patterns per employee over time
  • Transport Modes: Support for cars, public transit, cycling, walking, and remote work
  • CO2e Calculation: Automatic emissions calculation based on distance, transport mode, and frequency
  • Survey Integration: Send surveys to employees to collect commuting data
  • Bulk Upload: Import employee data via CSV for large organizations
  • Pagination Support: Efficiently retrieve large employee lists

Authentication

All endpoints require authentication using either:
  • API Key: Include in x-api-key header
  • JWT Token: Include in Authorization header as Bearer {JWT_TOKEN}

Headers

All requests must include:
x-organization-id
string
required
Your organization UUIDExample: a8315ef3-dd50-43f8-b7ce-d839e68d51fa
x-api-key
string
required
Your API key for authenticationExample: sk_live_1234567890abcdef

Available Endpoints

Employees

Commuting Periods

Data Model

Employee Object

The employee object contains basic employee information:
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "John Smith",
  "email": "[email protected]",
  "organization_id": "a8315ef3-dd50-43f8-b7ce-d839e68d51fa",
  "situation": "active",
  "status": "uploaded",
  "periods": [...],
  "created_at": "2024-01-15T10:30:00Z",
  "updated_at": "2024-01-15T10:30:00Z"
}

Employee Attributes

FieldTypeDescription
idUUIDUnique identifier for the employee
namestringEmployee’s full name
emailstringEmployee’s email address
organization_idUUIDOrganization the employee belongs to
situationstringEmployment status: active, inactive, terminated
statusstringData status: uploaded, loading
periodsarrayList of commuting periods (when requested)
created_atdatetimeWhen the employee was created
updated_atdatetimeWhen the employee was last updated

Commuting Period Object

Commuting periods track how an employee commutes during a specific time range:
{
  "id": "660e8400-e29b-41d4-a716-446655440000",
  "employee_id": "550e8400-e29b-41d4-a716-446655440000",
  "start_date": "2024-01-01",
  "end_date": "2024-12-31",
  "commuting_type": "in_itinere",
  "transport_type": "car",
  "vehicle_size": "medium",
  "fuel_type": "petrol",
  "total_km": 15,
  "weekly_travels": [0, 1, 2, 3, 4],
  "daily_trips": 1,
  "carpool": false,
  "situation": "active",
  "co2e": 1245.5,
  "created_at": "2024-01-15T10:30:00Z",
  "updated_at": "2024-01-15T10:30:00Z"
}

Transport Types

Transport TypeDescriptionRequires Fuel TypeRequires Vehicle Size
carPersonal vehicleYesYes
busPublic busYesNo
trainCommuter railOptionalNo
metroUrban subwayOptionalNo
tramLight railNoNo
motorbikeMotorcycleYesNo
bicycleCycling (including e-bike)OptionalNo
walkingWalkingNoNo
telecommutingRemote workNoNo
electric_kick_scooterElectric scooterNoNo
trolleybusElectric busOptionalNo

Fuel Types

Fuel TypeDescriptionApplicable Transport
petrolGasolinecar, motorbike, bus
dieselDiesel fuelcar, motorbike, bus
electricElectric vehiclecar, motorbike, metro, train, bicycle
hybridHybrid vehiclecar
lpgLiquefied petroleum gascar, bus
natural_gasNatural gascar, bus
not_fuel_basedNo fuel (human powered)bicycle
do_not_knowUnknown fuel typeAny motorized

Vehicle Sizes (Cars Only)

SizeDescription
smallCompact cars (e.g., city cars, superminis)
mediumMid-size sedans and hatchbacks
largeSUVs, large sedans, minivans

Weekly Travels

The weekly_travels field is an array of integers representing which days the employee commutes:
ValueDay
0Monday
1Tuesday
2Wednesday
3Thursday
4Friday
5Saturday
6Sunday
Examples:
  • [0, 1, 2, 3, 4] - Monday to Friday (5-day week)
  • [1, 3] - Tuesday and Thursday only (hybrid)
  • [] - Fully remote (telecommuting)

CO2e Calculation

Emissions are calculated using the formula:
CO2e = Distance (km) × Working Days × Daily Trips × Emission Factor × 2 (round trip)
  • Distance: One-way distance from home to work (total_km)
  • Working Days: Calculated from weekly_travels and date range
  • Daily Trips: Number of round trips per day
  • Emission Factor: Based on transport type, fuel, and vehicle size (from Ecoinvent database)
  • Carpool Factor: If carpool: true, emissions are divided by 3

Workflow

Tracking Employee Commuting

  1. Create Employee: Add employee with name or email
  2. Create Commuting Period: Define the commuting pattern for a date range
  3. Query Emissions: Retrieve employee with periods to see calculated CO2e

Using Surveys

  1. Upload Employees via CSV: Bulk create employees with email addresses
  2. Send Survey: Use the resend-survey endpoint to collect commuting data
  3. Review Results: Employees fill in the survey, creating commuting periods automatically

Error Handling

Common HTTP Status Codes

StatusMeaningSolution
200Success-
201Created-
204No Content (delete successful)-
400Bad RequestCheck request parameters and format
401UnauthorizedVerify API key
404Not FoundCheck resource ID or organization
422Validation ErrorReview error details in response
500Server ErrorContact support if persists

Error Response Format

{
  "detail": "Error description",
  "code": "ERROR_CODE"
}

Use Cases

Track Office Commuting

Monitor CO2e emissions for employees commuting to the office:
import requests

# Create employee
employee = requests.post(
    "https://api.dcycle.io/v1/employees",
    headers=headers,
    json={
        "name": "John Smith",
        "email": "[email protected]",
        "situation": "active",
        "status": "uploaded"
    }
).json()

# Add commuting period
period = requests.post(
    "https://api.dcycle.io/v1/employee-historic",
    headers=headers,
    json={
        "employee_id": employee["id"],
        "start_date": "2024-01-01",
        "end_date": "2024-12-31",
        "commuting_type": "in_itinere",
        "transport_type": "car",
        "vehicle_size": "medium",
        "fuel_type": "petrol",
        "total_km": 15,
        "weekly_travels": [0, 1, 2, 3, 4],
        "daily_trips": 1,
        "carpool": False,
        "situation": "active",
        "response_medium": "manual"
    }
).json()

print(f"Annual CO2e: {period['co2e']} kg")

Calculate Category 7 Totals

Sum up all employee commuting emissions:
# Get all employees with periods
response = requests.get(
    "https://api.dcycle.io/v1/employees",
    headers=headers,
    params={"size": 100}
).json()

total_co2e = 0
for employee in response["items"]:
    for period in employee.get("periods", []):
        total_co2e += period.get("co2e", 0)

print(f"Scope 3 Category 7 Total: {total_co2e} kg CO2e")