Skip to main content
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:
  1. 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.
  2. Revoke all API keys owned by the user (pk.* bearer tokens).
  3. Unlink all OAuth accounts — Google, GitHub, Apple, etc. credentials that were linked to this user.
  4. Revoke all trusted devices — the pylon_trusted_device records for this user.
  5. Delete the User row itself from the entity backing the auth user.
  6. Clear the session cookie on the response so the browser drops it.
  7. Audit log an AccountDelete event with counts of each category.
Response:
Errors:

App-owned tables don’t cascade

Pylon does not delete your app’s tables. If the user has 47 Project rows that point at their user_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:
You can also purge inside a mutation wrapper, or with a scheduled cleanup job after the delete. The framework leaves the deletion rule to your app. Some apps tombstone the row, some hard-delete it, and some anonymize the user_id and keep the history.

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:
For sensitive apps, gate the call on a fresh TOTP code or a session re-issued within the last 5 minutes.

Audit trail

Pylon writes the AccountDelete 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/export companion endpoint for data portability