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({purchase_ids: ['<string>']})
};
fetch('https://api.dcycle.io/v1/purchases/bulk-delete', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.dcycle.io/v1/purchases/bulk-delete"
payload = { "purchase_ids": ["<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/purchases/bulk-delete \
--header 'Content-Type: application/json' \
--header 'x-api-key: <x-api-key>' \
--header 'x-organization-id: <x-organization-id>' \
--data '
{
"purchase_ids": [
"<string>"
]
}
'{
"deleted": [
"<string>"
],
"failed": [
{}
]
}Bulk Delete
Delete multiple purchases by ID in a single request
POST
/
v1
/
purchases
/
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({purchase_ids: ['<string>']})
};
fetch('https://api.dcycle.io/v1/purchases/bulk-delete', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.dcycle.io/v1/purchases/bulk-delete"
payload = { "purchase_ids": ["<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/purchases/bulk-delete \
--header 'Content-Type: application/json' \
--header 'x-api-key: <x-api-key>' \
--header 'x-organization-id: <x-organization-id>' \
--data '
{
"purchase_ids": [
"<string>"
]
}
'{
"deleted": [
"<string>"
],
"failed": [
{}
]
}← Purchases API
Delete multiple purchases by their IDs. All purchases must belong to the requesting organization. Related emission records (
total_impacts) are automatically deleted to maintain referential integrity.
Returns detailed results for each ID, allowing you to handle partial failures gracefully.
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 purchase UUIDs to delete (1–100,000 per request)
Response
string[]
UUIDs of successfully deleted purchases
object[]
Failed deletions with reason:
| Field | Type | Description |
|---|---|---|
id | string | The purchase UUID that failed |
reason | string | Why the deletion failed |
Example
curl -X POST "https://api.dcycle.io/v1/purchases/bulk-delete" \
-H "x-api-key: ${DCYCLE_API_KEY}" \
-H "x-organization-id: ${DCYCLE_ORG_ID}" \
-H "Content-Type: application/json" \
-d '{
"purchase_ids": [
"a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"b2c3d4e5-f6a7-8901-bcde-f12345678901"
]
}'
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/purchases/bulk-delete",
headers=headers,
json={
"purchase_ids": [
"a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"b2c3d4e5-f6a7-8901-bcde-f12345678901",
]
},
)
result = response.json()
print(f"Deleted: {len(result['deleted'])} | Failed: {len(result['failed'])}")
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/purchases/bulk-delete', {
purchase_ids: [
'a1b2c3d4-e5f6-7890-abcd-ef1234567890',
'b2c3d4e5-f6a7-8901-bcde-f12345678901',
],
}, { headers })
.then(response => {
const { deleted, failed } = response.data;
console.log(`Deleted: ${deleted.length} | Failed: ${failed.length}`);
});
Successful Response
{
"deleted": [
"a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"b2c3d4e5-f6a7-8901-bcde-f12345678901"
],
"failed": []
}
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 Validation Error
Cause: Empty array or more than 100,000 IDs{
"detail": [
{
"loc": ["body", "purchase_ids"],
"msg": "ensure this value has at least 1 items",
"type": "value_error.list.min_items"
}
]
}
Related Endpoints
Bulk Delete by Filters
Delete all purchases matching filter criteria
List Purchases
Browse and filter purchases
Was this page helpful?