Skip to main content
GET
/
v1
/
invoices
/
totals
Totals
const options = {
  method: 'GET',
  headers: {'x-api-key': '<x-api-key>', 'x-organization-id': '<x-organization-id>'}
};

fetch('https://api.dcycle.io/v1/invoices/totals', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
{
  "total_quantity": 123,
  "total_spend": {},
  "total_co2e": 123,
  "total_co2e_consumption": {},
  "total_co2e_generation": {},
  "total_co2e_tnd": {},
  "count": 123,
  "quantity_by_unit": {}
}

Totals

Returns aggregated totals for invoices in a facility: total quantity, total spend, total CO2e broken down by scope (consumption, generation, T&D), and record count. Supports the same filters as the list endpoint.

Request

Headers

x-api-key
string
required
Your API key for authenticationExample: sk_live_1234567890abcdef
x-organization-id
string
required
Your organization UUIDExample: a8315ef3-dd50-43f8-b7ce-d839e68d51fa

Query Parameters

This endpoint accepts the same filters as List Invoices.
facility_id
uuid
required
UUID of the facility to scope invoices toExample: ?facility_id=660e8400-e29b-41d4-a716-446655440000
filters
string
required
Invoice type to retrieveAllowed values: heat, electricity, water, recharge, processExample: ?filters=electricity
start_date
date
Filter invoices starting on or after this date (YYYY-MM-DD)
end_date
date
Filter invoices ending on or before this date (YYYY-MM-DD)
status[]
string[]
Filter by invoice statusAllowed values: uploaded, loading, active, inactive, review, error
co2e_status
string
Filter by CO2e calculation statusAllowed values: calculated, not_calculated
invoice_id
string
Partial, case-insensitive match against the invoice numberExample: ?invoice_id=INV-2024
cups[]
string[]
Filter by one or more CUPS codes
supplier_id[]
UUID[]
Filter by one or more supplier IDs
facility_fuel_id[]
UUID[]
Filter by one or more facility fuel IDs
uploaded_by[]
UUID[]
Filter by the IDs of users who uploaded the invoice
source[]
string[]
Filter by invoice creation sourceKnown values: manual, pdf, bulk_file, datadis
created_at_start
date
Filter invoices uploaded on or after this date (YYYY-MM-DD)
created_at_end
date
Filter invoices uploaded on or before this date (YYYY-MM-DD)
stationary_fuel_id[]
UUID[]
Filter by stationary fuel IDs (natural gas, diesel, biomass). Relevant for heat invoices.
refrigerant_fuel_id[]
UUID[]
Filter by refrigerant fuel IDs. Relevant for recharge invoices.
supply_contract_id[]
UUID[]
Filter by one or more supply contract IDs
self_consumption[]
string[]
Filter by self-consumption flagAllowed values: true, false
project_id
uuid
Filter by project UUID

Response

total_quantity
number
Sum of quantities across all matching invoices
total_spend
number | null
Sum of monetary amounts (EUR)
total_co2e
number
Total CO2e (tCO2e)
total_co2e_consumption
number | null
CO2e from energy consumption (Scope 2 — market/location based)
total_co2e_generation
number | null
CO2e from on-site generation (Scope 1)
total_co2e_tnd
number | null
CO2e from transmission and distribution losses (Scope 3)
count
integer
Number of matching invoices
quantity_by_unit
array[object]
Quantities broken down by unit:
FieldTypeDescription
unit_namestringUnit of measure (e.g. kWh, m³)
total_quantitynumberSum for this unit
countintegerNumber of invoices with this unit

Example

curl -X GET "https://api.dcycle.io/v1/invoices/totals?facility_id=${FACILITY_ID}&filters=electricity&start_date=2025-01-01&end_date=2025-12-31" \
  -H "x-api-key: ${DCYCLE_API_KEY}" \
  -H "x-organization-id: ${DCYCLE_ORG_ID}"

Successful Response

{
  "total_quantity": 245000.0,
  "total_spend": 48500.75,
  "total_co2e": 82.45,
  "total_co2e_consumption": 72.30,
  "total_co2e_generation": null,
  "total_co2e_tnd": 10.15,
  "count": 12,
  "quantity_by_unit": [
    {"unit_name": "kWh", "total_quantity": 245000.0, "count": 12}
  ]
}

Common Errors

401 Unauthorized

Cause: Missing or invalid API key
{"detail": "Invalid API key for organization", "code": "INVALID_API_KEY"}

403 Forbidden

Cause: The authenticated user is not a member of the organization
{"detail": "Logged User is not Member of Organization", "code": "LOGGED_USER_NOT_MEMBER"}

422 Unprocessable Entity

Cause: Missing required query parameters (facility_id or type)
{
  "detail": [
    {
      "loc": ["query", "facility_id"],
      "msg": "field required",
      "type": "value_error.missing"
    }
  ]
}

List Invoices

Browse invoices with filters

Calculation Steps

View the CO2e conversion breakdown