> ## 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.

# Get Totals

> Get aggregated totals for business travels: record count, total distance, and total CO2e

# Get Totals

Returns aggregated statistics for business travels in your organization: total CO2e emitted, total distance traveled, and record count. Supports the same filters as the [list endpoint](/api-reference/business-travels/list).

## Request

### Headers

<ParamField header="x-api-key" type="string" required>
  Your API key for authentication

  **Example:** `sk_live_1234567890abcdef`
</ParamField>

<ParamField header="x-organization-id" type="string" required>
  Your organization UUID

  **Example:** `a8315ef3-dd50-43f8-b7ce-d839e68d51fa`
</ParamField>

### Query Parameters

<ParamField query="transport_type[]" type="array[string]">
  Filter by transport type

  **Available values:** `car`, `metro`, `train`, `trolleybus`, `bus`, `motorbike`, `aircraft`, `ferry`

  **Example:** `transport_type[]=train&transport_type[]=aircraft`
</ParamField>

<ParamField query="status[]" type="array[string]">
  Filter by status

  **Available values:** `active`, `pending`, `loading`, `completed`, `error`

  **Example:** `status[]=active`
</ParamField>

<ParamField query="start_date" type="date">
  Filter by minimum travel date (inclusive)

  **Format:** `YYYY-MM-DD`

  **Example:** `2024-01-01`
</ParamField>

<ParamField query="end_date" type="date">
  Filter by maximum travel date (inclusive)

  **Format:** `YYYY-MM-DD`

  **Example:** `2024-12-31`
</ParamField>

<ParamField query="name" type="string">
  Search by name (case-insensitive substring match)

  **Example:** `offsite`
</ParamField>

<ParamField query="name[]" type="array[string]">
  Filter by exact name values (multi-select, OR logic)

  **Example:** `name[]=Team offsite&name[]=Client visit`
</ParamField>

<ParamField query="file_id[]" type="array[uuid]">
  Filter by source file UUID. Pass `00000000-0000-0000-0000-000000000000` to filter for records with no associated file.

  **Example:** `file_id[]=3fa85f64-5717-4562-b3fc-2c963f66afa6`
</ParamField>

<ParamField query="created_at_from" type="datetime">
  Filter records created on or after this timestamp (inclusive)

  **Format:** `YYYY-MM-DDTHH:MM:SSZ`
</ParamField>

<ParamField query="created_at_to" type="datetime">
  Filter records created on or before this timestamp (inclusive)

  **Format:** `YYYY-MM-DDTHH:MM:SSZ`
</ParamField>

<ParamField query="co2e_status" type="string">
  Filter by CO2e calculation status

  **Available values:** `calculated`, `not_calculated`
</ParamField>

## Response

<ResponseField name="total_co2e" type="number">
  Total CO2e in kg across all matching business travels
</ResponseField>

<ResponseField name="total_km" type="number">
  Total distance in kilometers
</ResponseField>

<ResponseField name="count" type="integer">
  Number of business travel records matching the filters
</ResponseField>

## Example

<CodeGroup>
  ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl -X GET "https://api.dcycle.io/v1/business-travels/totals?start_date=2024-01-01&end_date=2024-12-31&status[]=active" \
    -H "x-api-key: ${DCYCLE_API_KEY}" \
    -H "x-organization-id: ${DCYCLE_ORG_ID}"
  ```

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

  response = requests.get(
      "https://api.dcycle.io/v1/business-travels/totals",
      headers={
          "x-api-key": os.getenv("DCYCLE_API_KEY"),
          "x-organization-id": os.getenv("DCYCLE_ORG_ID"),
      },
      params={
          "start_date": "2024-01-01",
          "end_date": "2024-12-31",
          "status[]": ["active"],
      },
  )

  totals = response.json()
  print(f"{totals['count']} trips, {totals['total_km']:.0f} km, {totals['total_co2e']:.2f} kg CO2e")
  ```

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

  axios.get('https://api.dcycle.io/v1/business-travels/totals', {
    headers: {
      'x-api-key': process.env.DCYCLE_API_KEY,
      'x-organization-id': process.env.DCYCLE_ORG_ID,
    },
    params: {
      start_date: '2024-01-01',
      end_date: '2024-12-31',
      'status[]': ['active'],
    },
  })
  .then(({ data }) => {
    console.log(`${data.count} trips, ${data.total_km} km, ${data.total_co2e} kg CO2e`);
  })
  .catch(error => console.error(error));
  ```
</CodeGroup>

### Successful Response

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "total_co2e": 14523.87,
  "total_km": 82150.0,
  "count": 127
}
```

## Common Errors

### 401 Unauthorized

**Cause:** Missing or invalid API key

```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:** Organization not found

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{"detail": "Organization with id=UUID('...') not found", "code": "ORGANIZATION_NOT_FOUND"}
```

## Use Cases

### Compare Emissions by Transport Type

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
transport_types = ["car", "train", "aircraft", "bus"]
for t_type in transport_types:
    response = requests.get(
        "https://api.dcycle.io/v1/business-travels/totals",
        headers=headers,
        params={
            "transport_type[]": [t_type],
            "start_date": "2024-01-01",
            "end_date": "2024-12-31",
            "status[]": ["active"],
        },
    )
    totals = response.json()
    print(f"{t_type}: {totals['total_co2e']:.1f} kg CO2e ({totals['count']} trips, {totals['total_km']:.0f} km)")
```

## Related Endpoints

<CardGroup cols={2}>
  <Card title="List Business Travels" icon="list" href="/api-reference/business-travels/list">
    Browse individual travel records
  </Card>

  <Card title="Calculation Steps" icon="calculator" href="/api-reference/business-travels/calculation-steps">
    See the CO2e breakdown for a specific trip
  </Card>
</CardGroup>
