# Prepare a Withdrawal

> Coming soon, upon request — this feature is turned on for your tenant by the Aurea team. [Contact us](https://www.aureahub.com/contact)

The unsigned transaction of a withdrawal, for a wallet the user signs for — client-side or MPC.

## Overview

- `weiAmount`: digits only, in the smallest unit, or `"max"` for the whole position. One step, the withdrawal, signed and sent as for [Prepare a Supply](https://docs.aureahub.com/docs/lending-prepare-supply.md).
- For a tenant on the institutional security profile, a policy rule that asks for an approval answers `403` `POLICY_APPROVAL_REQUIRED` here.

## Endpoint

### `POST /v1/lending/prepare-withdraw`

Authentication: bearer token required.

Builds the unsigned withdrawal transaction. Needs the user's access token and the tenant signature (or a server token).

**Request body**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `weiAmount` | string | yes | Digits only, in the smallest unit, or `max` |
| `isTestnet` | boolean | yes | `true` testnet, `false` mainnet |

**Responses**

`200` OK

```json
{
  "steps": [
    {
      "stepIndex": 0,
      "txHashToSign": "0x71bd…",
      "to": "0x… (the lending pool)",
      "data": "0x69328dec…",
      "value": "0",
      "chainId": 100,
      "nonce": 9,
      "gasLimit": "250000",
      "maxFeePerGas": "3000000000",
      "maxPriorityFeePerGas": "1000000000"
    }
  ],
  "walletAddress": "0x2f4b6c2e9a1d5f3b7c8e0a4d6b2c9e1f3a5d7b90"
}
```

**Example request**

```bash
curl -X POST https://api.aureahub.com/v1/lending/prepare-withdraw \
  -H "Authorization: Bearer USER_ACCESS_TOKEN" \
  -H "x-tenant-api-key: YOUR_API_KEY" \
  -H "x-timestamp: UNIX_SECONDS" \
  -H "x-signature: HMAC_SHA256_HEX" \
  -H "Content-Type: application/json" \
  -d '{"weiAmount": "max", "isTestnet": false}'
```

---

Web version: https://docs.aureahub.com/#lending-prepare-withdraw
