> ## 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 Waste Water Treatments

> Retrieve a paginated list of waste water treatment records for a facility with filtering and enriched data

# List Waste Water Treatments

Retrieve a paginated list of waste water treatment (WWT) records for a specific facility. Each record includes enriched data: CO2e emissions, linked projects, the user who uploaded it, and facility breakdown information.

## 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="facility_id" type="string" required>
  UUID of the facility to retrieve waste water treatment records for

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

<ParamField query="start_date" type="date">
  Filter records with a start date on or after this date (ISO 8601)

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

<ParamField query="end_date" type="date">
  Filter records with an end date on or before this date (ISO 8601)

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

<ParamField query="status[]" type="array[string]">
  Filter by record status. Can be specified multiple times.

  **Available values:** `uploaded`, `active`, `loading`, `error`

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

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

  **Available values:** `calculated`, `not_calculated`

  **Example:** `co2e_status=calculated`
</ParamField>

<ParamField query="project_id" type="string">
  Filter by project UUID

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

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

  **Example:** `-start_date` (most recent first), `invoice_id`
</ParamField>

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

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

<ParamField query="size" type="integer" default="50">
  Number of items per page (max 100)

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

## Response

<ResponseField name="items" type="array[object]">
  Array of waste water treatment record objects

  <Expandable title="Waste Water Treatment Object">
    <ResponseField name="id" type="string">
      Unique identifier (UUID) for the WWT record. Use this as `waste_water_treatment_id` in [DELETE /api/v1/waste\_water\_treatments/{id}](/api-reference/legacy/waste-water-treatments/delete).
    </ResponseField>

    <ResponseField name="type" type="string">
      Always `"waste_water_treatment"`
    </ResponseField>

    <ResponseField name="status" type="string">
      Processing status: `uploaded`, `active`, `loading`, or `error`
    </ResponseField>

    <ResponseField name="invoice_id" type="string">
      Identification name or invoice number of the WWT record
    </ResponseField>

    <ResponseField name="start_date" type="date">
      Start date of the treatment period
    </ResponseField>

    <ResponseField name="end_date" type="date">
      End date of the treatment period
    </ResponseField>

    <ResponseField name="facility_id" type="string | null">
      UUID of the facility this WWT belongs to
    </ResponseField>

    <ResponseField name="quantity" type="number">
      Volume of water entering treatment, in m³
    </ResponseField>

    <ResponseField name="base_quantity" type="number">
      Volume of water exiting treatment, in m³
    </ResponseField>

    <ResponseField name="m3_water_out" type="number">
      Same as `base_quantity` — water output volume in m³
    </ResponseField>

    <ResponseField name="kg_sludge" type="number">
      Mass of sludge produced, in kg
    </ResponseField>

    <ResponseField name="percentage" type="number">
      Percentage factor (always `1` for WWT records — they are not split across facilities)
    </ResponseField>

    <ResponseField name="co2e" type="number | null">
      CO2 equivalent emissions in kg CO2e. Populated asynchronously after record activation.
    </ResponseField>

    <ResponseField name="co2e_biomass" type="number">
      Biogenic CO2 emissions in kg CO2e
    </ResponseField>

    <ResponseField name="unit" type="object">
      Unit of measurement (always cubic meters for WWT)

      <Expandable title="Unit Object">
        <ResponseField name="id" type="string">
          Unit UUID
        </ResponseField>

        <ResponseField name="name" type="string">
          Unit name (e.g. `"cubic_metre_(m3)_total"`)
        </ResponseField>

        <ResponseField name="type" type="string">
          Unit category (e.g. `"waste_water_treatments_flow_total"`)
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="user" type="object | null">
      User who uploaded or created the record

      <Expandable title="User Object">
        <ResponseField name="id" type="string">User UUID</ResponseField>
        <ResponseField name="first_name" type="string | null">First name</ResponseField>
        <ResponseField name="last_name" type="string | null">Last name</ResponseField>
        <ResponseField name="email" type="string">Email address</ResponseField>
        <ResponseField name="prefix" type="string | null">Phone prefix</ResponseField>
        <ResponseField name="phone_number" type="string | null">Phone number</ResponseField>
        <ResponseField name="onboarding_done" type="boolean">Whether onboarding is complete</ResponseField>
        <ResponseField name="profile_img_url" type="string | null">Profile image URL</ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="uploaded_by" type="string | null">
      UUID of the user who created the record
    </ResponseField>

    <ResponseField name="source_invoice_id" type="string">
      Internal source record UUID (matches `id` for WWT records)
    </ResponseField>

    <ResponseField name="file_url" type="string | null">
      Download URL for any linked import file
    </ResponseField>

    <ResponseField name="linked_projects" type="array[object]">
      Projects this WWT record is linked to
    </ResponseField>

    <ResponseField name="facility_percentages" type="array[object]">
      Facility distribution breakdown (always empty for WWT records)
    </ResponseField>

    <ResponseField name="created_at" type="datetime">
      Timestamp when the record was created
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="total" type="integer">
  Total active and uploaded WWT records in the facility (facility-wide counter, independent of filters)
</ResponseField>

<ResponseField name="total2" type="integer">
  Number of WWT records currently being processed (`loading` status) in the facility
</ResponseField>

<ResponseField name="total_general" type="integer">
  Total records matching the current filters — use this for pagination calculations
</ResponseField>

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

<ResponseField name="size" type="integer">
  Number of items per page
</ResponseField>

## Example

<CodeGroup>
  ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl -X GET "https://api.dcycle.io/v1/waste-water-treatments?facility_id=660e8400-e29b-41d4-a716-446655440000&start_date=2025-01-01&end_date=2025-12-31&page=1&size=50" \
    -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 = {
      "facility_id": "660e8400-e29b-41d4-a716-446655440000",
      "start_date": "2025-01-01",
      "end_date": "2025-12-31",
      "page": 1,
      "size": 50,
  }

  response = requests.get(
      "https://api.dcycle.io/v1/waste-water-treatments",
      headers=headers,
      params=params,
  )

  result = response.json()
  for wwt in result["items"]:
      print(f"{wwt['invoice_id']}: {wwt['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,
  };

  const params = {
    facility_id: '660e8400-e29b-41d4-a716-446655440000',
    start_date: '2025-01-01',
    end_date: '2025-12-31',
    page: 1,
    size: 50,
  };

  axios.get('https://api.dcycle.io/v1/waste-water-treatments', { headers, params })
    .then(response => {
      response.data.items.forEach(wwt => {
        console.log(`${wwt.invoice_id}: ${wwt.co2e} kg CO2e`);
      });
    });
  ```
</CodeGroup>

### Successful Response

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "items": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "type": "waste_water_treatment",
      "status": "active",
      "invoice_id": "WWT-2025-001",
      "start_date": "2025-01-01",
      "end_date": "2025-01-31",
      "facility_id": "660e8400-e29b-41d4-a716-446655440000",
      "quantity": 12500.0,
      "base_quantity": 12000.0,
      "m3_water_out": 12000.0,
      "kg_sludge": 850.0,
      "percentage": 1,
      "co2e": 4521.3,
      "co2e_biomass": 0.0,
      "unit": {
        "id": "987190d0-8ed9-4234-bceb-ab683761a7fe",
        "name": "cubic_metre_(m3)_total",
        "type": "waste_water_treatments_flow_total"
      },
      "user": {
        "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
        "first_name": "Ana",
        "last_name": "García",
        "email": "ana.garcia@company.com",
        "prefix": null,
        "phone_number": null,
        "onboarding_done": true,
        "profile_img_url": null
      },
      "uploaded_by": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "source_invoice_id": "550e8400-e29b-41d4-a716-446655440000",
      "file_url": null,
      "linked_projects": [],
      "facility_percentages": [],
      "created_at": "2025-02-01T10:30:00Z"
    }
  ],
  "total": 47,
  "total2": 0,
  "total_general": 12,
  "page": 1,
  "size": 50
}
```

## Common Errors

### 401 Unauthorized

**Cause:** Missing or invalid API key

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "detail": "Invalid API key",
  "code": "INVALID_API_KEY"
}
```

**Solution:** Verify your API key is valid and active.

### 403 Forbidden

**Cause:** The facility does not belong to your organization

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "detail": "Facility doesn't belong to organization",
  "code": "FACILITY_NOT_BELONG_TO_ORGANIZATION"
}
```

**Solution:** Verify the `facility_id` belongs to your organization.

### 422 Validation Error

**Cause:** Missing required `facility_id` or invalid query parameter values

**Solution:** Ensure `facility_id` is provided and all filter values are valid.

## Related Endpoints

<CardGroup cols={2}>
  <Card title="Bulk Upload Waste Water Treatments" icon="upload" href="/api-reference/legacy/waste-water-treatments/bulk-upload">
    Create multiple WWT records at once
  </Card>

  <Card title="Delete Waste Water Treatment" icon="trash" href="/api-reference/legacy/waste-water-treatments/delete">
    Delete a single WWT record by ID
  </Card>
</CardGroup>
