> ## 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 Hotel Stay Totals

> Get aggregated totals for all hotel stays: stay count, total room-nights, and total CO2e

# Get Hotel Stay Totals

Returns aggregated statistics for all hotel stays in your organization: total number of stays, total room-nights booked, and total CO2e emitted.

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

## Response

<ResponseField name="total_stays" type="integer">
  Total number of hotel stay records for the organization
</ResponseField>

<ResponseField name="total_nights" type="integer">
  Total room-nights booked (sum of `rooms × nights` across all stays)
</ResponseField>

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

## Example

<CodeGroup>
  ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl -X GET "https://api.dcycle.io/v1/hotel-stays/totals" \
    -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/totals",
      headers={
          "x-api-key": os.getenv("DCYCLE_API_KEY"),
          "x-organization-id": os.getenv("DCYCLE_ORG_ID")
      }
  )
  totals = response.json()
  print(f"{totals['total_stays']} stays, {totals['total_nights']} room-nights, {totals['total_co2e']} kg CO2e")
  ```

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

  axios.get('https://api.dcycle.io/v1/hotel-stays/totals', {
    headers: {
      'x-api-key': process.env.DCYCLE_API_KEY,
      'x-organization-id': process.env.DCYCLE_ORG_ID
    }
  })
  .then(r => {
    const { total_stays, total_nights, total_co2e } = r.data;
    console.log(`${total_stays} stays, ${total_nights} room-nights, ${total_co2e} kg CO2e`);
  })
  .catch(error => console.error(error));
  ```
</CodeGroup>

### Successful Response

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "total_stays": 42,
  "total_nights": 186,
  "total_co2e": 1143.72
}
```

## 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"}
```

## Related Endpoints

<CardGroup cols={2}>
  <Card title="List Hotel Stays" icon="list" href="/api-reference/hotel-stays/list">
    Browse individual stay records
  </Card>

  <Card title="Impact Calculation" icon="calculator" href="/api-reference/hotel-stays/impact-calculation">
    See the step-by-step breakdown for a specific stay
  </Card>
</CardGroup>
