DELETE /api/auth/account deletes a user account. It clears the user’s auth state in every system Pylon owns: sessions, API keys, linked OAuth accounts, trusted-device records, and the User row. Pylon does this in one transaction. App-owned tables that reference the user are not deleted (see below). The host schema decides what gets purged.
Endpoint
What gets wiped
Pylon performs the following in order:- Revoke all sessions for the user. Pylon revokes the caller’s current session first, so a slow user-row delete cannot leave a usable session.
- Revoke all API keys owned by the user (
pk.*bearer tokens). - Unlink all OAuth accounts — Google, GitHub, Apple, etc. credentials that were linked to this user.
- Revoke all trusted devices — the
pylon_trusted_devicerecords for this user. - Delete the User row itself from the entity backing the auth user.
- Clear the session cookie on the response so the browser drops it.
- Audit log an
AccountDeleteevent with counts of each category.
App-owned tables don’t cascade
Pylon does not delete your app’s tables. If the user has 47 Project rows that point at theiruser_id, those rows survive the delete. Your app declares its own deletion rules.
The canonical pattern is a plugin hook that fires before the user row is wiped:
Confirming first
Do not expose this endpoint without a confirmation step in your UI. The API does not require a password or TOTP re-prompt. Design the frontend flow to confirm the action:Audit trail
Pylon writes theAccountDelete audit event before it deletes the user row, so the event row survives. Read it via /api/auth/audit. Operators get a record of which users deleted their account and when, with counts of what was cleared.
Where to go next
- Sessions — revoke a single session without deleting the account
- API keys — revoke a single key without deleting the account
- GDPR export —
/api/admin/users/:id/exportcompanion endpoint for data portability