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
string
required
Your API key for authenticationExample:
sk_live_1234567890abcdefstring
required
Your organization UUIDExample:
ff4adcc7-8172-45fe-9cf1-e90a6de53aa9Body Parameters
string
required
Type of consumption invoiceValid values:
electricity, heat, water, recharge, processExample: "electricity"number
required
Consumption quantity in the specified unitExample:
15000.5string
required
UUID 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"string
required
Invoice period start date (ISO 8601 format)Example:
"2024-11-01"string
required
Invoice period end date (ISO 8601 format)Example:
"2024-11-30"string
required
UUID of the user creating the invoiceExample:
"b2c3d4e5-f6g7-8901-bcde-fg2345678901"array
required
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
string
deprecated
Deprecated: Use
facility_percentages insteadLegacy single facility ID field. Maintained for backwards compatibility.string
External invoice reference number (e.g., supplier invoice number)Example:
"INV-2024-11-001"string
UUID of the energy/utility supplierExample:
"f6g7h8i9-j0k1-2345-fghi-jk6789012345"string
UUID of the facility fuel type (for heat invoices)Required for
type: "heat" invoicesExample: "g7h8i9j0-k1l2-3456-ghij-kl7890123456"string
CUPS code for Spanish electricity metersFormat: ES + 20 digits + 2 letters (e.g., ES0031406398765432GH0F)Example:
"ES0031406398765432GH0F"string
URL to the invoice file (PDF, image, etc.) stored in S3Example:
"https://s3.amazonaws.com/dcycle-files/invoices/..."string
UUID of custom emission factor group (if using custom factors)Example:
"h8i9j0k1-l2m3-4567-hijk-lm8901234567"string
Transport operation category (for logistics-related invoices)Example:
"van_diesel"Response
The create endpoint returns a lightweight confirmation with the core invoice fields. Use GET /v1/invoices/ for the full detail view.string
UUID of the created invoice
string
Invoice type:
electricity, heat, water, recharge, or processstring
Invoice status:
loading (processing), active (complete), or error (failed)string | null
UUID of the primary facility
string | null
UUID of the user who created the invoice
string | null
UUID of the energy supplier, if specified
string | null
External invoice reference number
string | null
CUPS code, if specified
boolean | null
Whether the invoice is enabled for emission calculations
boolean | null
Whether this is a self-consumption invoice (electricity only)
Example
Successful Response
Common Errors
401 Unauthorized
Cause: Missing or invalid API key403 Forbidden
Cause: The user is not a member of the organization, or lacks permission to create invoices for it400 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
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: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
Authentication
Learn about API authentication