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

# Hotel Stay Impact Calculation

> Get a step-by-step CO2e breakdown for a specific hotel stay

# Hotel Stay Impact Calculation

Returns the step-by-step emission calculation for a specific hotel stay, showing exactly how the CO2e figure was derived from the DEFRA room-night emission factor.

## 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="hotel_stay_id" type="string" required>
  The unique identifier (UUID) of the hotel stay record

  **Example:** `550e8400-e29b-41d4-a716-446655440000`
</ParamField>

## Response

The response contains the full step-by-step calculation breakdown as used by the Dcycle kernel.

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

<ResponseField name="periods" type="array">
  Calculation periods, one per date range

  <Expandable title="Period object">
    <ResponseField name="start_date" type="date">Period start date</ResponseField>
    <ResponseField name="end_date" type="date">Period end date</ResponseField>
    <ResponseField name="coincidence" type="string">How well the period matches the emission factor (`exact`, `interpolated`)</ResponseField>
    <ResponseField name="co2e" type="number">Total CO2e for this period (kg)</ResponseField>
    <ResponseField name="details" type="array">Breakdown by scope and category, each with step-by-step `co2e` calculation array showing raw value, conversion factor, calculated value, and source</ResponseField>
  </Expandable>
</ResponseField>

### Calculation Methodology

CO2e is computed as:

```
CO2e (kg) = rooms × nights × EF (kg CO2e / room-night)
```

Where:

* **nights** = `check_out_date − check_in_date` in days
* **EF** = DEFRA hotel room-night emission factor for the stay's country (from the `defra_hotel_stays` kernel activity, `HOTEL_STAYS` category)

One `total_impacts` row is written per night so that partial-period exports and dashboards pro-rate correctly.

## Example

<CodeGroup>
  ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl -X GET "https://api.dcycle.io/v1/hotel-stays/550e8400-e29b-41d4-a716-446655440000/impact-calculation" \
    -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/hotel-stays/550e8400-e29b-41d4-a716-446655440000/impact-calculation",
      headers={
          "x-api-key": os.getenv("DCYCLE_API_KEY"),
          "x-organization-id": os.getenv("DCYCLE_ORG_ID")
      }
  )
  print(response.json())
  ```

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

  const hotelStayId = '550e8400-e29b-41d4-a716-446655440000';

  axios.get(`https://api.dcycle.io/v1/hotel-stays/${hotelStayId}/impact-calculation`, {
    headers: {
      'x-api-key': process.env.DCYCLE_API_KEY,
      'x-organization-id': process.env.DCYCLE_ORG_ID,
    },
  }).then(response => {
    console.log(`Total CO2e: ${response.data.total_co2e} kg`);
  });
  ```
</CodeGroup>

### Successful Response

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "total_co2e": 0.312,
  "periods": [
    {
      "start_date": "2025-03-10",
      "end_date": "2025-03-13",
      "coincidence": "exact",
      "co2e_scope_3": 0.312,
      "co2e": 0.312,
      "details": [
        {
          "scope": "scope_3",
          "category": "hotel_stays",
          "co2e": [
            {
              "step": 1,
              "raw_value": { "value": 3, "unit": "room-night" },
              "conversion_factor": { "value": 0.104, "type": "final_conversion" },
              "calculated_value": { "value": 0.312, "unit": "kg CO2e" },
              "source": {
                "source_id": "defra-2025",
                "source_name": "DEFRA",
                "source_version": "2025",
                "source_reference_year": 2025
              },
              "coincidence": "exact"
            }
          ],
          "co2e_from_ch4": [],
          "co2e_from_n2o": [],
          "co2e_from_co2": [],
          "co2_biogenic": []
        }
      ]
    }
  ]
}
```

## 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 hotel stay ID does not exist or belongs to a different organization.

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "detail": "Hotel stay not found",
  "code": "HOTEL_STAY_NOT_FOUND"
}
```

## Related Endpoints

<CardGroup cols={2}>
  <Card title="Get Hotel Stay" icon="magnifying-glass" href="/api-reference/hotel-stays/get">
    Retrieve full stay details
  </Card>

  <Card title="List Hotel Stays" icon="list" href="/api-reference/hotel-stays/list">
    Browse all stays for the organization
  </Card>
</CardGroup>
