Trigger retention run
curl --request POST \
--url https://api.example.com/api/v1/admin/retention/runimport requests
url = "https://api.example.com/api/v1/admin/retention/run"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.example.com/api/v1/admin/retention/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/retention/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/retention/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/retention/run")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/admin/retention/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_bodyRetention
Trigger retention run
Enqueue a one-shot tenancy-document retention cleanup. Returns 202. SUPER role only.
POST
/
api
/
v1
/
admin
/
retention
/
run
Trigger retention run
curl --request POST \
--url https://api.example.com/api/v1/admin/retention/runimport requests
url = "https://api.example.com/api/v1/admin/retention/run"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.example.com/api/v1/admin/retention/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/retention/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/retention/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/retention/run")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/admin/retention/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_bodyOverview
Manually triggers the tenancy-document retention cleanup that normally runs on a daily schedule (03:00 UTC). The endpoint enqueues a one-shot job onto the worker’s BullMQ queue and returns202 Accepted immediately — the actual cleanup runs out-of-band in the worker process, using the same handler as the scheduled run.
Useful when a backlog has built up (the per-run cap is 500 rows) and an operator wants to drain it without waiting for the next nightly window. See Tenancy retention for the full lifecycle.
Authentication
Bearer <accessToken> with scope: 'admin' required (requireAdmin).
Role-gated: SUPER only. Neither MODERATOR nor FINANCE may invoke it — cleanup is destructive (the tenancy document is permanently removed from object storage). Per QUESTIONS.md §8.4.
Path parameters
None.Query parameters
None.Request body
None.Response — 202 Accepted
| Field | Type | Notes | Example |
|---|---|---|---|
status | string | Always "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 cleanup result counts (scanned/deleted/failed) — those are logged by the worker. There is no synchronous “how many rows did it delete?” read in Phase 6.Error responses
| Status | Code | Meaning |
|---|---|---|
| 401 | UNAUTHENTICATED | Missing, malformed, expired, or non-admin-scope token. |
| 403 | FORBIDDEN | Caller 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/retention/run",
"requestId": "01HZQ7K3M4N5P6Q7R8S9T0V1W2"
}
Side effects
- A one-shot retention-cleanup job is enqueued on the worker queue.
- An audit-log row is written (action
retention.manual-trigger). - When no Redis/queue is wired (dev/test), a no-op enqueuer is used and the call still returns
202.
See also
- Tenancy retention — the full 30-day lifecycle, the scheduled job, and failure semantics.
- Approve tenancy — where
reviewedAt(the start of the 30-day clock) is set.
curl
curl -X POST https://api.swappr.co.uk/api/v1/admin/retention/run \
-H "Authorization: Bearer $ADMIN_ACCESS_TOKEN"
Postman
Seedocs/postman/swappr.postman_collection.json → Admin Retention → Run.