Skip to main content
POST
/
v1
/
wastes
Create Waste
const options = {
  method: 'POST',
  headers: {
    'x-api-key': '<x-api-key>',
    'x-organization-id': '<x-organization-id>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    facility_id: '<string>',
    identification_name: '<string>',
    start_date: '<string>',
    end_date: '<string>',
    base_quantity: 123,
    description: '<string>',
    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', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
{
  "id": "<string>",
  "identification_name": "<string>",
  "description": "<string>",
  "start_date": "<string>",
  "end_date": "<string>",
  "base_quantity": 123,
  "quantity": 123,
  "status": "<string>",
  "co2e": 123,
  "co2e_biomass": 123,
  "created_at": {}
}

Create Waste

Create a new waste disposal record linked to a specific facility. The waste record will be processed for CO2e emissions calculation based on the emission factor and quantity provided.
CO2e Calculation: After creation, emissions are automatically calculated using the specified emission factor or custom emission factor. The co2e field will be updated asynchronously.

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

facility_id
uuid
required
UUID of the facility this waste belongs toExample: "660e8400-e29b-41d4-a716-446655440000"
identification_name
string
required
Waste identification name or invoice numberExample: "RSU-2024-001"
start_date
date
required
Start date of the waste period (ISO 8601 format)Example: "2024-01-01"
end_date
date
required
End date of the waste period (ISO 8601 format)Example: "2024-03-31"
base_quantity
number
required
Waste quantity in the specified unit. Must be greater than 0.Example: 1500.0
description
string
Description of the wasteExample: "Municipal solid waste from office building"
destination
string
Waste destination or treatment facility nameExample: "Waste treatment plant Madrid"
total_km_to_waste_center
number
Distance to waste treatment center in kilometersExample: 25.0
unit_id
uuid
UUID of the quantity unit. Defaults to kilograms if not specified.Example: "61743a63-ff70-459c-9567-5eee8f7dfd5c"
waste_efs_id
uuid
UUID of the waste emission factor (based on LER/RD code combination)Example: "770e8400-e29b-41d4-a716-446655440000"
custom_emission_factor_id
uuid
UUID of a custom emission factor. For organizations with custom emission data.Example: "880e8400-e29b-41d4-a716-446655440000"

Response

id
string
Unique identifier (UUID) for the waste record
identification_name
string
Waste identification name
description
string
Description of the waste
start_date
date
Start date of the waste period
end_date
date
End date of the waste period
base_quantity
number
Original waste quantity
quantity
number
Calculated quantity (base_quantity * percentage)
status
string
Current status: uploaded, active, loading, or error
co2e
number
CO2 equivalent emissions in kg CO2e (calculated asynchronously)
co2e_biomass
number
Biogenic CO2 emissions in kg CO2e
created_at
datetime
Timestamp when the record was created

Example

curl -X POST "https://api.dcycle.io/v1/wastes" \
  -H "x-api-key: ${DCYCLE_API_KEY}" \
  -H "x-organization-id: ${DCYCLE_ORG_ID}" \
  -H "Content-Type: application/json" \
  -d '{
    "facility_id": "660e8400-e29b-41d4-a716-446655440000",
    "identification_name": "RSU-2024-001",
    "start_date": "2024-01-01",
    "end_date": "2024-03-31",
    "base_quantity": 1500.0,
    "description": "Municipal solid waste",
    "destination": "Waste treatment plant Madrid",
    "total_km_to_waste_center": 25.0,
    "waste_efs_id": "770e8400-e29b-41d4-a716-446655440000"
  }'

Successful Response

{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "identification_name": "RSU-2024-001",
  "description": "Municipal solid waste",
  "start_date": "2024-01-01",
  "end_date": "2024-03-31",
  "base_quantity": 1500.0,
  "quantity": 1500.0,
  "percentage": 1.0,
  "destination": "Waste treatment plant Madrid",
  "total_km_to_waste_center": 25.0,
  "status": "uploaded",
  "co2e": 0.0,
  "co2e_biomass": 0.0,
  "enabled": true,
  "created_at": "2024-11-24T10:30:00Z",
  "updated_at": "2024-11-24T10:30:00Z"
}

Common Errors

401 Unauthorized

Cause: Missing or invalid API key
{
  "detail": "Invalid API key",
  "code": "INVALID_API_KEY"
}
Solution: Verify your API key is valid and active.

403 Forbidden

Cause: Facility doesn’t belong to your organization
{
  "detail": "Facility doesn't belong to organization",
  "code": "FACILITY_NOT_BELONG_TO_ORGANIZATION"
}
Solution: Verify that the facility_id belongs to your organization. Use the Facilities API to list available facilities.

422 Validation Error

Cause: Missing required fields or invalid values
{
  "detail": [
    {
      "loc": ["body", "base_quantity"],
      "msg": "ensure this value is greater than 0",
      "type": "value_error.number.not_gt"
    }
  ]
}
Solution: Check that all required fields are provided and values are valid.

List Wastes

Retrieve all waste records with filtering

Update Waste

Modify an existing waste record

Facilities

List facilities for your organization