> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pacifica.fi/llms.txt
> Use this file to discover all available pages before exploring further.

# Request Withdrawal

> This endpoint allows users to request withdrawal.

```http theme={null}
POST /api/v1/account/withdraw
```

#### Request Body

<table><thead><tr><th width="176">Field</th><th width="98">Type</th><th width="95">Need</th><th>Description</th><th>Example</th></tr></thead><tbody><tr><td>`"account"`</td><td>string</td><td>required</td><td>User's wallet address</td><td>`42trU9A5...`</td></tr><tr><td>`"signature"`</td><td>string</td><td>required</td><td>Cryptographic signature</td><td>`5j1Vy9Uq...`</td></tr><tr><td>`"timestamp"`</td><td>integer</td><td>required</td><td>Current timestamp in milliseconds</td><td>`1716200000000`</td></tr><tr><td>`"amount"`</td><td>string</td><td>required</td><td>Amount to withdraw in USDC</td><td>`100.50`</td></tr><tr><td>`"idempotency_key"`</td><td>string</td><td>optional</td><td>Full UUID string. Prevents duplicate withdrawals. Required when the account has two-factor authentication on</td><td>`550e8400-e29b-41d4-a716-446655440000`</td></tr><tr><td>`"agent_wallet"`</td><td>string</td><td>optional</td><td>Agent wallet address</td><td>`69trU9A5...`</td></tr><tr><td>`"expiry_window"`</td><td>integer</td><td>optional</td><td>Signature expiry in milliseconds</td><td>`30000`</td></tr><tr><td>`"two_factor"`</td><td>object</td><td>conditional</td><td>Two-factor proof. Required when the account has two-factor authentication on. Not part of the signed payload. See below</td><td>`{"type": "totp", "code": "123456"}`</td></tr></tbody></table>

```json theme={null}
{
  "account": "42trU9A5...",
  "signature": "5j1Vy9Uq...",
  "timestamp": 1716200000000,
  "amount": "100.50",
  "agent_wallet": "69trU9A5...",
  "expiry_window": 30000
}
```

#### Two-factor authentication

If the account's owner has turned on two-factor authentication, every withdrawal needs a proof, including withdrawals that an agent wallet signs.

To turn it on or manage factors, see [Two-factor authentication](https://docs.pacifica.fi/api-documentation/api/rest-api/two-factor).

* Send an `idempotency_key`. A retry with the same key and the same request returns the first result, so a retry does not need a new code.
* Send the proof in `two_factor`, outside the signed `data`. For an authenticator app, use `{"type": "totp", "code": "123456"}`. Recovery keys do not authorize withdrawals.

| Status | Meaning |
| - | - |
| `428` | Proof required: send `two_factor` |
| `401` | Proof is wrong, expired, or already used |
| `429` | Too many proof attempts. Each signer gets 5 attempts per 5 minutes |
| `400` | `idempotency_key` is missing |
| `409` | The `idempotency_key` was used for a different request |
| `422` | The proof can't be used here, for example a recovery key |
| `503` | Two-factor checks are unavailable. Retry later |

#### Response

* Status 200: Success

```json theme={null}
{
  "success": true,
  "data": {
    "batch_nonce": 42,
    "requested_amount": "100.500000",
    "fee_amount": "1.000000"
  }
}
```

| Field | Type | Description |
| - | - | - |
| `'batch_nonce'` | integer | Nonce of the withdrawal batch |
| `'requested_amount'` | decimal string | Amount requested for withdrawal |
| `'fee_amount'` | decimal string | Fee deducted from the withdrawal |

* Status 400: Invalid request parameters
* Status 409: `idempotency_key` already used for a different request. A retry of the same request returns the first result
* Status 500: Internal server error

#### Code Example (Python)

```python theme={null}
import requests

payload = {
    "account": "42trU9A5...",
    "signature": "5j1Vy9Uq...",
    "timestamp": 1716200000000,
    "amount": "100.50"
}

response = requests.post(
    "/api/v1/account/withdraw",
    json=payload,
    headers={"Content-Type": "application/json"}
)

data = response.json()
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.