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));
import requests

url = "https://api.dcycle.io/v1/facilities/waste_water"

payload = {
    "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>"
}
headers = {
    "x-api-key": "<x-api-key>",
    "x-organization-id": "<x-organization-id>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
curl --request POST \
  --url https://api.dcycle.io/v1/facilities/waste_water \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <x-api-key>' \
  --header 'x-organization-id: <x-organization-id>' \
  --data '
{
  "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>"
}
'
{
  "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"]
  }'
import requests
import os

response = requests.post(
    "https://api.dcycle.io/v1/facilities/waste_water",
    headers={
        "x-api-key": os.getenv("DCYCLE_API_KEY"),
        "x-organization-id": os.getenv("DCYCLE_ORG_ID"),
        "Content-Type": "application/json",
    },
    json={
        "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"],
    },
)

facility = response.json()
print(f"Created WWT facility: {facility['id']}{facility['name']}")
const axios = require('axios');

const { data: facility } = await axios.post(
  'https://api.dcycle.io/v1/facilities/waste_water',
  {
    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'],
  },
  {
    headers: {
      'x-api-key': process.env.DCYCLE_API_KEY,
      'x-organization-id': process.env.DCYCLE_ORG_ID,
      'Content-Type': 'application/json',
    },
  }
);

console.log(`Created: ${facility.id} — ${facility.name}`);

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