Skip to main content
POST
← Employees API Say how your employees got to work (Scope 3 category 7, employee commuting): one record per employee and period, with the modes they worked in. A mode is in_person (a transport and the days of the week it took them to work) or telecommuting (the days, or the hours, they worked from home); a hybrid employee sends both, each day of the week in one mode only, as the commuting survey of the Dcycle app asks it. Dcycle works out the distance when you leave it out and calculates the emissions in the background. Each record is stored as one response of the employee for that period, as the app’s form, the survey and the Data Importer store theirs: one commuting period per transport, with the days at home on the first one. These are the periods List Commuting Periods reads, in the vocabulary of POST /v1/employee-historic. An employee has one response at a time: a record whose dates overlap another response of the employee is rejected, whatever the weekdays. A record requires what the app’s form and the Data Importer require, since without it a period cannot be calculated. Every period is stored as in_itinere: commuting to and from work. Travel during working hours (in_labore) goes through POST /v1/employee-historic. The request checks every record and writes them all at once, then answers 202 Accepted with an ingest job that calculates them (see how bulk ingestion works). Follow it with GET /v2/ingest-jobs/{id} or, for a job submitted with an API key, the ingest_job.finished webhook. Like the rest of the bulk ingest API, this route never sends an email.
Beta. Part of the bulk ingest API, in beta. The contract may still change before general availability.

Choose the work model

Start from how the employee worked in the period, the work-model question of the app’s commuting survey. It decides which modes the record sends: Each day of the week goes in one mode only: a car on Monday and Tuesday and a train on Wednesday are two in_person modes, and the days at home are the telecommuting one. The app’s analytics show an in_person period as On-site and a telecommuting one as Remote.

Build a record

The questions of the app’s commuting survey, grouped by mode. Each step says which modes it applies to.
1

Who and when (every record)

employee_id, start_date and end_date. A change of address or transport within the year is a new record, with its own dates.An employee on leave or gone in the period sends situation: inactive or terminated. The situation only labels the period: send the modes of the days they worked, and they are calculated as any other’s; send no modes and the period has no commute and is calculated at 0 kg. Every other record is active, the default, and sends 1 to 8 modes.
2

How they got to work (in_person)

transport_type, and the details that only that transport takes:
  • carpool: true says the car is shared. Only a car takes it; left out or null, it is false.
  • renewable_energy (yes, no or do_not_know) goes only with fuel_type: electric: whether that electricity is renewable.
  • With walking, send no vehicle detail.
3

How far and how often (in_person)

  • The days: days, the days of the week they went to work with that transport, monday to sunday. The app’s survey asks how many days and stores them from Monday; send the actual days when you know them, since public holidays are removed by date.
  • The distance, one way: distance_km, or origin and destination for Dcycle to measure the road or rail route between them (by the transport). When your system knows the distance, send distance_km and leave the places out; any you send are only stored.
  • The trips: daily_trips, round trips each of those days, 1 (the default) to 3.
4

Days at home (telecommuting)

  • days, the days of the week they worked from home, or, when only the total is known, total_hours for the whole period. Send one of the two, never both.
  • hours_per_day (default 8) prices each day at home.
  • One telecommuting mode at most: send all the days at home in it.

How it works

  1. Every record is checked: its fields and the rules of its modes, its employee, its custom factors, and that it does not overlap another response of its employee, from any channel (this route, the app’s form, the survey, the Data Importer), nor an earlier record of the request. If any record is invalid the whole request is rejected with 422 and nothing is written; rejected is the number of invalid records and errors lists them (up to 100). The request never measures a distance, and leaves the job at most 500 distinct routes to measure (origin, destination and the road or rail network of the transport): a route repeated in the request counts once.
  2. The records are written at once, each as one response of its employee for its dates, in the organization of its employee (the x-organization-id organization or one of its perimeter), with one commuting period per transport, all with the record’s dates. The days at home (telecommuting days) go on the first transport’s period; they are a telecommuting period of their own when the record has no in_person mode, or when they are given as total_hours. Its custom_responses go on the first period. A record for the exact dates of a survey sent to the employee answers it.
  3. The job calculates each response in the background, in chunks. An in_person period sent without distance_km gets the distance of the road or rail route (by its transport) between its origin and destination, and is marked total_km_estimated. Then its commute is calculated under employee commuting, and the days at home under telecommuting. An employee with a calculated period is uploaded. A period that is not active is calculated the same way: its modes when it has them, else at 0 kg. A job item is failed, with the period_id of a period that failed in error_params, when:
    • DISTANCE_CALCULATION_ERROR: a place could not be found or no route joins them. That period is kept without a distance and is not calculated: write the response again (the item’s entity_id) with Replace Commuting Response (v2), with distance_km or other places for that mode.
    • CALCULATION_FAILED: a period produced no emission at all (no factor for its commute or its days at home).
    The response’s other periods keep their emissions.
  4. When every chunk is done the job is completed (or completed_with_errors). For a job submitted with an API key, ingest_job.finished is sent to the webhook endpoints of the x-organization-id organization.

How a period is counted

  • An in_person period is the same trip repeated on its days between start_date and end_date, without the public holidays of the organization’s country: daily_trips round trips each of those days, each twice the distance (there and back). A shared car (carpool: true) splits the emissions in 3.
  • The days at home count their days between the same dates, without the same holidays, priced per hour worked (hours_per_day each) or per day, depending on the factor, whichever period holds them. Sent with total_hours, they are priced on those hours instead, spread over the years of the period by calendar days (a factor per day reads them as total_hours / hours_per_day days).
For example, the Hybrid record of the request examples, in a week with no public holidays: 2 days × 1 round trip × 2 × 18 km = 72 km by car, shared by 3; 1 × 1 × 2 × 32.5 km = 65 km by train; and 2 days at home × 8 hours = 16 hours worked from home (or 2 days, when the factor is per day).

Request

Headers

string
required
Your API key (see Authentication).
string
required
The organization you send as. Its employees, and those of the organizations under it that you can write to (its perimeter), can be given records. The job and its ingest_job.finished webhook belong to this organization.
string
required
1 to 255 characters, one per batch, looked up per organization across every v2 bulk route. Within 24 hours, the same key with the same route and body returns the original job (with Idempotent-Replayed: true) instead of writing the records again; the same key with another body or on another route is 422 IDEMPOTENCY_KEY_REUSED, and while the first request is still being processed 409 IDEMPOTENCY_KEY_IN_PROGRESS. After 24 hours the key is free, and a request with it is a new one. See The Idempotency-Key.

Query Parameters

boolean
default:"false"
Check only: the same 422 for invalid records, nothing written, no job; 200 with {"dry_run": true, "submitted": n, "valid": n} when every record is valid. The Idempotency-Key header is still required, but a dry run does not check or store it.

Body Parameters

array[object]
required
The records to create, 1 to 5,000: one per employee and period. A field not listed here is rejected (SCHEMA_INVALID).

Response

202 Accepted with the job (entity_type: employee_commuting, operation: create) and a Location header to it. To read the result:
If chunks_done stops moving, see A job that does not finish: never resend the batch with a new Idempotency-Key: its records are already stored, so a second send is rejected with COMMUTING_RESPONSE_OVERLAP.

Errors

Problem details. Per-record codes in errors[].error_code of a 422 BULK_RECORDS_REJECTED: After the 202, a job item can end failed with DISTANCE_CALCULATION_ERROR or CALCULATION_FAILED (see How it works).

Common mistakes

Each one answers SCHEMA_INVALID for the record: Request-level errors: 401 for a missing or invalid API key, 403 LOGGED_USER_NOT_MEMBER when the key’s user is not a member of the organization, 422 REQUEST_VALIDATION_FAILED for a malformed body (no records, more than 5,000, no Idempotency-Key), 422 IDEMPOTENCY_KEY_REUSED, 409 IDEMPOTENCY_KEY_IN_PROGRESS, and 429 beyond the rate limits.

Limits

Create Employees (v2)

The employees, and their employee_id

Replace Commuting Response (v2)

Write a response again whole

Delete Commuting Periods (v2)

Delete periods, or whole responses

List Job Items

The response and outcome of each record

List Custom Factor Records

The ids for custom_ef_record_id