Skip to main content
POST
← Invoices API Delete invoices by id, whatever their category (electricity, fuels, refrigerants, water, district heating or cooling, process), together with their emissions. The request checks every id and answers 202 Accepted with an ingest job that deletes them in the background (see how bulk ingestion works). Follow it with GET /v2/ingest-jobs/{id} or, for a job submitted with an API key, the ingest_job.finished webhook. The ids are the ones a create job gives you (each item’s entity_id in GET /v2/ingest-jobs/{id}/items) or the ids of List Invoices.
Permanent. Deleted invoices and their emissions cannot be recovered. Use dry_run=true first if you are not sure.
Beta. Part of the bulk ingest API, in beta. The contract may still change before general availability.

How it works

  1. The request checks every id. One that does not exist, is not one you can delete (see x-organization-id) or repeats an invoice already in the request rejects the whole request with 422, and nothing is deleted (all or nothing).
  2. An invoice split across facilities goes whole, whichever of its per-facility invoices the id names (they share source_invoice_id).
  3. Invoices imported by Datadis are refused (DATADIS_MANAGED): the next sync would bring them back. Remove the supply point’s Datadis connection in the Dcycle app instead.
  4. The job deletes them in the background with their emissions and calculation data. When every chunk is done the job is completed (or completed_with_errors), and, for a job submitted with an API key, ingest_job.finished is sent with "operation": "delete" to the webhook endpoints of the organization in x-organization-id.

Request

Headers

string
required
Your API key (see Authentication).
string
required
The organization the invoices are deleted for. You can delete the invoices of the facilities of its perimeter (this organization and the ones under it that you can write to) and, beyond it, those of any organization where the API key’s user is an enabled member.
string
required
1 to 255 characters, one per batch, looked up per organization across every v2 bulk route. Within 24 hours, the same key with the same route and body returns the original job (with Idempotent-Replayed: true); the same key with another body or on another route is 422 IDEMPOTENCY_KEY_REUSED, and while the first request is still being processed 409 IDEMPOTENCY_KEY_IN_PROGRESS. After 24 hours the key is free, and a request with it is a new one. See The Idempotency-Key.

Query Parameters

boolean
default:"false"
Check only: the same 422 for bad ids, nothing deleted, no job; 200 with {"dry_run": true, "submitted": n, "valid": n} when every id is valid. The Idempotency-Key header is still required, but a dry run does not check or store it.

Body Parameters

array[uuid]
required
Invoice ids, of any category, 1 to 5,000, each invoice once.

Response

202 Accepted with the job (entity_type: invoices, operation: delete) and a Location header to it. GET /v2/ingest-jobs/{id}/items has one item per invoice, in the order sent; an item is failed with DELETE_FAILED when its invoice was already gone by the time the job reached it. It also ends DELETE_FAILED when it could not be deleted: List Ingest Job Items says what to do.

Errors

Problem details. Per-id codes in errors[].error_code of a 422 BULK_RECORDS_REJECTED (source_row_index is the position in ids): Request-level errors: 401 for a missing or invalid API key, 403 LOGGED_USER_NOT_MEMBER when the key’s user is not a member of the organization, 422 REQUEST_VALIDATION_FAILED for a malformed body (no ids, more than 5,000, no Idempotency-Key), 422 IDEMPOTENCY_KEY_REUSED, 409 IDEMPOTENCY_KEY_IN_PROGRESS, and 429 beyond the rate limits.

Limits

Invoices API

Which route for which consumption

List Invoices

Find the ids to delete

Get Ingest Job

Follow the deletion

List Job Items

The outcome of each id