Skip to main content
POST
← Vehicles API Create one or many vehicles of your fleet. A vehicle is master data: creating it calculates nothing (its emissions come from its consumptions), so the request is synchronous: it answers 201 Created with every vehicle, in the order you sent them, ready to take consumptions, and sends no webhook. It also records an ingest job, born completed with 0 of 0 chunks. See how bulk ingestion works.
Beta. Part of the bulk ingest API, in beta. The contract may still change before general availability.

How it works

  1. Every record is checked: the vehicle class and its fuels exist and the fuels are ones that class can run on, the country is known and the plate is free. If any record is invalid the whole request is rejected with 422 and nothing is created (all or nothing): rejected is the number of invalid records and errors lists them (up to 100).
  2. Every vehicle is created in one transaction and returned, in the order sent. source_row_index is the position of the record in records, and client_row_id echoes yours.
  3. The vehicles belong to the x-organization-id organization. A record cannot name another one, not even one of your perimeter: send each organization’s vehicles with its own x-organization-id.

Request

Headers

string
required
Your API key (see Authentication).
string
required
The organization the vehicles belong to.
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 answers the same vehicles (with Idempotent-Replayed: true) instead of creating them 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 created; 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. See dry run.

Body Parameters

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

Response

201 Created with items: one per record, in the order sent, each with source_row_index, client_row_id and the created vehicle: id, organization_id, license_plate, name, type, ownership, country, unknown_vehicle_id, vehicle_fuel_ids (primary first), registration_year, market_segment, size, status (active) and UTC timestamps ending in Z. Its emissions come with its consumptions: there is no co2e here.

Errors

Problem details. Per-record codes in errors[].error_code: 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 1,000, no Idempotency-Key), 422 IDEMPOTENCY_KEY_REUSED, 409 IDEMPOTENCY_KEY_IN_PROGRESS, and 429 beyond the rate limits.

Retries and idempotency

  • Network error or timeout: retry with the same Idempotency-Key and body. If the first request was accepted you get the same vehicles back, with Idempotent-Replayed: true, and nothing is duplicated.
  • 422 BULK_RECORDS_REJECTED: nothing was created. Fix the records and send the batch again.

Limits

Delete Vehicles (v2)

Delete up to 1,000 vehicles with their consumptions

List Unknown Vehicles

Ids for unknown_vehicle_id

List Vehicle Fuels

Ids for vehicle_fuel_ids

Create Vehicle Consumptions (v2)

Next step: the consumptions the vehicles’ emissions come from