> ## Documentation Index
> Fetch the complete documentation index at: https://code.dcycle.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Transport Route

> Create a new transport route with one or more sections. Emissions are calculated asynchronously.

> [!WARNING]
>
> **Deprecated.** Use [`POST /v2/transports`](https://code.dcycle.io/api-reference/transport/create-v2): up to 5,000 shipments per request,
> idempotent, with distances and emissions calculated asynchronously and webhooks. This endpoint keeps working; its
> responses carry `Deprecation` and `Link: </v2/transports>; rel="successor-version"` headers. Its responses also carry
> `Sunset: Fri, 30 Apr 2027 00:00:00 GMT`: the endpoint is retired on **April 30, 2027** (see the
> [changelog](https://code.dcycle.io/api-reference/changelog.md)).

Create a new transport route for your organization. A route consists of one or more sections (legs), each describing a segment of the journey with its own transport mode and distance. Distances are geocoded automatically from origin/destination addresses, or you can override them with `kms_manual`.

After creation the route is in `status: pending`. Emissions are calculated asynchronously — poll [GET /v1/transports/`{id}`](https://code.dcycle.io/api-reference/transport/get) until `status` becomes `active` or `error`.

## Request

### Headers

**x-api-key** `string` *required*

Your API key for authentication

**Example:** `sk_live_1234567890abcdef`

**x-organization-id** `string` *required*

Your organization UUID

**Example:** `a8315ef3-dd50-43f8-b7ce-d839e68d51fa`

**Content-Type** `string` *required*

Must be `application/json`

### Body

**name** `string`

Optional human-readable label for this route (e.g. `"Barcelona → Damascus Q2"`)

**transport\_date** `date` *required*

Date of the transport event (YYYY-MM-DD)

**Example:** `"2024-06-15"`

**quantity\_transported** `decimal`

Amount of cargo transported. Must be greater than 0, up to 999,999,999.99999: 9 integer digits, 5 decimal places.
Required unless a `spend_amount` is sent; with it, send both or neither.

**Example:** `1500.000`

**supplier** `string`

Optional supplier or carrier name

**transport\_direction** `string` *required*

Direction of the transport:

* `downstream` — outbound, goods sent to customers
* `upstream` — inbound, goods received from suppliers

**unit\_id** `UUID`

UUID of the unit of measurement for `quantity_transported`. Required unless a `spend_amount` is sent; with it, send
both or neither. Common values:

| Unit | UUID |
| - | - |
| kilogram (kg) | `61743a63-ff70-459c-9567-5eee8f7dfd5c` |
| metric tonne (t) | `cab66828-c2b1-431b-92af-f9ab37149d3c` |

**spend\_amount** `number`

Optional: what the whole shipment cost, over 0, in `currency_unit_id`. It is calculated as in
[What a shipment cost](https://code.dcycle.io/api-reference/transport/create-v2.md#what-a-shipment-cost): the distance keeps the priority,
and the spend prices the shipment when its distance cannot, including when a section's distance cannot be had
(the request is not refused for it). With it, `quantity_transported`, `unit_id` and the
sections' distances become optional. Send it with `currency_unit_id` and `multidb: true` (`422` otherwise).

**currency\_unit\_id** `UUID`

The currency of `spend_amount`, a unit of `type` `fiat_currency` from [List Units](https://code.dcycle.io/api-reference/units/list.md)
(`422 INVALID_CURRENCY_UNIT` otherwise). Send it with `spend_amount`, and only with it.

**multidb** `boolean`

`true` calculates the shipment with the emission factor databases
[Create Transports (v2)](https://code.dcycle.io/api-reference/transport/create-v2.md) uses; left out or `false`, with the previous
calculation. A `spend_amount` needs `true`.

**sections** `array` *required*

Ordered list of transport legs. At least one section is required. Sections are processed in order and assigned `part` numbers starting from 1.

**section fields**

**sections\[].transport\_type** `string` *required*

Mode of transport for this leg:

* `road` — truck, car, or other road vehicle
* `air` — air freight
* `maritime` — sea freight
* `rail` — train
* `do_not_know` — let Dcycle infer the best mode from the origin/destination pair

**sections\[].travel\_method** `string`

Road sub-type (only relevant when `transport_type` is `road`): `car`, `truck`, `motorbike`, `bicycle`, `electric_kick_scooter`

**sections\[].electric** `boolean` (default: false)

Whether the vehicle is electrically powered. Omit it, or send `false`, when unknown.

**sections\[].refrigerated** `boolean` (default: false)

Whether the cargo requires refrigeration. Omit it, or send `false`, when unknown.

**sections\[].distance\_manual** `boolean` *required*

Whether the distance is manually provided via `kms_manual`. Set to `true` when providing `kms_manual`, or `false` when using origin/destination geocoding.

**sections\[].detail** `string`

Additional detail for emission factor selection. Values use a `property:operator:value` format:

**Distance bands (maritime/air):** `distance:ge:4000`, `distance:ge:1500`, `distance:ge:800`, `distance:lt:800`

**Weight classes (road):** `weight:ge:32000`, `weight:ge:16000`, `weight:ge:7500`, `weight:ge:3500`

Leave unset to use the default factor for the transport type.

**sections\[].origin** `string`

Origin address for this leg (e.g. `"Madrid, Spain"`). Dcycle geocodes this address and computes the distance to the destination automatically. Required if `kms_manual` is not provided.

**sections\[].destination** `string`

Destination address for this leg (e.g. `"Barcelona Port, Spain"`). Required if `kms_manual` is not provided.

**sections\[].origin\_country** `string`

ISO 3166-1 alpha-2 code of the country the origin is in (e.g. `"IT"`), when you know it. Dcycle then geocodes the origin within that country instead of inferring the country from the address text. Not stored.

**sections\[].destination\_country** `string`

ISO 3166-1 alpha-2 code of the country the destination is in, as `origin_country`. Not stored.

**sections\[].kms\_manual** `decimal`

Distance override in kilometers. Use this to bypass geocoding entirely. Must be greater than 0, up to 8 integer digits, 6 decimal places.

**Example:** `4626.00`

## Response

Returns the newly created `TransportRouteSch` object with HTTP status **201 Created**.

> [!NOTE]
>
> Emissions are calculated asynchronously. Immediately after creation, `status` will be `pending` and `co2e` will be `null`. Poll [GET /v1/transports/`{id}`](https://code.dcycle.io/api-reference/transport/get) until `status` is `active` (success) or `error` (calculation failed). Typical calculation time is a few seconds per section.

**id** `string`

Unique identifier (UUID) of the new route

**name** `string | null`

Route name as provided

**transport\_date** `date | null`

Date of transport (YYYY-MM-DD)

**quantity\_transported** `number`

Amount transported

**supplier** `string | null`

Supplier name as provided

**transport\_direction** `string`

`downstream` or `upstream`

**transport\_frequency** `string | null`

Recurrence value set by the system: `once`, `weekly`, `monthly`

**unit** `object`

Resolved unit of measurement

**unit fields**

**unit.id** `string`

UUID of the unit

**unit.name** `string`

Unit name, e.g. `kilogram_(kg)`, `metric_tonne_(t)`

**unit.type** `string`

Unit type, e.g. `solid`, `liquid`

**co2e** `number | null`

Total CO2-equivalent emissions in kg. `null` immediately after creation — available once `status` is `active`.

**emissions** `array`

Route-level emissions summary. Empty until calculation completes.

**status** `string`

`pending` immediately after creation. Transitions to `active` when calculation succeeds, or `error` if it fails.

**file\_id** `string | null`

Always `null` for routes created via this endpoint (only set for bulk-uploaded routes)

**sections** `array`

Created sections with their assigned `part` numbers and initial geocoding state. See [Get Transport Route](https://code.dcycle.io/api-reference/transport/get.md) for the full section schema.

**uploaded\_by** `object | null`

The authenticated user who created this route

**created\_at** `datetime`

ISO 8601 creation timestamp

**updated\_at** `datetime | null`

ISO 8601 last-update timestamp

## Example

```bash cURL (API Key) theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X POST "https://api.dcycle.io/v1/transports" \
  -H "x-api-key: ${DCYCLE_API_KEY}" \
  -H "x-organization-id: ${DCYCLE_ORG_ID}" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Madrid to Syria Shipment",
    "transport_date": "2024-06-15",
    "quantity_transported": 1500.000,
    "supplier": "LogiTrans S.A.",
    "transport_direction": "downstream",
    "unit_id": "61743a63-ff70-459c-9567-5eee8f7dfd5c",
    "sections": [
      {
        "transport_type": "road",
        "travel_method": "truck",
        "electric": false,
        "refrigerated": false,
        "distance_manual": false,
        "origin": "Madrid, Spain",
        "destination": "Barcelona Port, Spain"
      },
      {
        "transport_type": "maritime",
        "electric": false,
        "refrigerated": false,
        "distance_manual": false,
        "detail": "distance:ge:1500",
        "origin": "Barcelona Port, Spain",
        "destination": "Latakia Port, Syria"
      }
    ]
  }'
```

```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
import requests
import os
import time

response = requests.post(
    "https://api.dcycle.io/v1/transports",
    headers={
        "x-api-key": os.getenv("DCYCLE_API_KEY"),
        "x-organization-id": os.getenv("DCYCLE_ORG_ID"),
    },
    json={
        "name": "Madrid to Syria Shipment",
        "transport_date": "2024-06-15",
        "quantity_transported": 1500.000,
        "supplier": "LogiTrans S.A.",
        "transport_direction": "downstream",
        "unit_id": "61743a63-ff70-459c-9567-5eee8f7dfd5c",
        "sections": [
            {
                "transport_type": "road",
                "travel_method": "truck",
                "electric": False,
                "refrigerated": False,
                "distance_manual": False,
                "origin": "Madrid, Spain",
                "destination": "Barcelona Port, Spain",
            },
            {
                "transport_type": "maritime",
                "electric": False,
                "refrigerated": False,
                "distance_manual": False,
                "detail": "distance:ge:1500",
                "origin": "Barcelona Port, Spain",
                "destination": "Latakia Port, Syria",
            },
        ],
    },
)

route = response.json()
route_id = route["id"]
print(f"Created route {route_id} with status: {route['status']}")

# Poll until calculated
while route["status"] == "pending":
    time.sleep(2)
    route = requests.get(
        f"https://api.dcycle.io/v1/transports/{route_id}",
        headers={
            "x-api-key": os.getenv("DCYCLE_API_KEY"),
            "x-organization-id": os.getenv("DCYCLE_ORG_ID"),
        },
    ).json()

print(f"Final status: {route['status']}, CO2e: {route['co2e']} kgCO2e")
```

```javascript JavaScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
const axios = require('axios');

const headers = {
  'x-api-key': process.env.DCYCLE_API_KEY,
  'x-organization-id': process.env.DCYCLE_ORG_ID,
};

async function createAndWait() {
  const { data: route } = await axios.post(
    'https://api.dcycle.io/v1/transports',
    {
      name: 'Madrid to Syria Shipment',
      transport_date: '2024-06-15',
      quantity_transported: 1500.0,
      supplier: 'LogiTrans S.A.',
      transport_direction: 'downstream',
      unit_id: '61743a63-ff70-459c-9567-5eee8f7dfd5c',
      sections: [
        {
          transport_type: 'road',
          travel_method: 'truck',
          electric: false,
          refrigerated: false,
          distance_manual: false,
          origin: 'Madrid, Spain',
          destination: 'Barcelona Port, Spain',
        },
        {
          transport_type: 'maritime',
          electric: false,
          refrigerated: false,
          distance_manual: false,
          detail: 'distance:ge:1500',
          origin: 'Barcelona Port, Spain',
          destination: 'Latakia Port, Syria',
        },
      ],
    },
    { headers },
  );

  console.log(`Created route ${route.id} — status: ${route.status}`);

  // Poll until calculated
  let current = route;
  while (current.status === 'pending') {
    await new Promise(resolve => setTimeout(resolve, 2000));
    const { data } = await axios.get(
      `https://api.dcycle.io/v1/transports/${route.id}`,
      { headers },
    );
    current = data;
  }

  console.log(`Final status: ${current.status}, CO2e: ${current.co2e} kgCO2e`);
}

createAndWait().catch(console.error);
```

### Successful Response (201 Created)

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "id": "010ed3b6-b513-40f3-b9fe-0f0a338d9274",
  "name": "Madrid to Syria Shipment",
  "transport_date": "2024-06-15",
  "quantity_transported": 1500.0,
  "supplier": "LogiTrans S.A.",
  "transport_direction": "downstream",
  "transport_frequency": null,
  "unit": {
    "id": "61743a63-ff70-459c-9567-5eee8f7dfd5c",
    "name": "kilogram_(kg)",
    "type": "solid"
  },
  "co2e": null,
  "emissions": [],
  "status": "pending",
  "file_id": null,
  "file_name": null,
  "sections": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440001",
      "part": 1,
      "transport_type": "road",
      "travel_method": "truck",
      "electric": false,
      "refrigerated": false,
      "detail": null,
      "origin": "Madrid, Spain",
      "destination": "Barcelona Port, Spain",
      "kms": null,
      "kms_manual": null,
      "distance_manual": false,
      "kms_source": null,
      "status": "pending",
      "step": "geocoding",
      "error_messages": null,
      "emissions": null,
      "created_at": "2024-06-10T09:00:00Z",
      "updated_at": "2024-06-10T09:00:00Z"
    },
    {
      "id": "550e8400-e29b-41d4-a716-446655440002",
      "part": 2,
      "transport_type": "maritime",
      "travel_method": null,
      "electric": false,
      "refrigerated": false,
      "detail": "distance:ge:1500",
      "origin": "Barcelona Port, Spain",
      "destination": "Latakia Port, Syria",
      "kms": null,
      "kms_manual": null,
      "distance_manual": false,
      "kms_source": null,
      "status": "pending",
      "step": "geocoding",
      "error_messages": null,
      "emissions": null,
      "created_at": "2024-06-10T09:00:00Z",
      "updated_at": "2024-06-10T09:00:00Z"
    }
  ],
  "uploaded_by": {
    "id": "user-123",
    "first_name": "Maria",
    "last_name": "García",
    "profile_img_url": null
  },
  "created_at": "2024-06-10T09:00:00Z",
  "updated_at": "2024-06-10T09:00:00Z"
}
```

## Common Errors

### 401 Unauthorized

**Cause:** Missing or invalid API key / JWT token

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{"detail": "Invalid API key for organization", "code": "INVALID_API_KEY"}
```

### 403 Forbidden

**Cause:** The authenticated user is not a member of the organization

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{"detail": "Logged User is not Member of Organization", "code": "LOGGED_USER_NOT_MEMBER"}
```

### 404 Not Found

**Cause:** The provided `unit_id` does not exist

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{"detail": "Unit not found", "code": "UNIT_NOT_FOUND"}
```

### 422 Unprocessable Entity

**Cause:** Missing required field or invalid value

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "detail": [
    {
      "loc": ["body", "transport_direction"],
      "msg": "field required",
      "type": "value_error.missing"
    }
  ]
}
```

**Cause:** `sections` array is empty

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "detail": [
    {
      "loc": ["body", "sections"],
      "msg": "ensure this value has at least 1 items",
      "type": "value_error.list.min_items"
    }
  ]
}
```

## Related Endpoints

> [card] [Get Transport Route](https://code.dcycle.io/api-reference/transport/get.md)
>
> Retrieve a single route by ID (use this to poll for calculated emissions)

> [card] [List Transport Routes](https://code.dcycle.io/api-reference/transport/list.md)
>
> Retrieve all transport routes with filtering and pagination

> [card] [Update Transport Route](https://code.dcycle.io/api-reference/transport/update.md)
>
> Modify a transport route and its sections

> [card] [Transport Overview](https://code.dcycle.io/api-reference/transport/overview.md)
>
> Full data model and distance calculation reference


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.