Create Invoice
Create Invoice
Register a new consumption invoice in the system
POST
Create Invoice
Create Invoice
Create a new consumption invoice (electricity, heat, water, etc.) for your organization. This endpoint supports both single-facility invoices and distributed invoices (split across multiple facilities with percentage allocation).This endpoint automatically calculates CO2e emissions based on the invoice type, quantity, and location. For distributed invoices, emissions are proportionally allocated across facilities.
Request
Headers
Your API key for authenticationExample:
sk_live_1234567890abcdefYour organization UUIDExample:
ff4adcc7-8172-45fe-9cf1-e90a6de53aa9Body Parameters
Type of consumption invoiceValid values:
electricity, heat, water, recharge, processExample: "electricity"Consumption quantity in the specified unitExample:
15000.5UUID of the unit of measurementCommon units:
- Electricity: kilowatt_hour_(kwh)
- Natural gas: cubic_meter_(m³)
- Water: cubic_meter_(m³)
- Diesel/Gasoline: liter_(l)
"a1b2c3d4-e5f6-7890-abcd-ef1234567890"Invoice period start date (ISO 8601 format)Example:
"2024-11-01"Invoice period end date (ISO 8601 format)Example:
"2024-11-30"UUID of the user creating the invoiceExample:
"b2c3d4e5-f6g7-8901-bcde-fg2345678901"Array of facility allocation objects. Sum of percentages must equal 1.0 (100%)For distributed invoices (multiple facilities):
Facility Percentage Object:
organization_id(string, UUID, required) - Organization that owns the facilityfacility_id(string, UUID, required) - Facility to allocate topercentage(number, required) - Allocation percentage (0.0-1.0)company_name(string, optional) - Company name for referencefacility_name(string, optional) - Facility name for reference
Deprecated: Use
facility_percentages insteadLegacy single facility ID field. Maintained for backwards compatibility.External invoice reference number (e.g., supplier invoice number)Example:
"INV-2024-11-001"UUID of the energy/utility supplierExample:
"f6g7h8i9-j0k1-2345-fghi-jk6789012345"UUID of the facility fuel type (for heat invoices)Required for
type: "heat" invoicesExample: "g7h8i9j0-k1l2-3456-ghij-kl7890123456"CUPS code for Spanish electricity metersFormat: ES + 20 digits + 2 letters (e.g., ES0031406398765432GH0F)Example:
"ES0031406398765432GH0F"URL to the invoice file (PDF, image, etc.) stored in S3Example:
"https://s3.amazonaws.com/dcycle-files/invoices/..."UUID of custom emission factor group (if using custom factors)Example:
"h8i9j0k1-l2m3-4567-hijk-lm8901234567"Transport operation category (for logistics-related invoices)Example:
"van_diesel"Response
UUID of the created invoice
Invoice type
Original consumption quantity
Allocated consumption quantity for this facility (base_quantity × percentage)
Unit of measurement UUID
Original quantity if converted from currency
Original unit ID if converted
Invoice period start date
Invoice period end date
Allocation percentage for primary facility
Invoice status:
"loading" (processing), "active" (completed), "error" (failed)Primary facility UUID
User UUID who created the invoice
Complete distribution across all facilities
Parent invoice UUID for distributed invoices
Supplier UUID if specified
Facility fuel UUID if specified
External invoice reference
CUPS code if specified
Invoice file URL if specified
Custom emission factor UUID if specified
Custom emission factor details if applicable
Transport operation category if specified
Example
Successful Response
Distributed Invoice Response
Common Errors
400 Bad Request - Invalid Total Percentage
Cause: Sum of facility_percentages does not equal 1.0percentage values in facility_percentages equals exactly 1.0 (100%).
400 Bad Request - Invalid Invoice Type
Cause: Unsupported invoice typeheat, electricity, water, recharge, process
400 Bad Request - Invalid Facility
Cause: Facility doesn’t belong to the specified organization or is archived- The facility_id exists and belongs to the organization_id
- The facility is not archived
- You have access to the organization
403 Forbidden
Cause: User doesn’t have permission to create invoices for the specified organizationx-organization-id matches the organizations in facility_percentages and you have proper permissions.
404 Not Found - Organization Not Found
Cause: Organization ID in facility_percentages doesn’t existUse Cases
Single Facility Electricity Invoice
Create an electricity invoice for one facility:Distributed Heat Invoice
Split a shared heating bill across multiple facilities:Corporate Distribution
Headquarters distributing utility bills to subsidiaries:Batch Invoice Creation
Create multiple invoices efficiently:Special Notes
Invoice Status Workflow
Invoices go through the following status workflow:- loading: Initial state after creation. System is calculating emissions.
- active: Processing complete. Emissions calculated and available.
- error: Processing failed. Check
error_messagesfield in GET response.
loading to active within a few seconds.
Distributed Invoices
When creating distributed invoices (multiple facilities):- The system creates one parent invoice + N child invoices (one per facility)
- The parent invoice ID is returned in the response
- All child invoices reference the parent via
source_invoice_id - Emissions are automatically calculated proportionally for each facility
- Percentages must sum to exactly 1.0 (100%)
- Shared utility bills across office floors
- Corporate headquarters allocating costs
- Multi-tenant buildings
- Franchise operations with centralized billing
Date Format
Dates must be provided in ISO 8601 format:YYYY-MM-DD
Valid examples:
"2024-11-01""2024-12-31"
Invoice Types and Required Fields
Different invoice types have different requirements:| Type | Required Fields | Optional Fields |
|---|---|---|
electricity | type, base_quantity, unit_id, dates, facility_percentages | supplier_id, cups, file_url |
heat | type, base_quantity, unit_id, dates, facility_percentages, facility_fuel_id | supplier_id, file_url |
water | type, base_quantity, unit_id, dates, facility_percentages | supplier_id, file_url |
recharge | type, base_quantity, unit_id, dates, facility_percentages | supplier_id, toc |
process | type, base_quantity, unit_id, dates, facility_percentages | custom_emission_factor_id |
Units
Common unit UUIDs for different consumption types:- Electricity: kilowatt_hour_(kwh)
- Natural Gas: cubic_meter_(m³)
- Diesel/Gasoline: liter_(l)
- Water: cubic_meter_(m³)
CUPS Validation
For Spanish electricity invoices, if you provide acups code:
- Format: ES + 20 digits + 2 letters
- Example:
ES0031406398765432GH0F - The system validates format but doesn’t verify existence with utility companies
Emission Calculation
CO2e emissions are calculated automatically based on:- Consumption quantity and unit
- Facility location (country-specific emission factors)
- Time period (emission factors vary by year/month)
- Supplier (if renewable energy contract)
- Custom emission factors (if specified)
- Scope 2 (consumption) emissions
- Scope 3 (generation + T&D) emissions
File Attachments
To attach invoice files (PDF, images):- Upload file to S3 using presigned URL (separate endpoint)
- Include the S3 URL in
file_urlfield - System will retain file for audit trail
Related Endpoints
List Invoices
Query created invoices
List Facilities
Get facility IDs for invoice creation
Bulk Upload Invoices
Upload multiple invoices via CSV
Authentication
Learn about API authentication

