# Delete account

> Permanently delete an embedded Abstraxn wallet account from your app

Use `deleteAccount` from `useAbstraxnWallet()` to permanently delete a connected **embedded** wallet account (email OTP, passkey, or social login). This removes the wallet organization and backend account rows. It cannot be undone.

## Prerequisites

- `AbstraxnProvider` is configured and the user is connected.
- Wallet-service exposes `POST /account/delete/prepare` and `POST /account/delete/submit-stamped`.
- Use only for embedded auth — not for external wallets (MetaMask, WalletConnect, etc.).

## React integration

```tsx
import { useAbstraxnWallet, useConnectionType } from "@abstraxn/signer-react";

export function DeleteAccountButton() {
  const { deleteAccount, disconnect, isConnected } = useAbstraxnWallet();
  const { connectorMeta } = useConnectionType();

  const isEmbedded =
    isConnected &&
    (connectorMeta?.category === "auth" || connectorMeta?.category === "oauth");

  if (!isEmbedded || !deleteAccount) {
    return null;
  }

  const handleDelete = async () => {
    const ok = window.confirm(
      "Permanently delete this account and wallet? This cannot be undone."
    );
    if (!ok) return;

    try {
      await deleteAccount();
      await disconnect();
      // Clear any app-specific session state here
    } catch (error) {
      console.error("Delete account failed:", error);
    }
  };

  return <button onClick={() => void handleDelete()}>Delete account</button>;
}
```

## Core SDK (framework-agnostic)

```ts
import { AbstraxnWallet } from "@abstraxn/signer-core";

const wallet = new AbstraxnWallet({ apiKey: "your-api-key" });
await wallet.connect();

await wallet.deleteAccount();
await wallet.disconnect();
```

## What happens

1. Client calls prepare → receives a delete-organization activity body.
2. Client stamps the activity with the session key.
3. Client submits the stamped activity; the API co-signs and completes deletion.
4. Backend removes linked auth rows, org wallets, and the user record.
5. Your app should call `disconnect()` and clear local session state.

## Notes

- Always show a confirmation UI before calling `deleteAccount`.
- Gate the control with `useConnectionType()` so external wallet users never see it.
- After success, the previous access token is no longer valid for that account.
