Bulk Update
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>'],
update: {
unit_id: '<string>',
currency_unit_id: '<string>',
supplier_id: '<string>',
cups: '<string>'
}
})
};
fetch('https://api.dcycle.io/v1/invoices/bulk-update', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.dcycle.io/v1/invoices/bulk-update"
payload = {
"invoice_ids": ["<string>"],
"update": {
"unit_id": "<string>",
"currency_unit_id": "<string>",
"supplier_id": "<string>",
"cups": "<string>"
}
}
headers = {
"x-api-key": "<x-api-key>",
"x-organization-id": "<x-organization-id>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)curl --request POST \
--url https://api.dcycle.io/v1/invoices/bulk-update \
--header 'Content-Type: application/json' \
--header 'x-api-key: <x-api-key>' \
--header 'x-organization-id: <x-organization-id>' \
--data '
{
"invoice_ids": [
"<string>"
],
"update": {
"unit_id": "<string>",
"currency_unit_id": "<string>",
"supplier_id": "<string>",
"cups": "<string>"
}
}
'{
"success_count": 123,
"success_ids": [
"<string>"
],
"failed_count": 123,
"failed_ids": [
"<string>"
],
"message": "<string>"
}Bulk Update
Apply the same field changes to multiple invoices by ID
POST
/
v1
/
invoices
/
bulk-update
Bulk Update
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>'],
update: {
unit_id: '<string>',
currency_unit_id: '<string>',
supplier_id: '<string>',
cups: '<string>'
}
})
};
fetch('https://api.dcycle.io/v1/invoices/bulk-update', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.dcycle.io/v1/invoices/bulk-update"
payload = {
"invoice_ids": ["<string>"],
"update": {
"unit_id": "<string>",
"currency_unit_id": "<string>",
"supplier_id": "<string>",
"cups": "<string>"
}
}
headers = {
"x-api-key": "<x-api-key>",
"x-organization-id": "<x-organization-id>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)curl --request POST \
--url https://api.dcycle.io/v1/invoices/bulk-update \
--header 'Content-Type: application/json' \
--header 'x-api-key: <x-api-key>' \
--header 'x-organization-id: <x-organization-id>' \
--data '
{
"invoice_ids": [
"<string>"
],
"update": {
"unit_id": "<string>",
"currency_unit_id": "<string>",
"supplier_id": "<string>",
"cups": "<string>"
}
}
'{
"success_count": 123,
"success_ids": [
"<string>"
],
"failed_count": 123,
"failed_ids": [
"<string>"
],
"message": "<string>"
}← Invoices API
Apply the same set of field changes to many invoices at once. Only the fields exposed by the bulk-edit UI (
unit_id, currency_unit_id, supplier_id, cups) can be updated; every other field on each invoice is left untouched.
Each selected invoice’s whole distributed group receives the change, so a distributed invoice never ends up with different units or supplier across facilities. Selecting more than one row of the same group updates that group exactly once.
When a change affects the emission calculation (supplier_id or unit_id), recalculation is triggered asynchronously: the affected invoices move to loading and settle once the recalculation finishes. Changing only currency_unit_id or cups updates the value as plain metadata and triggers no recalculation.
Per-invoice failures are reported in failed_ids instead of aborting the batch. Invoice IDs that do not belong to your organization are also returned in failed_ids.
Request
Headers
string
required
Your API key for authenticationExample:
sk_live_1234567890abcdefstring
required
Your organization UUIDExample:
a8315ef3-dd50-43f8-b7ce-d839e68d51faBody Parameters
string[]
required
Array of invoice UUIDs to update (1–10,000)
object
required
Fields to apply to every selected invoice. At least one field must be provided.
Show update
Show update
string
UUID of the unit of the quantity. Cannot be set to
null.string
UUID of the fiat-currency unit of the monetary spend. Does not affect the emission calculation.Retrieve it from
GET /v2/units, which works with your API
key. Currencies have no type filter, so request the full catalog and match on the ISO
code in the name — searching for (eur) finds the eurostring
UUID of the supplier (provider).Retrieve available options from
GET /api/v1/suppliers — electricity and energy suppliersstring
CUPS supply-point code (electricity). Does not affect the emission calculation.
Response
integer
Number of invoices successfully updated
string[]
UUIDs of successfully updated invoices
integer
Number of invoices that failed to update or were not found
string[]
UUIDs of invoices that failed to update or were not found
string
Human-readable summary message
Example
curl -X POST "https://api.dcycle.io/v1/invoices/bulk-update" \
-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"],
"update": {
"supplier_id": "'${SUPPLIER_ID}'"
}
}'
import requests
import os
headers = {
"x-api-key": os.getenv("DCYCLE_API_KEY"),
"x-organization-id": os.getenv("DCYCLE_ORG_ID"),
"Content-Type": "application/json",
}
response = requests.post(
"https://api.dcycle.io/v1/invoices/bulk-update",
headers=headers,
json={
"invoice_ids": ["uuid-1", "uuid-2"],
"update": {"supplier_id": os.getenv("SUPPLIER_ID")},
},
)
result = response.json()
print(f"Updated: {result['success_count']} | Failed: {result['failed_count']}")
const axios = require('axios');
const headers = {
'x-api-key': process.env.DCYCLE_API_KEY,
'x-organization-id': process.env.DCYCLE_ORG_ID,
'Content-Type': 'application/json',
};
axios.post('https://api.dcycle.io/v1/invoices/bulk-update', {
invoice_ids: ['uuid-1', 'uuid-2'],
update: { supplier_id: process.env.SUPPLIER_ID },
}, { headers })
.then(response => {
const { success_count, failed_count } = response.data;
console.log(`Updated: ${success_count} | Failed: ${failed_count}`);
});
Successful Response
{
"success_count": 2,
"success_ids": ["uuid-1", "uuid-2"],
"failed_count": 0,
"failed_ids": [],
"message": "Successfully updated 2 invoice(s)"
}
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: No fields provided inupdate, an explicit null unit_id, or a supplier_id that does not exist
{"detail": "Supplier not found", "code": "SUPPLIER_ID_NOT_FOUND"}
Related Endpoints
Update Invoice
Update a single invoice
Bulk Delete
Delete multiple invoices by ID
Was this page helpful?