Skip to main content
POST
← Vehicles API Create one or many fuel or energy consumptions of your vehicles (Scope 1 for owned vehicles, with their upstream emissions in Scope 3 category 3). Say which vehicle, how much, in which unit and over which period; Dcycle picks the emission factor of the vehicle’s class, fuel and country and calculates the emissions in the background. The consumptions are the ones the app shows under each vehicle. The request checks every record and writes them all at once, then answers 202 Accepted with an ingest job that calculates them. Follow it with GET /v2/ingest-jobs/{id} or the ingest_job.finished webhook.
Beta. Part of the bulk ingest API, currently in beta. The contract may still change before general availability.

How it works

  1. Every record is checked. If any is invalid the whole request is rejected with 422 and nothing is written; the answer lists every invalid record, so you can fix them all at once.
  2. The consumptions are written at once, with status loading. Each belongs to its vehicle’s organization: the x-organization-id organization or one under it that you can write to.
  3. The job calculates them in the background, in chunks. Each consumption ends success or error: its job item is then failed with CALCULATION_FAILED, e.g. when there is no emission factor for the vehicle’s class, fuel and country in the consumption’s year.
  4. When every chunk is done the job is completed (or completed_with_errors) and ingest_job.finished is sent to your webhook endpoints.

A spend in euros

A consumption in euros (unit_id d3e37f2b-0fc3-4532-82f8-3890ab56ad37) is stored in litres: the amount is divided by the pump price, taxes included, of the vehicle’s fuel in the vehicle’s country in the EU Weekly Oil Bulletin published on or up to two weeks before start_date. The euros are kept as the consumption’s spend. A fuel or country the bulletin does not cover, or a date with no bulletin (before 2020), is NO_FUEL_PRICE_FOR_SPEND: send litres instead. Vehicles with a legacy custom emission factor group keep the euros, since their factors may be per euro.

Request

Headers

string
required
Your API key (see Authentication).
string
required
Your organization. Its vehicles, and those of the organizations under it that you can write to, can take consumptions; each consumption belongs to its vehicle’s organization.
string
required
1 to 255 characters, unique per batch. A retry with the same key and body returns the original job (with Idempotent-Replayed: true) instead of creating the consumptions again; the same key with another body is 422 IDEMPOTENCY_KEY_REUSED, and while the first request is still being processed 409 IDEMPOTENCY_KEY_IN_PROGRESS.

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.

Body Parameters

array[object]
required
The consumptions to create, 1 to 5,000. A field not listed here is rejected (SCHEMA_INVALID).

Response

202 Accepted with the job (entity_type: vehicle_consumptions, operation: create) and a Location header to it. GET /v2/ingest-jobs/{id}/items has one item per record, in the order sent: its entity_id is the consumption’s id (the one Delete Vehicle Consumptions (v2) takes), and a failed item carries its error_code.

Errors

Problem details. Per-record codes in errors[].error_code of a 422 BULK_RECORDS_REJECTED: 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

Delete Vehicle Consumptions (v2)

Delete consumptions by id

Create Vehicles (v2)

The vehicles, and their ids

List Vehicle Fuels

Fuel and unit ids

Get Ingest Job

Follow the calculation

List Job Items

The consumption id and outcome of each record