> For the complete documentation index, see [llms.txt](https://docs.flash.trade/flash-trade/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flash.trade/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/guides/withdraw-funds.md).

# Withdraw funds

Pull collateral back out with the single-call withdraw flow.

Withdrawals are a single call, but two things make them different from a normal transaction: they need a **separate fee payer**, and the funds settle **asynchronously**.

## 1. Build the withdrawal

```bash
curl -X POST $FLASH_API_URL/transaction-builder/withdraw -d '{
  "owner": "<WALLET>", "tokenSymbol": "USDC", "amount": "12.5", "feePayer": "<FEE_PAYER>"
}'
```

* **`feePayer` must differ from `owner`** — the delegation program rejects `owner == feePayer`. The client holds this keypair and co-signs the transaction.
* Optionally pass `feePayerTopUpLamports` to prepend an `owner → feePayer` transfer that covers the escrow rent.

## 2. Handle the response

The response includes `receipt`, `custodySettlementRequired`, and `isNativeSol`.

* **`custodySettlementRequired: true`** → the trade vault can't cover the amount yet. Settle first, then retry `withdraw`:

  ```bash
  curl -X POST $FLASH_API_URL/transaction-builder/custody-settlement -d '{
    "owner": "<WALLET>", "tokenSymbol": "USDC"
  }'
  ```

## 3. Submit and wait

Sign (owner + fee payer), submit to your **Solana RPC**, then poll until the escrow `receipt` account closes — that means the funds landed in your ATA.

* **`isNativeSol: true`** → the funds arrive as WSOL; unwrap the WSOL account back to native SOL.
* If the withdrawal doesn't finalize on its own, resume it:

  ```bash
  curl -X POST $FLASH_API_URL/transaction-builder/withdrawal-settle -d '{
    "owner": "<WALLET>", "tokenMint": "<MINT>"
  }'
  ```

> A lower-level `request-withdrawal` performs just the request step (also requires `feePayer` ≠ `owner`). Most integrations should use `withdraw`.

→ Full fields: [API reference › Account & funds](/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/reference/account-and-funds.md#withdraw) · Background: [Funds lifecycle](/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/concepts/funds-lifecycle.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.flash.trade/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/guides/withdraw-funds.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
