Skip to main content
POST
/
v1
/
facilities
/
waste_water
Create Waste Water Facility
const options = {
  method: 'POST',
  headers: {
    'x-api-key': '<x-api-key>',
    'x-organization-id': '<x-organization-id>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    name: '<string>',
    type: '<string>',
    country: '<string>',
    address: '<string>',
    wwt_line_id: '<string>',
    sludge_line_id: '<string>',
    wwd_line_id: '<string>',
    methane_burned: true,
    categories: {},
    status: '<string>'
  })
};

fetch('https://api.dcycle.io/v1/facilities/waste_water', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
{
  "id": "<string>",
  "name": "<string>",
  "type": "<string>",
  "country": "<string>",
  "address": {},
  "facility_purpose_type": "<string>",
  "wwt_line_id": "<string>",
  "sludge_line_id": "<string>",
  "wwd_line_id": "<string>",
  "methane_burned": {},
  "created_at": {}
}

Create Waste Water Facility

Create a new waste water treatment (WWT) facility in your organization. Unlike standard facilities, WWT facilities require configuration of three treatment lines:
  • WWT line — waste water treatment process
  • Sludge line — sludge treatment process
  • WWD line — waste water discharge process
Each line determines the CH4 and N2O emission factors used when calculating the facility’s GHG emissions.

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

Body Parameters

name
string
required
Name of the facilityExample: "Barcelona WWTP"
type
string
required
Facility typeExample: "waste_water"
country
string
ISO 3166-1 country codeExample: "ES"
address
string
Physical address of the facilityExample: "Passeig de la Zona Franca 101, Barcelona"
wwt_line_id
string
required
UUID of the waste water treatment line configuration
sludge_line_id
string
required
UUID of the sludge treatment line configuration
wwd_line_id
string
required
UUID of the waste water discharge line configuration
methane_burned
boolean
Whether methane from the treatment process is captured and burned (flared). If true, CH4 emissions are reduced.
categories
array[string]
Consumption categories enabled for this facilityExample: ["water"]
status
string
Facility statusAvailable values: active, archived

Response (201 Created)

id
string
UUID of the created facility
name
string
Facility name
type
string
Facility type
country
string
Country code
address
string | null
Facility address
facility_purpose_type
string
Always "waste_water" for WWT facilities
wwt_line_id
string
UUID of the waste water treatment line
sludge_line_id
string
UUID of the sludge treatment line
wwd_line_id
string
UUID of the waste water discharge line
methane_burned
boolean | null
Whether methane is captured and burned
created_at
datetime
Creation timestamp

Example

curl -X POST "https://api.dcycle.io/v1/facilities/waste_water" \
  -H "x-api-key: ${DCYCLE_API_KEY}" \
  -H "x-organization-id: ${DCYCLE_ORG_ID}" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Barcelona WWTP",
    "type": "waste_water",
    "country": "ES",
    "address": "Passeig de la Zona Franca 101, Barcelona",
    "wwt_line_id": "wwt-line-uuid",
    "sludge_line_id": "sludge-line-uuid",
    "wwd_line_id": "wwd-line-uuid",
    "methane_burned": true,
    "categories": ["water"]
  }'

Successful Response (201)

{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "Barcelona WWTP",
  "type": "waste_water",
  "country": "ES",
  "address": "Passeig de la Zona Franca 101, Barcelona",
  "status": "active",
  "facility_purpose_type": "waste_water",
  "wwt_line_id": "wwt-line-uuid",
  "sludge_line_id": "sludge-line-uuid",
  "wwd_line_id": "wwd-line-uuid",
  "methane_burned": true,
  "co2e": null,
  "co2e_biomass": null,
  "created_at": "2024-11-24T10:30:00Z"
}

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 fields or invalid treatment line UUIDs
{
  "detail": [
    {
      "loc": ["body", "wwt_line_id"],
      "msg": "field required",
      "type": "value_error.missing"
    }
  ]
}

Create Facility

Create a standard facility

List Facilities

Retrieve all facilities

Waste Water Treatments

List waste water treatment records