Delete a user and all their data (admin only).
const url = 'https://api.tradr.cloud/api/admin/users/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/delete';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"confirmEmail":"hello@example.com"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.tradr.cloud/api/admin/users/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/delete \ --header 'Content-Type: application/json' \ --data '{ "confirmEmail": "hello@example.com" }'Admin-gated (403 ADMIN_REQUIRED). DESTRUCTIVE AND IRREVERSIBLE — the user row and every user-keyed row (accounts, positions, ledger, wallet, Stripe mirror, sessions, settings) are removed by the FK cascade in one transaction; there is no undo. POST (never GET) per the SameSite=Lax CSRF posture.
confirmEmail must equal the target user’s email (case-insensitive) or the request is a 400 VALIDATION_ERROR and nothing is changed; the check is enforced here, not only in the UI that collects it. An admin cannot delete their OWN account this way (400 VALIDATION_ERROR) — self-deletion goes through Settings.
Before the delete, every live subscription is cancelled immediately at Stripe (fail-closed): a cancel error is a 502 STRIPE_CANCEL_FAILED and nothing is deleted. Deleting the last remaining admin is refused with 409 LAST_ADMIN. With Stripe unconfigured but a non-terminal subscription mirror still present the deletion is refused with 409 SUBSCRIPTION_UNRESOLVED.
Parameters
Section titled “ Parameters ”Path Parameters
Section titled “Path Parameters”Request Bodyrequired
Section titled “Request Bodyrequired”object
Must match the target user’s email, case-insensitively.
Examplegenerated
{ "confirmEmail": "hello@example.com"}Responses
Section titled “ Responses ”AdminDeleteUserResult — { userId, outcome: “deleted”, purgeOutcome }.
VALIDATION_ERROR — id is not a UUID, body malformed, confirmEmail does not match, or the caller targeted their own account.
Not authenticated.
ADMIN_REQUIRED — authenticated but not an admin.
NOT_FOUND — no such user.
LAST_ADMIN — cannot delete the last admin; or SUBSCRIPTION_UNRESOLVED — resolve billing first.
Admin rate limit reached (60 / 60 s per user).
STRIPE_CANCEL_FAILED — a live subscription could not be cancelled; nothing deleted.