# Delete Wallet

Remove a wallet from the user's account. The primary wallet cannot be deleted.

## Overview

Deletes a wallet by UUID. The wallet is removed from the user's account and will no longer appear in wallet lists. If the wallet holds funds, those funds remain on-chain — they are not automatically transferred. Ensure the wallet balance is zero or transferred before deletion.

The user's **primary wallet cannot be deleted**. To delete it, first assign a different primary wallet using `PATCH /v1/wallets/{id}/primary`, then delete the old one.

> ⚠️ Deletion is permanent within Aurea's system. If the wallet has a non-zero balance, those funds will be inaccessible through the platform unless the wallet is re-imported. Always verify balance before deleting.

### `DELETE /v1/wallets/{id}`

Authentication: bearer token required.

Removes a wallet from the user's account. Cannot delete the primary wallet.

**Path parameters**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | yes | Wallet UUID |

**Responses**

`204` No Content

`403` Forbidden

```json
{ "detail": "Cannot delete primary wallet" }
```

`404` Not Found

```json
{ "detail": "Wallet not found" }
```

## Implementation

```javascript
async function deleteWallet(token, walletId) {
  // Safety check: verify balance is zero first
  const balance = await fetch(
    `https://api.aureahub.com/v1/wallets/${walletId}/balance`,
    { headers: { Authorization: `Bearer ${token}` } }
  ).then(r => r.json());

  const hasBalance = parseFloat(balance.nativeBalance?.amount || '0') > 0
    || (balance.tokens || []).some(t => parseFloat(t.balance) > 0);

  if (hasBalance) {
    throw new Error('Wallet still has funds — transfer or withdraw before deleting');
  }

  const res = await fetch(`https://api.aureahub.com/v1/wallets/${walletId}`, {
    method: 'DELETE',
    headers: { Authorization: `Bearer ${token}` }
  });

  if (res.status === 403) throw new Error('Cannot delete primary wallet — reassign primary first');
  if (res.status === 404) throw new Error('Wallet not found');
  if (!res.ok) throw new Error('Failed to delete wallet');

  return true; // 204 No Content
}
```

---

Web version: https://docs.aureahub.com/#wallets-delete
