Delete Waste Water Treatment
const options = {
method: 'DELETE',
headers: {'x-api-key': '<x-api-key>', 'x-organization-id': '<x-organization-id>'}
};
fetch('https://api.dcycle.io/api/v1/waste_water_treatments/{waste_water_treatment_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.dcycle.io/api/v1/waste_water_treatments/{waste_water_treatment_id}"
headers = {
"x-api-key": "<x-api-key>",
"x-organization-id": "<x-organization-id>"
}
response = requests.delete(url, headers=headers)
print(response.text)curl --request DELETE \
--url https://api.dcycle.io/api/v1/waste_water_treatments/{waste_water_treatment_id} \
--header 'x-api-key: <x-api-key>' \
--header 'x-organization-id: <x-organization-id>'Delete Waste Water Treatment
Remove a waste water treatment record
DELETE
/
api
/
v1
/
waste_water_treatments
/
{waste_water_treatment_id}
Delete Waste Water Treatment
const options = {
method: 'DELETE',
headers: {'x-api-key': '<x-api-key>', 'x-organization-id': '<x-organization-id>'}
};
fetch('https://api.dcycle.io/api/v1/waste_water_treatments/{waste_water_treatment_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.dcycle.io/api/v1/waste_water_treatments/{waste_water_treatment_id}"
headers = {
"x-api-key": "<x-api-key>",
"x-organization-id": "<x-organization-id>"
}
response = requests.delete(url, headers=headers)
print(response.text)curl --request DELETE \
--url https://api.dcycle.io/api/v1/waste_water_treatments/{waste_water_treatment_id} \
--header 'x-api-key: <x-api-key>' \
--header 'x-organization-id: <x-organization-id>'Legacy API. This page documents the previous version of the API. For new
integrations use Delete Waste Water Treatments (v2) instead:
up to 5,000 measurements per request, with their emissions.
Deleting a waste water treatment record is permanent and will affect your facility’s emission calculations and historical data.
Request
Headers
Optional and ignored: the request acts as the member who created the API keyExample:
a1b2c3d4-e5f6-7890-abcd-ef1234567890Path Parameters
Response
Returns HTTP 204 No Content on successful deletion.Example
curl -X DELETE "https://api.dcycle.io/api/v1/waste_water_treatments/treatment-uuid" \
-H "Authorization: Bearer ${DCYCLE_API_KEY}" \
-H "x-organization-id: ${DCYCLE_ORG_ID}" \
-H "x-user-id: ${DCYCLE_USER_ID}"
import requests
import os
headers = {
"Authorization": f"Bearer {os.getenv('DCYCLE_API_KEY')}",
"x-organization-id": os.getenv("DCYCLE_ORG_ID"),
"x-user-id": os.getenv("DCYCLE_USER_ID")
}
treatment_id = "treatment-uuid"
response = requests.delete(
f"https://api.dcycle.io/api/v1/waste_water_treatments/{treatment_id}",
headers=headers
)
if response.status_code == 204:
print("✅ Waste water treatment record deleted successfully")
else:
print(f"❌ Error: {response.json()}")
const axios = require('axios');
const headers = {
'Authorization': `Bearer ${process.env.DCYCLE_API_KEY}`,
'x-organization-id': process.env.DCYCLE_ORG_ID,
'x-user-id': process.env.DCYCLE_USER_ID
};
const treatmentId = 'treatment-uuid';
axios.delete(
`https://api.dcycle.io/api/v1/waste_water_treatments/${treatmentId}`,
{ headers }
)
.then(response => {
if (response.status === 204) {
console.log('✅ Waste water treatment record deleted successfully');
}
})
.catch(error => console.error(error));
Use Cases
Delete Erroneous Records
Remove incorrectly uploaded records:# Delete a single erroneous record
treatment_id = "treatment-uuid"
response = requests.delete(
f"https://api.dcycle.io/api/v1/waste_water_treatments/{treatment_id}",
headers=headers
)
if response.status_code == 204:
print(f"✅ Deleted treatment record: {treatment_id}")
Bulk Delete by Date Range
Delete multiple records from a specific period:# Find the ids with GET /v1/waste-water-treatments?facility_id=<plant>
treatment_ids_to_delete = [
"treatment-uuid-1",
"treatment-uuid-2",
"treatment-uuid-3"
]
for treatment_id in treatment_ids_to_delete:
response = requests.delete(
f"https://api.dcycle.io/api/v1/waste_water_treatments/{treatment_id}",
headers=headers
)
if response.status_code == 204:
print(f"✅ Deleted: {treatment_id}")
else:
print(f"❌ Failed to delete: {treatment_id}")
Safe Delete with Confirmation
Implement confirmation before deletion:def delete_treatment_with_confirmation(treatment_id):
# In a real application, you'd fetch treatment details first
print(f"⚠️ About to delete treatment: {treatment_id}")
confirmation = input("Are you sure? (yes/no): ")
if confirmation.lower() == 'yes':
response = requests.delete(
f"https://api.dcycle.io/api/v1/waste_water_treatments/{treatment_id}",
headers=headers
)
if response.status_code == 204:
print("✅ Deleted successfully")
return True
else:
print("❌ Deletion cancelled")
return False
# Usage
delete_treatment_with_confirmation("treatment-uuid")
Common Errors
404 Not Found
Cause: Waste water treatment not found{
"detail": "Waste water treatment not found",
"code": "NOT_FOUND"
}
403 Forbidden
Cause: Insufficient permissions{
"detail": "Insufficient permissions",
"code": "FORBIDDEN"
}
Best Practices
1. Confirm Before Deleting
Always confirm deletion, especially for production data:treatment_id = "treatment-uuid"
# Get treatment details first (if you have the data)
print(f"About to delete treatment: {treatment_id}")
# Confirm
confirmed = True # Replace with actual user confirmation
if confirmed:
response = requests.delete(
f"https://api.dcycle.io/api/v1/waste_water_treatments/{treatment_id}",
headers=headers
)
2. Log Deletions
Maintain audit logs of deletions:import logging
from datetime import datetime
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
def delete_treatment_with_audit(treatment_id, reason):
logger.info(f"Deleting treatment {treatment_id}. Reason: {reason}")
response = requests.delete(
f"https://api.dcycle.io/api/v1/waste_water_treatments/{treatment_id}",
headers=headers
)
if response.status_code == 204:
logger.info(f"Successfully deleted treatment {treatment_id} at {datetime.utcnow()}")
return True
else:
logger.error(f"Failed to delete treatment {treatment_id}")
return False
# Usage
delete_treatment_with_audit("treatment-uuid", "Incorrect data uploaded")
3. Re-upload Instead of Edit
Since there’s no UPDATE endpoint, delete and re-upload to correct errors:# Delete incorrect record
requests.delete(
f"https://api.dcycle.io/api/v1/waste_water_treatments/{treatment_id}",
headers=headers
)
# Re-upload with corrected data
corrected_data = {
"facility_id": "facility-uuid",
"daily_waste_water_treatment_data": [
{
"name": "Corrected Daily Treatment 2024-03-01",
"measurement_date": "2024-03-01",
"m3_water_in": 38500, # Corrected value
"m3_water_out": 30500, # Corrected value
# ... all other fields
}
]
}
requests.post(
"https://api.dcycle.io/api/v1/bulk/waste_water_treatments",
headers=headers,
json=corrected_data
)
Related Endpoints
Bulk Upload
Create treatment records
Facilities
List waste water facilities
Was this page helpful?