Delete Custom Emission Factor
const options = {
method: 'DELETE',
headers: {
'x-api-key': '<x-api-key>',
'x-organization-id': '<x-organization-id>',
'x-user-id': '<x-user-id>'
}
};
fetch('https://api.dcycle.io/api/v1/custom_emission_factors/{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/custom_emission_factors/{id}"
headers = {
"x-api-key": "<x-api-key>",
"x-organization-id": "<x-organization-id>",
"x-user-id": "<x-user-id>"
}
response = requests.delete(url, headers=headers)
print(response.text)curl --request DELETE \
--url https://api.dcycle.io/api/v1/custom_emission_factors/{id} \
--header 'x-api-key: <x-api-key>' \
--header 'x-organization-id: <x-organization-id>' \
--header 'x-user-id: <x-user-id>'Delete Custom Emission Factor
Remove a custom emission factor permanently
DELETE
/
api
/
v1
/
custom_emission_factors
/
{id}
Delete Custom Emission Factor
const options = {
method: 'DELETE',
headers: {
'x-api-key': '<x-api-key>',
'x-organization-id': '<x-organization-id>',
'x-user-id': '<x-user-id>'
}
};
fetch('https://api.dcycle.io/api/v1/custom_emission_factors/{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/custom_emission_factors/{id}"
headers = {
"x-api-key": "<x-api-key>",
"x-organization-id": "<x-organization-id>",
"x-user-id": "<x-user-id>"
}
response = requests.delete(url, headers=headers)
print(response.text)curl --request DELETE \
--url https://api.dcycle.io/api/v1/custom_emission_factors/{id} \
--header 'x-api-key: <x-api-key>' \
--header 'x-organization-id: <x-organization-id>' \
--header 'x-user-id: <x-user-id>'Delete Custom Emission Factor
Permanently delete a custom emission factor from a Custom Emission Group. This action cannot be undone.Deleting a custom emission factor is permanent. If the factor is currently in use by purchases, wastes, or other records, this may affect historical data calculations. Consider archiving by setting end dates instead of deleting.
Request
Headers
string
required
Your API key for authenticationExample:
sk_live_1234567890abcdefstring
required
Your organization UUIDExample:
ff4adcc7-8172-45fe-9cf1-e90a6de53aa9string
required
Your user UUIDExample:
a1b2c3d4-e5f6-7890-abcd-ef1234567890Path Parameters
string
required
UUID of the Custom Emission Factor to deleteExample:
"factor-uuid-here"Response
Returns HTTP 204 No Content on successful deletion.Example
curl -X DELETE "https://api.dcycle.io/api/v1/custom_emission_factors/factor-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")
}
factor_id = "factor-uuid"
response = requests.delete(
f"https://api.dcycle.io/api/v1/custom_emission_factors/{factor_id}",
headers=headers
)
if response.status_code == 204:
print("✅ Custom emission factor 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 factorId = 'factor-uuid';
axios.delete(
`https://api.dcycle.io/api/v1/custom_emission_factors/${factorId}`,
{ headers }
)
.then(response => {
if (response.status === 204) {
console.log('✅ Custom emission factor deleted successfully');
}
})
.catch(error => console.error(error));
Use Cases
Remove Outdated Factors
Delete factors that are no longer relevant:# Get all factors in a group
factors = requests.get(
f"https://api.dcycle.io/api/v1/custom_emission_factors/list/{group_id}",
headers=headers,
params={"page": 1, "size": 100}
).json()
# Delete outdated factors
from datetime import date
today = date.today()
for factor in factors['items']:
if factor['factor_end_date'] and date.fromisoformat(factor['factor_end_date']) < today:
requests.delete(
f"https://api.dcycle.io/api/v1/custom_emission_factors/{factor['id']}",
headers=headers
)
print(f"Deleted expired factor: {factor['ef_name']}")
Safe Delete with Confirmation
Always fetch and confirm before deleting:async function deleteFactorSafely(factorId) {
// First, get the factor details
const factor = await axios.get(
`https://api.dcycle.io/api/v1/custom_emission_factors/${factorId}`,
{ headers }
).then(res => res.data);
// Show confirmation
console.log(`About to delete: ${factor.ef_name}`);
console.log(`Uploaded by: ${factor.factor_uploaded_by}`);
console.log(`Valid until: ${factor.factor_end_date}`);
// Confirm and delete
const confirmed = true; // Replace with actual user confirmation
if (confirmed) {
await axios.delete(
`https://api.dcycle.io/api/v1/custom_emission_factors/${factorId}`,
{ headers }
);
console.log('✅ Deleted successfully');
}
}
Bulk Delete by Criteria
Delete multiple factors matching certain criteria:# List all factors in a group
response = requests.get(
f"https://api.dcycle.io/api/v1/custom_emission_factors/list/{group_id}",
headers=headers,
params={"page": 1, "size": 100}
)
factors = response.json()['items']
# Delete factors with high uncertainty
for factor in factors:
if factor.get('uncertainty_grade', 0) > 80:
requests.delete(
f"https://api.dcycle.io/api/v1/custom_emission_factors/{factor['id']}",
headers=headers
)
print(f"Deleted high-uncertainty factor: {factor['ef_name']} ({factor['uncertainty_grade']}%)")
Common Errors
404 Not Found
Cause: Custom emission factor not found{
"detail": "Custom emission factor not found",
"code": "NOT_FOUND"
}
403 Forbidden
Cause: Insufficient permissions{
"detail": "Insufficient permissions",
"code": "FORBIDDEN"
}
Best Practices
1. Archive Instead of Delete
For factors with historical usage, consider setting an end date instead of deleting:# Instead of deleting
# requests.delete(...)
# Archive by setting end date to yesterday
from datetime import date, timedelta
yesterday = date.today() - timedelta(days=1)
requests.patch(
f"https://api.dcycle.io/api/v1/custom_emission_factors/{factor_id}",
headers=headers,
json={
"factor_uploaded_by": "system@company.com",
"factor_end_date": yesterday.isoformat(),
"additional_docs": f"{factor['additional_docs']} | Archived {date.today().isoformat()}"
}
)
factor_end_date via PATCH. If you need to archive, you must delete and recreate with the updated date, or simply delete if no longer needed.
2. Audit Before Deleting
Check if factor is in use before deletion:# Get factor details
factor = requests.get(
f"https://api.dcycle.io/api/v1/custom_emission_factors/{factor_id}",
headers=headers
).json()
print(f"Factor: {factor['ef_name']}")
print(f"Created: {factor.get('factor_start_date', 'Unknown')}")
print(f"Uploaded by: {factor['factor_uploaded_by']}")
# Confirm before proceeding
confirm = input("Delete this factor? (yes/no): ")
if confirm.lower() == 'yes':
requests.delete(
f"https://api.dcycle.io/api/v1/custom_emission_factors/{factor_id}",
headers=headers
)
3. Clean Up Empty Groups
After deleting factors, check if the group is empty:# Delete factor
requests.delete(
f"https://api.dcycle.io/api/v1/custom_emission_factors/{factor_id}",
headers=headers
)
# Check if group has remaining factors
remaining = requests.get(
f"https://api.dcycle.io/api/v1/custom_emission_factors/list/{group_id}",
headers=headers,
params={"page": 1, "size": 1}
).json()
if remaining['total'] == 0:
print(f"Group {group_id} is now empty. Consider deleting the group.")
# Optionally delete the group
# requests.delete(f"https://api.dcycle.io/api/v1/custom_emission_groups/{group_id}", headers=headers)
4. Log Deletion Actions
Maintain audit logs of deletions:async function deleteWithAudit(factorId, reason) {
const factor = await axios.get(
`https://api.dcycle.io/api/v1/custom_emission_factors/${factorId}`,
{ headers }
).then(res => res.data);
// Log before deletion
const auditLog = {
action: 'delete_custom_emission_factor',
factor_id: factorId,
factor_name: factor.ef_name,
deleted_by: process.env.DCYCLE_USER_ID,
deleted_at: new Date().toISOString(),
reason: reason
};
console.log('Audit log:', auditLog);
// Save to your audit system
// Delete
await axios.delete(
`https://api.dcycle.io/api/v1/custom_emission_factors/${factorId}`,
{ headers }
);
}
// Usage
deleteWithAudit('factor-uuid', 'Supplier no longer in use');
Related Endpoints
Get Factor
View before deleting
List Factors
View all factors in group
Create Factor
Add new factor
Overview
Learn about custom factors
Was this page helpful?