This page describes the operation to use to move large numbers of records to the trash
at once, typically to clear out what a previous synchronization or import wrote, before
starting over with a clean database.
| Operation | Method | Description |
|---|---|---|
mass_delete |
POST | Move a batch of records to the trash |
Restricted to administrators. Deleting hundreds of records in a single call is a
data recovery task. A non-administrator account keepsdelete, one record at a
time, with their own permissions.
Nothing is erased: this is a move to the trash #
mass_delete does exactly what the Delete button does in the interface: the record
goes to the trash. It retains its ID, its links, and its history, and it can be
restored.
Permanent deletion does not exist in the API. Emptying the trash remains a deliberate action,
to be performed from the instance (Settings > Trash). This is intentional: an irreversible deletion
must not be triggerable by a script.
Bulk deletion – Move a batch to the trash #
POST
https://apps.kafinea.com/{instance}/webservice.php
| Parameter | Type | Required | Description |
|---|---|---|---|
operation |
string | yes | Must be mass_delete |
sessionName |
string | yes | Session identifier |
elementType |
string | yes | Name of the target module (e.g.: Products, SalesOrder) |
ids |
JSON | yes | Array of IDs (500 maximum per call) |
IDs can be retrieved with query.
curl -X POST https://apps.kafinea.com/YourKafinea/webservice.php \
-d "operation=mass_delete" \
-d "sessionName=YOUR_SESSION_ID" \
-d "elementType=SalesOrder" \
-d 'ids=["7x54993","7x54994","7x54995"]'
Response #
{
"success": true,
"result": {
"module": "SalesOrder",
"processed": 3,
"deleted": 2,
"alreadyDeleted": 1,
"records": [
{ "index": 0, "id": "7x54993", "outcome": "deleted" },
{ "index": 1, "id": "7x54994", "outcome": "deleted" },
{ "index": 2, "id": "7x54995", "outcome": "alreadyDeleted" }
],
"errors": []
}
}
| Field | Meaning |
|---|---|
processed |
Number of records processed without error |
deleted |
Records that were just moved to the trash |
alreadyDeleted |
Records that were already there: nothing was done, this is not an error |
records |
Line-by-line details, with the position in the batch |
errors |
Rejected IDs, with their position in the batch and the reason |
Safeguards #
A bulk deletion has no second chance, so the operation is deliberately strict:
- the module is mandatory, and all IDs must belong to it. An ID
that refers to a record from another module is rejected, with the module actually found included in the
reason. This is a safeguard against an incorrect prefix in a generated file, which could delete
something other than what you expect; - an ID that doesn’t refer to anything is identified as such, rather than presented as a permissions
issue; - permissions are those of
delete: access to the module, deletion rights on the profile, sharing of
the record. The operation deletes nothing thatdeletewould have refused; - a faulty ID does not cancel the others: valid records in the batch go to the
trash, rejected IDs are returned inerrorswith their position; - if the
idsparameter itself is not readable (invalid JSON, more than 500 elements), the entire call
is rejected: processing half of an incomprehensible batch would be worse than processing
none of it.
Replayable: re-run without worry #
An ID already in the trash is counted in alreadyDeleted, not in errors. You can
therefore resend the same batch as is after an interruption, without having to sort beforehand what has
already been processed.
Related references 🔗 #
- Full API reference: deleting one record at a time
- Queries and filtering: retrieving the IDs to delete
- Bulk import (upsert): the symmetrical operation, for writing a batch