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

# List Hotel Stays

> Retrieve all hotel stays with filtering and pagination support

# List Hotel Stays

Retrieve a paginated list of hotel stay records for your organization, with support for filtering by status, date range, name, and file.

## 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="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 for stays that overlap this start date (inclusive)

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

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

<ParamField query="end_date" type="date">
  Filter for stays that overlap this end date (inclusive)

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

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

<ParamField query="name" type="string">
  Filter by name (partial match, case-insensitive)

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

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

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

<ParamField query="created_at_from" type="datetime">
  Filter by minimum creation time (inclusive)

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

<ParamField query="created_at_to" type="datetime">
  Filter by maximum creation time (inclusive)

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

<ParamField query="sort" type="array[string]">
  Sort order. Prefix with `-` for descending.

  **Available values:** `check_in_date`, `check_out_date`, `name`, `created_at`, `updated_at`

  **Example:** `sort=-check_in_date`
</ParamField>

<ParamField query="page" type="integer" default="1">
  Page number for pagination
</ParamField>

<ParamField query="size" type="integer" default="50">
  Items per page (max 100)
</ParamField>

## Response

<ResponseField name="items" type="array[object]">
  Array of hotel stay objects

  <Expandable title="Hotel Stay Object">
    <ResponseField name="id" type="string">
      Unique identifier (UUID)
    </ResponseField>

    <ResponseField name="organization_id" type="string">
      Organization UUID this stay belongs to
    </ResponseField>

    <ResponseField name="name" type="string | null">
      Free-text description of the stay
    </ResponseField>

    <ResponseField name="check_in_date" type="date">
      Check-in date
    </ResponseField>

    <ResponseField name="check_out_date" type="date">
      Check-out date
    </ResponseField>

    <ResponseField name="country" type="string">
      ISO-3166 alpha-2 country code
    </ResponseField>

    <ResponseField name="address" type="string | null">
      Plain-text hotel address (used for geocoding)
    </ResponseField>

    <ResponseField name="hotel_name" type="string | null">
      Hotel name
    </ResponseField>

    <ResponseField name="rooms" type="integer">
      Number of rooms booked
    </ResponseField>

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

    <ResponseField name="source" type="string | null">
      How the record was created (`manual`, `bulk_upload`, etc.)
    </ResponseField>

    <ResponseField name="co2e" type="number | null">
      Calculated CO2e in kg (sourced from total\_impacts)
    </ResponseField>

    <ResponseField name="file_id" type="string | null">
      UUID of the source bulk-upload file, if any
    </ResponseField>

    <ResponseField name="file_name" type="string | null">
      Name of the source file, if any
    </ResponseField>

    <ResponseField name="created_at" type="datetime">
      Record creation timestamp
    </ResponseField>

    <ResponseField name="updated_at" type="datetime | null">
      Last update timestamp
    </ResponseField>

    <ResponseField name="uploaded_by" type="object | null">
      User who created the record

      <Expandable title="User Object">
        <ResponseField name="id" type="string">UUID</ResponseField>
        <ResponseField name="first_name" type="string | null">First name</ResponseField>
        <ResponseField name="last_name" type="string | null">Last name</ResponseField>
        <ResponseField name="profile_img_url" type="string | null">Profile image URL</ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="location_geocode" type="object | null">
      Geocoded location (populated when address is resolved)

      <Expandable title="Location Geocode Object">
        <ResponseField name="country_code" type="string">ISO country code</ResponseField>
        <ResponseField name="place_id" type="string">Geocoding provider place ID</ResponseField>
        <ResponseField name="address_formatted" type="string">Full formatted address</ResponseField>
        <ResponseField name="latitude" type="number">Latitude coordinate</ResponseField>
        <ResponseField name="longitude" type="number">Longitude coordinate</ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="total" type="integer">
  Total number of records matching the filter
</ResponseField>

<ResponseField name="page" type="integer">
  Current page number
</ResponseField>

<ResponseField name="size" type="integer">
  Items per page
</ResponseField>

<ResponseField name="filter_hash" type="string">
  Hash of the current filter state — use to detect if filters have changed
</ResponseField>

## Example

<CodeGroup>
  ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl -X GET "https://api.dcycle.io/v1/hotel-stays?page=1&size=50&status[]=active&start_date=2024-01-01&end_date=2024-12-31" \
    -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

  headers = {
      "x-api-key": os.getenv("DCYCLE_API_KEY"),
      "x-organization-id": os.getenv("DCYCLE_ORG_ID"),
  }

  params = {
      "page": 1,
      "size": 50,
      "status[]": ["active"],
      "start_date": "2024-01-01",
      "end_date": "2024-12-31"
  }

  response = requests.get(
      "https://api.dcycle.io/v1/hotel-stays",
      headers=headers,
      params=params
  )

  result = response.json()
  for stay in result["items"]:
      nights = (
          (stay["check_out_date"] and stay["check_in_date"])
          and "N/A"  # compute externally if needed
      )
      print(f"{stay['hotel_name']} ({stay['country']}): {stay['rooms']} rooms — {stay['co2e']} kg CO2e")
  ```

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

  const headers = {
    'x-api-key': process.env.DCYCLE_API_KEY,
    'x-organization-id': process.env.DCYCLE_ORG_ID
  };

  axios.get('https://api.dcycle.io/v1/hotel-stays', {
    headers,
    params: {
      page: 1,
      size: 50,
      'status[]': ['active'],
      start_date: '2024-01-01',
      end_date: '2024-12-31'
    }
  })
  .then(response => {
    response.data.items.forEach(stay => {
      console.log(`${stay.hotel_name} (${stay.country}): ${stay.rooms} rooms — ${stay.co2e} kg CO2e`);
    });
  })
  .catch(error => console.error(error));
  ```
</CodeGroup>

### Successful Response

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "items": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "organization_id": "a8315ef3-dd50-43f8-b7ce-d839e68d51fa",
      "name": "Team offsite — Madrid",
      "check_in_date": "2024-11-04",
      "check_out_date": "2024-11-07",
      "country": "ES",
      "address": "Gran Vía 28, Madrid, Spain",
      "hotel_name": "Hotel Gran Vía",
      "rooms": 3,
      "status": "active",
      "source": "manual",
      "co2e": 18.54,
      "file_id": null,
      "file_name": null,
      "created_at": "2024-11-01T09:00:00Z",
      "updated_at": "2024-11-01T09:00:00Z",
      "uploaded_by": {
        "id": "b9f1e2d3-0000-0000-0000-000000000001",
        "first_name": "Ana",
        "last_name": "García",
        "profile_img_url": null
      },
      "location_geocode": {
        "country_code": "ES",
        "place_id": "ChIJgTwKgJcpQg0RaSKMYcHeNsQ",
        "address_formatted": "Gran Vía 28, 28013 Madrid, Spain",
        "latitude": 40.4200,
        "longitude": -3.7025
      }
    }
  ],
  "total": 42,
  "page": 1,
  "size": 50,
  "filter_hash": "d4f9a2..."
}
```

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

### 422 Unprocessable Entity

**Cause:** Invalid query parameters (e.g. malformed date)

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "detail": [
    {
      "loc": ["query", "start_date"],
      "msg": "invalid date format",
      "type": "value_error.date"
    }
  ]
}
```

## Related Endpoints

<CardGroup cols={2}>
  <Card title="Get Hotel Stay" icon="magnifying-glass" href="/api-reference/hotel-stays/get">
    Get a specific stay by ID
  </Card>

  <Card title="Get Totals" icon="chart-bar" href="/api-reference/hotel-stays/totals">
    Get aggregated stats across all stays
  </Card>
</CardGroup>
