{"id":445419,"date":"2026-09-18T00:57:44","date_gmt":"2026-09-17T22:57:44","guid":{"rendered":"https:\/\/www.kafinea.com\/documentation\/uncategorized\/rest-api-bulk-deletion-trash\/"},"modified":"2026-11-22T17:50:31","modified_gmt":"2026-11-22T16:50:31","password":"","slug":"rest-api-bulk-deletion-trash","status":"publish","type":"docs","link":"https:\/\/www.kafinea.com\/en\/help\/api\/rest-api-bulk-deletion-trash\/","title":{"rendered":"REST API &#8211; Bulk deletion (trash)"},"content":{"rendered":"<p>This page describes the operation to use to <strong>move large numbers of records to the trash<br \/>\nat once<\/strong>, typically to clear out what a previous synchronization or import wrote, before<br \/>\nstarting over with a clean database.<\/p>\n<div style=\"overflow-x:auto\">\n<table>\n<thead>\n<tr>\n<th>Operation<\/th>\n<th>Method<\/th>\n<th>Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>mass_delete<\/code><\/td>\n<td>POST<\/td>\n<td>Move a batch of records to the trash<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<blockquote>\n<p><strong>Restricted to administrators.<\/strong> Deleting hundreds of records in a single call is a<br \/>\ndata recovery task. A non-administrator account keeps <code>delete<\/code>, one record at a<br \/>\ntime, with their own permissions.<\/p>\n<\/blockquote>\n<hr>\n<h2>Nothing is erased: this is a move to the trash<\/h2>\n<p><code>mass_delete<\/code> does <strong>exactly what the Delete button does in the interface<\/strong>: the record<br \/>\ngoes to the trash. It retains its ID, its links, and its history, and it can be<br \/>\nrestored.<\/p>\n<p><strong>Permanent deletion does not exist in the API.<\/strong> Emptying the trash remains a deliberate action,<br \/>\nto be performed from the instance (<em>Settings &gt; Trash<\/em>). This is intentional: an irreversible deletion<br \/>\nmust not be triggerable by a script.<\/p>\n<hr\/>\n<h2>Bulk deletion \u2013 Move a batch to the trash<\/h2>\n<blockquote>\n<p><strong>POST<\/strong> <code>https:\/\/apps.kafinea.com\/{instance}\/webservice.php<\/code><\/p>\n<\/blockquote>\n<div style=\"overflow-x:auto\">\n<table>\n<thead>\n<tr>\n<th>Parameter<\/th>\n<th>Type<\/th>\n<th>Required<\/th>\n<th>Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>operation<\/code><\/td>\n<td>string<\/td>\n<td>yes<\/td>\n<td>Must be <code>mass_delete<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>sessionName<\/code><\/td>\n<td>string<\/td>\n<td>yes<\/td>\n<td>Session identifier<\/td>\n<\/tr>\n<tr>\n<td><code>elementType<\/code><\/td>\n<td>string<\/td>\n<td>yes<\/td>\n<td>Name of the target module (e.g.: <code>Products<\/code>, <code>SalesOrder<\/code>)<\/td>\n<\/tr>\n<tr>\n<td><code>ids<\/code><\/td>\n<td>JSON<\/td>\n<td>yes<\/td>\n<td>Array of IDs (500 maximum per call)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>IDs can be retrieved with <a href=\"https:\/\/www.kafinea.com\/en\/help\/api\/rest-api-requests-and-querying\/\"><code>query<\/code><\/a>.<\/p>\n<p><!-- doc-check-ignore: tech --><\/p>\n<pre><code class=\"language-bash\">curl -X POST https:\/\/apps.kafinea.com\/YourKafinea\/webservice.php \\\n  -d \"operation=mass_delete\" \\\n  -d \"sessionName=YOUR_SESSION_ID\" \\\n  -d \"elementType=SalesOrder\" \\\n  -d 'ids=[\"7x54993\",\"7x54994\",\"7x54995\"]'\n<\/code><\/pre>\n<h3>Response<\/h3>\n<pre><code class=\"language-json\">{\n  \"success\": true,\n  \"result\": {\n    \"module\": \"SalesOrder\",\n    \"processed\": 3,\n    \"deleted\": 2,\n    \"alreadyDeleted\": 1,\n    \"records\": [\n      { \"index\": 0, \"id\": \"7x54993\", \"outcome\": \"deleted\" },\n      { \"index\": 1, \"id\": \"7x54994\", \"outcome\": \"deleted\" },\n      { \"index\": 2, \"id\": \"7x54995\", \"outcome\": \"alreadyDeleted\" }\n    ],\n    \"errors\": []\n  }\n}\n<\/code><\/pre>\n<div style=\"overflow-x:auto\">\n<table>\n<thead>\n<tr>\n<th>Field<\/th>\n<th>Meaning<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>processed<\/code><\/td>\n<td>Number of records processed without error<\/td>\n<\/tr>\n<tr>\n<td><code>deleted<\/code><\/td>\n<td>Records that were just moved to the trash<\/td>\n<\/tr>\n<tr>\n<td><code>alreadyDeleted<\/code><\/td>\n<td>Records that were already there: nothing was done, this is not an error<\/td>\n<\/tr>\n<tr>\n<td><code>records<\/code><\/td>\n<td>Line-by-line details, with the <strong>position in the batch<\/strong><\/td>\n<\/tr>\n<tr>\n<td><code>errors<\/code><\/td>\n<td>Rejected IDs, with their position in the batch and the reason<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<hr>\n<h2>Safeguards<\/h2>\n<p>A bulk deletion has no second chance, so the operation is deliberately strict:<\/p>\n<ul>\n<li><strong>the module is mandatory, and all IDs must belong to it.<\/strong> An ID<br \/>\nthat refers to a record from another module is rejected, with the module actually found included in the<br \/>\nreason. This is a safeguard against an incorrect prefix in a generated file, which could delete<br \/>\nsomething other than what you expect;<\/li>\n<li><strong>an ID that doesn&#8217;t refer to anything is identified as such<\/strong>, rather than presented as a permissions<br \/>\nissue;<\/li>\n<li><strong>permissions are those of <code>delete<\/code><\/strong>: access to the module, deletion rights on the profile, sharing of<br \/>\nthe record. The operation deletes nothing that <code>delete<\/code> would have refused;<\/li>\n<li><strong>a faulty ID does not cancel the others<\/strong>: valid records in the batch go to the<br \/>\ntrash, rejected IDs are returned in <code>errors<\/code> with their position;<\/li>\n<li>if the <code>ids<\/code> parameter itself is not readable (invalid JSON, more than 500 elements), <strong>the entire call<br \/>\nis rejected<\/strong>: processing half of an incomprehensible batch would be worse than processing<br \/>\nnone of it.<\/li>\n<\/ul>\n<hr>\n<h2>Replayable: re-run without worry<\/h2>\n<p>An ID already in the trash is counted in <code>alreadyDeleted<\/code>, not in <code>errors<\/code>. You can<br \/>\ntherefore <strong>resend the same batch as is<\/strong> after an interruption, without having to sort beforehand what has<br \/>\nalready been processed.<\/p>\n<hr>\n<h2>Related references \ud83d\udd17<\/h2>\n<ul>\n<li><a href=\"https:\/\/www.kafinea.com\/en\/help\/api\/rest-api-full-reference-openapi\/\">Full API reference<\/a>: deleting one record at a time<\/li>\n<li><a href=\"https:\/\/www.kafinea.com\/en\/help\/api\/rest-api-requests-and-querying\/\">Queries and filtering<\/a>: retrieving the IDs to delete<\/li>\n<li><a href=\"https:\/\/www.kafinea.com\/en\/help\/api\/rest-api-bulk-import-upsert\/\">Bulk import (upsert)<\/a>: the symmetrical operation, for writing a batch<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>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&#8230;<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_uag_custom_page_level_css":"","_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","footnotes":""},"doc_category":[759],"doc_tag":[],"class_list":["post-445419","docs","type-docs","status-publish","hentry","doc_category-api"],"year_month":"2026-11","word_count":563,"total_views":0,"reactions":{"happy":0,"normal":0,"sad":0},"author_info":{"name":"David Valminos","author_nicename":"david","author_url":"https:\/\/www.kafinea.com\/en\/author\/david\/"},"doc_category_info":[{"term_name":"API","term_url":"https:\/\/www.kafinea.com\/en\/help\/api\/"}],"doc_tag_info":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Help - REST API - Bulk deletion (trash) &#8226; Kafinea<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.kafinea.com\/en\/help\/api\/rest-api-bulk-deletion-trash\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Help - REST API - Bulk deletion (trash) &#8226; Kafinea\" \/>\n<meta property=\"og:description\" content=\"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...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.kafinea.com\/en\/help\/api\/rest-api-bulk-deletion-trash\/\" \/>\n<meta property=\"og:site_name\" content=\"Kafinea\" \/>\n<meta property=\"article:modified_time\" content=\"2026-11-22T16:50:31+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.kafinea.com\\\/en\\\/help\\\/api\\\/rest-api-bulk-deletion-trash\\\/\",\"url\":\"https:\\\/\\\/www.kafinea.com\\\/en\\\/help\\\/api\\\/rest-api-bulk-deletion-trash\\\/\",\"name\":\"Help - REST API - Bulk deletion (trash) &#8226; Kafinea\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.kafinea.com\\\/en\\\/#website\"},\"datePublished\":\"2026-09-17T22:57:44+00:00\",\"dateModified\":\"2026-11-22T16:50:31+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.kafinea.com\\\/en\\\/help\\\/api\\\/rest-api-bulk-deletion-trash\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.kafinea.com\\\/en\\\/help\\\/api\\\/rest-api-bulk-deletion-trash\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.kafinea.com\\\/en\\\/help\\\/api\\\/rest-api-bulk-deletion-trash\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\\\/\\\/www.kafinea.com\\\/en\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"REST API &#8211; Bulk deletion (trash)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.kafinea.com\\\/en\\\/#website\",\"url\":\"https:\\\/\\\/www.kafinea.com\\\/en\\\/\",\"name\":\"Kafinea\",\"description\":\"Une solution unique pour toutes vos ambitions\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.kafinea.com\\\/en\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.kafinea.com\\\/en\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.kafinea.com\\\/en\\\/#organization\",\"name\":\"Kafinea\",\"url\":\"https:\\\/\\\/www.kafinea.com\\\/en\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.kafinea.com\\\/en\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.kafinea.com\\\/wp-content\\\/uploads\\\/2024\\\/10\\\/Logo-Kafinea-SVG-orange-bleu.svg\",\"contentUrl\":\"https:\\\/\\\/www.kafinea.com\\\/wp-content\\\/uploads\\\/2024\\\/10\\\/Logo-Kafinea-SVG-orange-bleu.svg\",\"width\":296.31,\"height\":66.48,\"caption\":\"Kafinea\"},\"image\":{\"@id\":\"https:\\\/\\\/www.kafinea.com\\\/en\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/company\\\/kafinea\\\/\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Help - REST API - Bulk deletion (trash) &#8226; Kafinea","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.kafinea.com\/en\/help\/api\/rest-api-bulk-deletion-trash\/","og_locale":"en_US","og_type":"article","og_title":"Help - REST API - Bulk deletion (trash) &#8226; Kafinea","og_description":"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...","og_url":"https:\/\/www.kafinea.com\/en\/help\/api\/rest-api-bulk-deletion-trash\/","og_site_name":"Kafinea","article_modified_time":"2026-11-22T16:50:31+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.kafinea.com\/en\/help\/api\/rest-api-bulk-deletion-trash\/","url":"https:\/\/www.kafinea.com\/en\/help\/api\/rest-api-bulk-deletion-trash\/","name":"Help - REST API - Bulk deletion (trash) &#8226; Kafinea","isPartOf":{"@id":"https:\/\/www.kafinea.com\/en\/#website"},"datePublished":"2026-09-17T22:57:44+00:00","dateModified":"2026-11-22T16:50:31+00:00","breadcrumb":{"@id":"https:\/\/www.kafinea.com\/en\/help\/api\/rest-api-bulk-deletion-trash\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.kafinea.com\/en\/help\/api\/rest-api-bulk-deletion-trash\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.kafinea.com\/en\/help\/api\/rest-api-bulk-deletion-trash\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/www.kafinea.com\/en\/"},{"@type":"ListItem","position":2,"name":"REST API &#8211; Bulk deletion (trash)"}]},{"@type":"WebSite","@id":"https:\/\/www.kafinea.com\/en\/#website","url":"https:\/\/www.kafinea.com\/en\/","name":"Kafinea","description":"Une solution unique pour toutes vos ambitions","publisher":{"@id":"https:\/\/www.kafinea.com\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.kafinea.com\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.kafinea.com\/en\/#organization","name":"Kafinea","url":"https:\/\/www.kafinea.com\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.kafinea.com\/en\/#\/schema\/logo\/image\/","url":"https:\/\/www.kafinea.com\/wp-content\/uploads\/2024\/10\/Logo-Kafinea-SVG-orange-bleu.svg","contentUrl":"https:\/\/www.kafinea.com\/wp-content\/uploads\/2024\/10\/Logo-Kafinea-SVG-orange-bleu.svg","width":296.31,"height":66.48,"caption":"Kafinea"},"image":{"@id":"https:\/\/www.kafinea.com\/en\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.linkedin.com\/company\/kafinea\/"]}]}},"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"David Valminos","author_link":"https:\/\/www.kafinea.com\/en\/author\/david\/"},"uagb_comment_info":0,"uagb_excerpt":"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...","_links":{"self":[{"href":"https:\/\/www.kafinea.com\/en\/wp-json\/wp\/v2\/docs\/445419","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kafinea.com\/en\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/www.kafinea.com\/en\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/www.kafinea.com\/en\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kafinea.com\/en\/wp-json\/wp\/v2\/comments?post=445419"}],"version-history":[{"count":0,"href":"https:\/\/www.kafinea.com\/en\/wp-json\/wp\/v2\/docs\/445419\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.kafinea.com\/en\/wp-json\/wp\/v2\/media?parent=445419"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/www.kafinea.com\/en\/wp-json\/wp\/v2\/doc_category?post=445419"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/www.kafinea.com\/en\/wp-json\/wp\/v2\/doc_tag?post=445419"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}