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

# Transfers

> Move cash between your account's Polymarket, Hyperliquid and Lighter balances.

A transfer moves cash from one of your account's venues to another. A live key moves it between
Polymarket, Hyperliquid and Lighter, in any direction. A test key moves simulated cash between
Polymarket and Hyperliquid. The cash always lands in your own account's balance on the other
venue. A transfer can't send funds to any other address or account.

A transfer takes three calls:

1. `POST /v1/transfers/quote` shows the fee, what arrives, the minimum and what you can send.
2. `POST /v1/transfers` creates the transfer.
3. `POST /v1/transfers/{id}/execute` authorizes it. Lean then moves the cash.

Creating and executing need a key with the `trade` and `route` scopes. Quoting and reading need
`read`. See [Authentication](https://docs.lean.xyz/authentication.md#create-a-key).

**1. Quote the transfer**

```bash theme={"dark"}
curl -sS -X POST "$LEAN_API_URL/v1/transfers/quote" \
  -H "Authorization: Bearer $LEAN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "from_venue": "polymarket", "to_venue": "hyperliquid", "amount_usd": "25" }'
```

| Field | Meaning |
| - | - |
| `amount_usd` | What leaves `from_venue`. |
| `fee_usd` | What the move costs. It comes out of `amount_usd`. |
| `receive_usd` | What arrives on `to_venue`: `amount_usd` minus `fee_usd`. |
| `minimum_usd` | The smallest `amount_usd` this route accepts. |
| `available_usd` | What `from_venue` can send right now. |
| `estimated_seconds` | How long the move usually takes once authorized. |
| `expires_at` | Until when a transfer created now can be authorized. |
| `warnings` | Why creating this transfer would be refused: `BELOW_VENUE_MINIMUM` under `minimum_usd`, `INSUFFICIENT_FUNDS` over `available_usd`. Empty means the amount fits the route; creating the transfer can still be refused under the key's notional limits, allowed venues or a placement block. |

A quote never moves cash, and it answers even when the amount is below the minimum or above
what is available, so you can show the numbers before you ask. Check `warnings` before you
create the transfer.

**2. Create the transfer**

```bash theme={"dark"}
curl -sS -X POST "$LEAN_API_URL/v1/transfers" \
  -H "Authorization: Bearer $LEAN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "client_transfer_id": "rebalance-2026-11-11-0001",
    "from_venue": "polymarket",
    "to_venue": "hyperliquid",
    "amount_usd": "25"
  }'
```

`client_transfer_id` is your ID for the transfer. Sending the same body again returns the same
transfer, so a retry never moves cash twice. The same ID with a different body is
`409 CONFLICT`, and `details.transfer_id` names the original.

The transfer starts as `awaiting_authorization`. A test transfer returns what to sign in
`authorization`:

| Field | Meaning |
| - | - |
| `authorization.signer_address` | The wallet that must sign: the account owner's. |
| `authorization.expires_at` | Sign and execute before this time. |
| `authorization.payloads` | The EIP-712 messages to sign, in order. Each has a `scheme` and `typed_data`. |

A live transfer has nothing for you to sign, so its `authorization` is `null`. See
[Live transfers](#live-transfers).

**3. Execute the transfer**

For a test transfer, sign each `typed_data` exactly as returned, then send the signatures in
the same order:

```bash theme={"dark"}
curl -sS -X POST "$LEAN_API_URL/v1/transfers/$TRANSFER_ID/execute" \
  -H "Authorization: Bearer $LEAN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "authorization": "signature", "signatures": ["0x…"] }'
```

If the account has enabled trading in the Lean app, send `{ "authorization": "delegated" }`
instead and Lean signs with the account's delegated signer. A live transfer takes
`delegated` only.

The transfer moves to `pending`, then `completed` once the cash arrives. Sending the same
request again returns the transfer and moves nothing.

## Live transfers

A live transfer moves real cash through [Relay](https://relay.link). Lean signs every step with
the account's delegated signer, so the account must have enabled trading in the Lean app.

* `fee_usd` on the quote is Relay's price at that moment, plus any fee the sending venue charges.
  Creating the transfer prices the route again, and the transfer keeps that fee.
* The minimum is 2 USD. Relay may ask for more on some routes, and the quote then warns
  `BELOW_VENUE_MINIMUM`.
* An account moves one transfer at a time. While another live transfer is open, or a Hyperliquid
  withdrawal or a transfer started in the Lean app is in progress, creating a live transfer is
  refused with `409 CONFLICT`. A transfer you created and have not executed counts as open until
  it is executed or expires. Test keys can hold several open transfers at once, so a client that
  opens transfers in parallel in test mode should still expect this `409` live.
* A live transfer does not hold `amount_usd` on `from_venue`. If the venue no longer has it when
  you execute, the transfer fails and nothing moves.
* Each read of a `pending` transfer checks Relay and the venues, and the status follows the cash.
  If a step fails after the cash left, Relay refunds it to `from_venue` and `failure_reason`
  says so. If the cash has left `from_venue` but has neither arrived nor been refunded, the
  transfer stays `pending` and `failure_reason` says so.
* `GET /v1/balances` and `GET /v1/positions` cover Kalshi, Polymarket, Polymarket US and
  Hyperliquid. Cash moved to Lighter and Lighter positions don't appear there; check them in the
  Lean app.

## Follow a transfer

`GET /v1/transfers/{id}` returns one transfer. `GET /v1/transfers` lists the key's account's
transfers, newest first. Pass `limit` (1 to 100) and the `next_cursor` from the previous page as
`cursor` to read further back.

| Status | Meaning |
| - | - |
| `awaiting_authorization` | Created and not yet executed. A test transfer holds the amount on `from_venue` until then. |
| `pending` | Authorized. The cash is on its way. |
| `completed` | The cash arrived on `to_venue`. |
| `failed` | The move did not happen, or Relay refunded it. `failure_reason` says why. |
| `expired` | Not executed in time. Nothing moved. |

## Limits and refusals

A transfer counts against the per order and daily limits of the key and its account like an
order, and a paused key or trading account can't create or execute one. A quote still answers
while paused. Executing checks the limits and allowed venues again, so a limit lowered or a venue
removed after the transfer was created is refused with 422 and nothing moves. Only the key that
created a transfer can execute it; any other key gets 404.

| Response | `details.reason` | When |
| - | - | - |
| `400 VALIDATION_ERROR` | | The venues are the same, a venue is unknown, a test key names `lighter`, a venue is not connected, the amount is malformed, or the body has a field a transfer does not take. |
| `422 VALIDATION_ERROR` | `BELOW_VENUE_MINIMUM` | `amount_usd` is below the route minimum. `details.minimum_usd` is the minimum. |
| `422 VALIDATION_ERROR` | `INSUFFICIENT_FUNDS` | `from_venue` can't send `amount_usd`. `details.available_usd` is what it can send. |
| `422 VALIDATION_ERROR` | `VENUE_NOT_ALLOWED` | The trading account does not allow one of the two venues. `details.allowed_venues` lists the ones it allows. |
| `422 VALIDATION_ERROR` | `ORDER_NOTIONAL_LIMIT`, `DAILY_NOTIONAL_LIMIT` | The amount is over the key's or account's limits. |
| `400 VALIDATION_ERROR` | `SIGNER_MISMATCH`, `INVALID_SIGNATURE` | A signature is not the owner's over the payload Lean returned, or a live transfer was sent signatures. |
| `403 FORBIDDEN` | `ACCOUNT_NOT_DELEGATED` | A live key, or `delegated` was sent, and the account has not enabled trading in the Lean app. |
| `409 CONFLICT` | | Another transfer on the account is open or in progress, from the API or the Lean app, including a Hyperliquid withdrawal. |
| `409 CONFLICT` | `PAYMENT_ALREADY_AUTHORIZED` | The transfer was already authorized another way. |
| `409 CONFLICT` | `QUOTE_EXPIRED` | The transfer expired before it was executed. Create a new one. |
| `503 FEATURE_DISABLED` | `TRADING_PAUSED`, `LIVE_TRADING_DISABLED` | The key or its trading account is paused, or Lean has halted live trading. |
| `503 UPSTREAM_ERROR` | | Relay or a venue could not price or prepare the route. Nothing was sent. |

## In test mode

A test transfer moves simulated cash between the test balances. It costs a flat 0.10 USD, its minimum
is 2 USD. Executing answers `pending`, and the next read or list shows it `completed`. [Reset test mode](https://docs.lean.xyz/api-reference/test-mode/reset-test-mode.md)
deletes the account's test transfers along with its test orders.


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