Documentation Index
Fetch the complete documentation index at: https://docs.pylonsync.com/llms.txt
Use this file to discover all available pages before exploring further.
DELETE /api/auth/account is the “user clicked Delete Account” button. It wipes the user’s auth state across every system Pylon owns — sessions, API keys, linked OAuth accounts, trusted-device records, and the User row itself — in one transactional sweep. App-owned tables that reference the user are not cascade-deleted (see below) — the host schema is the source of truth for what gets purged.
Endpoint
| Endpoint | Method | Auth | Purpose |
|---|---|---|---|
/api/auth/account | DELETE | session | Hard-delete the caller’s account |
What gets wiped
Pylon performs the following in order:- Revoke all sessions for the user. The caller’s current session is invalidated first so a slow user-row delete can’t 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.
| Status | Code | Reason |
|---|---|---|
| 401 | AUTH_REQUIRED | No session |
| 403 | API_KEY_AUTH_FORBIDDEN | API-key auth can’t delete the account — real session required |
| 400 | (storage error code) | The User row delete failed (storage layer rejection) |
App-owned tables don’t cascade
This is the most important caveat: Pylon does NOT cascade-delete your app’s tables. If the user has 47 Project rows pointing at theiruser_id, those rows survive the delete. The host schema is the source of truth — your app declares its own deletion semantics.
The canonical pattern is a plugin hook that fires before the user row is wiped:
Confirming first
Don’t expose this endpoint without a confirmation step in your UI. Pylon doesn’t require a password / TOTP re-prompt on the API itself — design the front-end flow to confirm:Audit trail
TheAccountDelete audit event is written before the user row is deleted, so the event row survives. Read via /api/auth/audit — gives operators a record of which users self-deleted and when, with counts of what was wiped.
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