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

# Emissions API

> Calculate the greenhouse gas emissions of freight transport, and store and retrieve the results.

The Emissions API calculates the greenhouse gas emissions of moving cargo along a [transport chain](https://docs.terratwin.com/content/guides/transport-chains.md) – by road, rail, water, and air, including the logistics hubs between them.
It returns the emissions of each operation and of the whole chain, together with the distances, transport activity, and the defaults TerraTwin used.

New to the Emissions API? Start with the [Emissions API quick start](https://docs.terratwin.com/content/get-started/emissions-api.md).

## Endpoints

| Endpoint | What it does |
| - | - |
| [`POST /emissions/calculate`](https://docs.terratwin.com/api-reference/calculate-transport-emissions) | Calculates the emissions of a transport chain. |
| [`GET /emissions/{id}`](https://docs.terratwin.com/api-reference/get-calculation-result) | Returns a stored calculation result by the `id` you gave it. |
| [`GET /emissions`](https://docs.terratwin.com/api-reference/list-calculation-results) | Lists stored calculation results, newest first, filtered by creation time. |

All endpoints are served from `https://api.terratwin.com/api/v1/transportation` and need your API key in the `x-api-key` header.

## The request

An emissions request describes the shipment:

| Property | Purpose | Guide |
| - | - | - |
| `cargo` | What is moved. `weight` is required; the category, density, and climate control improve the defaults. | [Cargo](https://docs.terratwin.com/content/guides/cargo.md) |
| `origin`, `destination` | Where the shipment starts and finishes. | [Locations](https://docs.terratwin.com/content/guides/locations.md) |
| `transportChain` | The ordered transport operations, and the hubs between them. | [Transport chains](https://docs.terratwin.com/content/guides/transport-chains.md) |
| `options` | How the calculation runs and what the response includes – see below. | |
| `id`, `context` | Your own identifier and data, returned unchanged in the response. | |

Each transport operation is one of [`ROAD`](https://docs.terratwin.com/content/guides/road-transport), [`RAIL`](https://docs.terratwin.com/content/guides/rail-transport), [`WATER`](https://docs.terratwin.com/content/guides/water-transport), [`AIR`](https://docs.terratwin.com/content/guides/air-transport), [`UNKNOWN`](https://docs.terratwin.com/content/guides/unknown-transport), or [`WEIGHTED_MODES`](https://docs.terratwin.com/content/guides/weighted-modes-transport).
[Hubs](https://docs.terratwin.com/content/guides/hubs.md) add the emissions of handling cargo between operations.

### Options

| Option | What it does |
| - | - |
| `storeResult` | Stores the result so it can be retrieved later with `GET /emissions/{id}`. Requires a top-level `id`. |
| `hubInsertion` | Whether TerraTwin inserts hubs between operations automatically (the default) or only uses the hubs you add. |
| `defaultHubTypes` | The hub type inserted for each change of transport mode. |
| `fallbackTransportModes` | The modes tried, in order, for `UNKNOWN` operations and for operations that can't be routed with the requested mode. |
| `includeRoutePolylines` | Adds encoded route polylines to `ROAD`, `RAIL`, and `WATER` results. |

## The response

| Property | What it tells you |
| - | - |
| `totalEmissions` | The emissions of the transport operations and logistics hubs across the whole chain. |
| `transportEmissions`, `hubEmissions` | The emissions of the transport operations and of the hubs, separately. |
| `activityDistanceKm`, `activityTonneKm` | The modelled distance and transport activity. |
| `transportChain` | The realized operations, including any connecting road journeys and hubs TerraTwin added, with the defaults used for each. |
| `creditCost` | The Emissions API credits the calculation consumed. |

## Storing and retrieving results

Set `options.storeResult` to `true` and give the request a unique top-level `id` to keep the result.
You can then fetch it with [`GET /emissions/{id}`](https://docs.terratwin.com/api-reference/get-calculation-result), or browse stored results with [`GET /emissions`](https://docs.terratwin.com/api-reference/list-calculation-results), which pages through them with `created_from`, `created_to`, `limit`, and `cursor`.

## Credits

Emissions API requests are charged to your account's **Emissions API credits**, one credit per transport operation – see [Credits & usage](https://docs.terratwin.com/content/guides/credits.md).
Emissions API credits can be bought on the [TerraTwin website](https://www.terratwin.com/account/credits).

## Related

> [card] [Distance API](https://docs.terratwin.com/content/guides/distance-api.md)
>
> Need only the routes and distances, without emissions? The Distance API takes the same transport chain and routes it the same way.

> [card] [API reference](https://docs.terratwin.com/api-reference/calculate-transport-emissions.md)
>
> Every request field, response object, and error code of the Emissions API.


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