Create Invoice with PDF Attachment
Use this guide when your system already extracts the invoice data (from an ERP, billing API, EDI feed, or your own OCR pipeline) and you only need to attach the original PDF as a source document for audit purposes. This is different from the OCR-driven file upload flow (POST /v1/files/invoices/presigned-urls), which scans the PDF and uses it to populate the invoice fields. Here, you control all field values and the PDF is treated as read-only evidence.
This guide applies to all invoice types:
electricity, heat, water, recharge, and process.When to Use This Approach
Prerequisites
- An active API key (
x-api-key) - Your organization UUID (
x-organization-id) - The facility UUID(s) where the consumption occurred
- The invoice data already parsed: consumption amount, unit, dates, invoice type
- The PDF file you want to attach
Step 1 — Upload the PDF and Obtain an S3 URL
CallPOST /v1/files/presigned-urls to register the file and receive a presigned S3 upload URL. This endpoint does not trigger OCR or create an invoice skeleton—it simply reserves storage space and returns a URL.
Request
cURL
Response
url field — this is the S3 URL you will pass as file_url when creating the invoice.
Step 2 — Upload the File Bytes to S3
PUT the raw PDF bytes to the presigned_url from Step 1. Use the same Content-Type you declared (application/pdf).
200 response from S3 confirms the file is stored. No further confirmation call is required for this flow.
Step 3 — Create the Invoice
CallPOST /v1/invoices with all invoice fields populated and the url from Step 1 in the file_url field. The PDF is stored as an audit attachment; Dcycle will not re-parse it.
Successful Response
Step 4 — Poll Until Active (Optional)
Invoices start inloading state while the platform calculates CO2e emissions. Poll GET /v1/invoices/{id} until status is no longer loading.
Python
Status Values
Invoice Type Reference
Different invoice types require different fields.file_url is optional but accepted for all types.
Related Endpoints
Create Invoice
Full parameter reference for POST /v1/invoices
Get Invoice
Retrieve full invoice detail including emissions and status
List Invoices
Query and filter your invoice records
Upload Files
General-purpose presigned URL file upload reference