POST
/
api
/
v1
/
admin
/
erasure
/
run
Trigger erasure run
curl --request POST \
  --url https://api.example.com/api/v1/admin/erasure/run
import requests

url = "https://api.example.com/api/v1/admin/erasure/run"

response = requests.post(url)

print(response.text)
const options = {method: 'POST'};

fetch('https://api.example.com/api/v1/admin/erasure/run', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/v1/admin/erasure/run",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"net/http"
"io"
)

func main() {

url := "https://api.example.com/api/v1/admin/erasure/run"

req, _ := http.NewRequest("POST", url, nil)

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.example.com/api/v1/admin/erasure/run")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.example.com/api/v1/admin/erasure/run")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)

response = http.request(request)
puts response.read_body

Overview

Manually triggers the GDPR erasure scan that normally runs on a daily schedule (04:00 UTC). The endpoint enqueues a one-shot job onto the worker’s BullMQ queue and returns 202 Accepted immediately — the actual erasure runs out-of-band in the worker process, using the same handler as the scheduled run. The erasure worker tombstones user rows whose deletedAt < now − 30d (the soft-delete clock starts at DELETE /me) and hard-deletes their child data per the carve-outs in GDPR data lifecycle. Useful when:
  • A backlog has built up (the per-run cap is 500 users) and ops wants to drain it before the next 04:00 window.
  • Operational testing — verifying a specific user’s data has been erased after they passed the 30-day clock.
This endpoint parallels retention manual trigger — same shape, same audit pattern, same no-op fallback when Redis is absent.

Authentication

Bearer <accessToken> with scope: 'admin' required (requireAdmin).
Role-gated: SUPER only. Neither MODERATOR nor FINANCE may invoke it — erasure is destructive (PII removal across every collection, only the anonymized audit trail and the financial-retention-protected subscription rows survive). Per QUESTIONS.md §9.1 item 4.

Path parameters

None.

Query parameters

None.

Request body

None.

Response — 202 Accepted

FieldTypeNotesExample
statusstringAlways "enqueued". The job has been placed on the queue; it has not necessarily run yet.enqueued
{
  "status": "enqueued"
}
202 means accepted for processing, not completed. The response carries no result counts (scanned/erased/failed) — those are logged by the worker. There is no synchronous “how many users did it erase?” read in Phase 7.

Error responses

StatusCodeMeaning
401UNAUTHENTICATEDMissing, malformed, expired, or non-admin-scope token.
403FORBIDDENCaller is a MODERATOR or FINANCE admin. SUPER only.

Example error — 403 FORBIDDEN

{
  "type": "https://api.swappr.co.uk/errors/forbidden",
  "title": "Forbidden",
  "status": 403,
  "code": "FORBIDDEN",
  "detail": "Admin role MODERATOR is not permitted for this action",
  "instance": "/api/v1/admin/erasure/run",
  "requestId": "01HZQ7K3M4N5P6Q7R8S9T0V1W2"
}

Side effects

  • A one-shot gdpr-erasure job is enqueued on the worker queue with removeOnComplete: true (the Bull list does not grow on every admin click).
  • An audit-log row is written (action erasure.manual-trigger).
  • When no Redis/queue is wired (dev/test), a no-op enqueuer is used and the call still returns 202 — same fallback as Phase 5 push, Phase 6 retention, and Phase 7 GDPR export.

See also

curl

curl -X POST https://api.swappr.co.uk/api/v1/admin/erasure/run \
  -H "Authorization: Bearer $ADMIN_ACCESS_TOKEN"

Postman

See docs/postman/swappr.postman_collection.jsonAdmin Erasure → Run.