> ## 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 Commuting Period

> Get a single commuting period by ID

# Get Commuting Period

Retrieve a single employee commuting period record by its ID. Returns the full commuting details including transport type, distances, and emission calculation status.

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

### Path Parameters

<ParamField path="employee_historic_id" type="string" required>
  UUID of the commuting period record
</ParamField>

## Response

<ResponseField name="id" type="string">
  Commuting period UUID
</ResponseField>

<ResponseField name="employee_id" type="string">
  UUID of the associated employee
</ResponseField>

<ResponseField name="commuting_type" type="string">
  Type of commuting: `in_itinere` (commute) or `in_labore` (work-from-home)
</ResponseField>

<ResponseField name="transport_type" type="string">
  Transport mode (car, bus, metro, train, bicycle, walking, telecommuting, etc.)
</ResponseField>

<ResponseField name="start_date" type="date">
  Period start date (ISO 8601)
</ResponseField>

<ResponseField name="end_date" type="date">
  Period end date (ISO 8601)
</ResponseField>

<ResponseField name="total_km" type="number | null">
  Distance per trip (km)
</ResponseField>

<ResponseField name="daily_trips" type="integer | null">
  Number of daily trips
</ResponseField>

<ResponseField name="status" type="string">
  Calculation status: `pending`, `active`, or `error`
</ResponseField>

<ResponseField name="co2e" type="number | null">
  Calculated CO2e emissions (tCO2e)
</ResponseField>

## Example

<CodeGroup>
  ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl "https://api.dcycle.io/v1/employee-historic/${COMMUTING_PERIOD_ID}" \
    -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(
      f"https://api.dcycle.io/v1/employee-historic/{os.getenv('COMMUTING_PERIOD_ID')}",
      headers={
          "x-api-key": os.getenv("DCYCLE_API_KEY"),
          "x-organization-id": os.getenv("DCYCLE_ORG_ID"),
      },
  )

  period = response.json()
  print(f"{period['transport_type']}: {period['total_km']} km/trip, {period['co2e']} tCO2e")
  ```

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

  const { data: period } = await axios.get(
    `https://api.dcycle.io/v1/employee-historic/${process.env.COMMUTING_PERIOD_ID}`,
    {
      headers: {
        'x-api-key': process.env.DCYCLE_API_KEY,
        'x-organization-id': process.env.DCYCLE_ORG_ID,
      },
    }
  );

  console.log(`${period.transport_type}: ${period.total_km} km/trip, ${period.co2e} tCO2e`);
  ```
</CodeGroup>

### Successful Response

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "id": "commuting-period-uuid",
  "employee_id": "employee-uuid",
  "commuting_type": "in_itinere",
  "transport_type": "car",
  "start_date": "2025-01-01",
  "end_date": "2025-12-31",
  "total_km": 25.0,
  "daily_trips": 2,
  "status": "active",
  "co2e": 1.85
}
```

## 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:** The commuting period ID does not exist or belongs to a different organization

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{"detail": "Employee historic not found"}
```

## Related Endpoints

<CardGroup cols={2}>
  <Card title="List Commuting Periods" icon="list" href="/api-reference/employees/commuting-periods/list">
    List all commuting periods
  </Card>

  <Card title="Update Commuting Period" icon="pen" href="/api-reference/employees/commuting-periods/update">
    Modify a commuting period
  </Card>
</CardGroup>
