Skip to main content
PATCH
/
v1
/
wastes
/
{waste_id}
Update Waste
const options = {
  method: 'PATCH',
  headers: {
    'x-api-key': '<x-api-key>',
    'x-organization-id': '<x-organization-id>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    identification_name: '<string>',
    description: '<string>',
    start_date: '<string>',
    end_date: '<string>',
    base_quantity: 123,
    destination: '<string>',
    total_km_to_waste_center: 123,
    unit_id: '<string>',
    waste_efs_id: '<string>',
    custom_emission_factor_id: '<string>'
  })
};

fetch('https://api.dcycle.io/v1/wastes/{waste_id}', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
{
  "id": "<string>",
  "identification_name": "<string>",
  "base_quantity": 123,
  "status": "<string>",
  "co2e": 123,
  "co2e_biomass": 123,
  "updated_at": {}
}

Update Waste

Update specific fields of an existing waste record. All fields are optional - only include fields you want to modify. Omitted fields will retain their current values.
CO2e Recalculation: When you update fields like base_quantity, waste_efs_id, or unit_id, CO2e emissions are automatically recalculated.

Request

Path Parameters

waste_id
uuid
required
The UUID of the waste record to updateExample: 550e8400-e29b-41d4-a716-446655440000

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

All parameters are optional. Only include fields you want to update.
identification_name
string
Waste identification name or invoice numberExample: "RSU-2024-001-Updated"
description
string
Description of the wasteExample: "Updated description"
start_date
date
Start date of the waste periodExample: "2024-01-01"
end_date
date
End date of the waste periodExample: "2024-06-30"
base_quantity
number
Waste quantity in the specified unit. Must be greater than 0.Example: 2000.0
destination
string
Waste destination or treatment facilityExample: "New waste treatment plant"
total_km_to_waste_center
number
Distance to waste treatment center in kilometersExample: 30.0
unit_id
uuid
UUID of the quantity unitExample: "61743a63-ff70-459c-9567-5eee8f7dfd5c"
waste_efs_id
uuid
UUID of the waste emission factorExample: "770e8400-e29b-41d4-a716-446655440000"
custom_emission_factor_id
uuid
UUID of a custom emission factorExample: "880e8400-e29b-41d4-a716-446655440000"

Response

id
string
Unique identifier (UUID) for the waste record
identification_name
string
Waste identification name
base_quantity
number
Updated waste quantity
status
string
Current status: uploaded, active, loading, or error
co2e
number
Updated CO2 equivalent emissions in kg CO2e
co2e_biomass
number
Biogenic CO2 emissions in kg CO2e
updated_at
datetime
Timestamp when the record was last updated

Example

curl -X PATCH "https://api.dcycle.io/v1/wastes/550e8400-e29b-41d4-a716-446655440000" \
  -H "x-api-key: ${DCYCLE_API_KEY}" \
  -H "x-organization-id: ${DCYCLE_ORG_ID}" \
  -H "Content-Type: application/json" \
  -d '{
    "base_quantity": 2000.0,
    "description": "Updated municipal solid waste",
    "destination": "New waste treatment plant"
  }'

Successful Response

{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "identification_name": "RSU-2024-001",
  "description": "Updated municipal solid waste",
  "start_date": "2024-01-01",
  "end_date": "2024-03-31",
  "base_quantity": 2000.0,
  "quantity": 2000.0,
  "percentage": 1.0,
  "destination": "New waste treatment plant",
  "total_km_to_waste_center": 25.0,
  "status": "active",
  "co2e": 601.0,
  "co2e_biomass": 16.4,
  "enabled": true,
  "created_at": "2024-11-24T10:30:00Z",
  "updated_at": "2024-11-24T15:45:00Z"
}

Common Errors

404 Not Found

Cause: Waste record not found in organization
{
  "detail": "Waste with id=UUID('...') not found",
  "code": "WASTE_NOT_FOUND"
}
Solution: Verify the waste ID is correct and belongs to your organization.

403 Forbidden

Cause: Waste doesn’t belong to your organization
{
  "detail": "Waste doesn't belong to organization",
  "code": "FORBIDDEN"
}
Solution: Verify the x-organization-id header matches the organization that owns this waste record.

422 Validation Error

Cause: Invalid values
{
  "detail": [
    {
      "loc": ["body", "base_quantity"],
      "msg": "ensure this value is greater than 0",
      "type": "value_error.number.not_gt"
    }
  ]
}
Solution: Ensure numeric values are valid and within allowed ranges.

List Wastes

Retrieve all waste records

Create Waste

Add a new waste record

Facilities

List facilities for your organization