Skip to main content
POST
/
v1
/
invoices
/
bulk-delete
Bulk Delete
const options = {
  method: 'POST',
  headers: {
    'x-api-key': '<x-api-key>',
    'x-organization-id': '<x-organization-id>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({invoice_ids: ['<string>'], facility_id: '<string>', type: '<string>'})
};

fetch('https://api.dcycle.io/v1/invoices/bulk-delete', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
{
  "success_count": 123,
  "success_ids": [
    "<string>"
  ],
  "failed_count": 123,
  "failed_ids": [
    "<string>"
  ],
  "message": "<string>"
}

Bulk Delete

Delete multiple invoices by their IDs. Invoices must belong to the specified facility and match the given type. Related emission records and distributed siblings are automatically cleaned up.

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

invoice_ids
string[]
required
Array of invoice UUIDs to delete (1–100,000)
facility_id
string
required
UUID of the facility the invoices belong to
type
string
required
Invoice type: electricity, heat, water, recharge

Response

success_count
integer
Number of invoices successfully deleted
success_ids
string[]
UUIDs of successfully deleted invoices
failed_count
integer
Number of invoices that failed to delete
failed_ids
string[]
UUIDs of invoices that failed to delete
message
string
Human-readable summary message

Example

curl -X POST "https://api.dcycle.io/v1/invoices/bulk-delete" \
  -H "x-api-key: ${DCYCLE_API_KEY}" \
  -H "x-organization-id: ${DCYCLE_ORG_ID}" \
  -H "Content-Type: application/json" \
  -d '{
    "invoice_ids": ["uuid-1", "uuid-2"],
    "facility_id": "'${FACILITY_ID}'",
    "type": "electricity"
  }'

Successful Response

{
  "success_count": 2,
  "success_ids": ["uuid-1", "uuid-2"],
  "failed_count": 0,
  "failed_ids": [],
  "message": "Successfully deleted 2 invoices"
}

Common Errors

401 Unauthorized

Cause: Missing or invalid API key
{"detail": "Invalid API key for organization", "code": "INVALID_API_KEY"}

403 Forbidden

Cause: The authenticated user is not a member of the organization
{"detail": "Logged User is not Member of Organization", "code": "LOGGED_USER_NOT_MEMBER"}

422 Unprocessable Entity

Cause: Missing required fields or invalid invoice type
{
  "detail": [
    {
      "loc": ["body", "invoice_ids"],
      "msg": "field required",
      "type": "value_error.missing"
    }
  ]
}

Bulk Delete Preview

Preview what will be deleted before confirming

Bulk Delete by Filters

Delete invoices matching filter criteria