Skip to main content
POST
← Transport API Create one or many freight shipments (Scope 3 categories 4 and 9, upstream and downstream transportation). Say when each shipment was made, in which direction, how much it weighed and its legs (sections), each with its transport and either its distance or the places it joins; Dcycle works out the distance when you leave it out, picks the emission factor and calculates the emissions in the background. The shipments are the ones /v1/transports reads and edits. 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.
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: its fields, its weight unit, each section’s transport against the combinations there are emission factors for, and its custom factors. If any 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 looks up no place: an address that cannot be found only shows in the job.
  2. The shipments are written at once, with their sections and status pending, in the x-organization-id organization.
  3. The job calculates them in the background, in chunks. A section sent without distance_km gets the distance between its origin and destination for its transport (road or rail route, sea route for maritime, great-circle for air), and its places are located. A do_not_know section is inferred as for POST /v1/transports: road by truck within a country when there is a road route, air otherwise. Then each section gets the emission factor of its transport, its distance and the shipment’s weight. A shipment that carries what it cost is priced by its spend when the distance of a section cannot be had, instead of failing with DISTANCE_CALCULATION_ERROR. Each shipment ends active or error. Its job item is then failed with the reason when there is one:
    • DISTANCE_CALCULATION_ERROR: the distance of a section could not be had: one of its places is on no map, or no distance for its transport joins them, and the shipment has no spend to price it (or a section is pinned to a custom factor that is not per currency). Send it again with the places fixed, with distance_km, or with what it cost.
    • CALCULATION_FAILED: a section could not be calculated. Either no emission factor applies to it (message says so; for example a custom_ef_record_id in a unit a leg cannot use: send it with another factor), or an error on our side, such as the geocoder refusing us (send it again later).
    • EXCHANGE_RATE_NOT_FOUND: a shipment priced by what it cost, in a currency whose rate to EUR could not be had for its transport_date (error_params.field is currency_unit_id).
    The item’s error_params names the first section that failed, as the request’s errors do, and says why: {"field": "sections[1]", "message": "its origin or destination could not be found on a map"}. A shipment whose calculation failed unexpectedly (for example, emissions too large to store) has error_params null. Either way the shipment stays stored, in error: delete it with Delete Transports (v2) before sending it again, or the two will add up.
  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.

What a shipment cost

A record can also say what the whole shipment cost: spend_amount in currency_unit_id. It is optional and, unlike an invoice’s total_spend, which is only kept, it can price the shipment. With it the weight and the sections’ distances become optional too: only each section’s transport_type (and travel_method for road) is still required. The distance keeps the priority, as in business travels. A shipment is priced by its spend only when its distance cannot price it:
  • a section has no distance_km and no origin + destination;
  • the distance of a section cannot be had: a place on no map, or no distance for its transport between its places (0 km between them counts as none);
  • a section has no distance factor for its transport and country;
  • it has no weight and a section that is not road (only road has per-km factors; air, rail and sea are priced per tonne-km). A weightless shipment that is all road, with its distances, is calculated per vehicle-km as with distance_only.
The decision is the shipment’s: when one section cannot be priced by its distance, the whole shipment is priced by its spend. Its sections keep their places. Then its spend in EUR (at the rate of its transport_date) is split equally between its sections, and each section is priced with the EXIOBASE spend factor (kgCO2e per EUR) of its transport in your organization’s country: Its sections have no well-to-tank emissions. A section pinned to a custom_ef_record_id keeps it: one per unit of currency prices its share of the spend, and one per tonne-km or km prices a distance. Such a factor needs one: a shipment sent without what its distance needs (a section without a distance or places, or no weight unless every section is by road) is rejected with UNIT_NOT_ALLOWED_FOR_CUSTOM_EMISSION_FACTOR, and one whose distance cannot be had fails with DISTANCE_CALCULATION_ERROR instead of being priced at 0 km.

Coming from POST /v1/transports

The record is the shipment v1 takes, with these differences:
  • transport_direction is required (v1 assumes downstream when it is missing).
  • A section gives its distance as distance_km, instead of kms_manual with distance_manual: true. A section without it gives origin and destination.
  • transport_date is tomorrow in UTC at the latest, as every v2 activity date (activity dates).
  • travel_method is truck, car or bicycle, and a road section needs it: the other vehicles v1 lists are not among the transport combinations.
  • origin and destination are 1 to 256 characters once trimmed.
  • There is no detail: the distance or weight band of the factor is picked from the section’s distance and the shipment’s weight, as v1 does when detail is left out.
  • There is no organization_id, nor any other field not listed below: the shipments belong to the x-organization-id organization.

Request

Headers

string
required
Your API key (see Authentication).
string
required
The organization the shipments belong to. A record cannot name another organization: send each organization’s shipments with its own x-organization-id. The job and its ingest_job.finished webhook belong to that organization too, so register a webhook endpoint in each organization you send as.
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 creating the shipments 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 shipments to create, 1 to 5,000. A field not listed here is rejected (SCHEMA_INVALID).

Response

202 Accepted with the job (entity_type: transport_routes, operation: create) and a Location header to it. To read the result:

Errors

Problem details. Per-record codes in errors[].error_code of a 422 BULK_RECORDS_REJECTED (each invalid record is listed once, with its first error): 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 Freight Transports (v2)

Delete shipments by id

Transport Combinations

The section transports there are factors for

Get Ingest Job

Follow the calculation

List Job Items

The shipment id and outcome of each record

List Transport Routes

The shipments and their emissions

List Units

The weight units a shipment takes