> 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/quickstart.md).

# Quickstart

Go from an empty wallet to an open position and back out in one pass. This is the only page that stitches every step together — each endpoint is documented in full under [API reference](/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/reference.md).

**Base URL:** `https://flashapi.trade`

```bash
export FLASH_API_URL="https://flashapi.trade"
export WALLET="<your-wallet-pubkey>"
```

Every builder returns an **unsigned** transaction — you sign client-side and submit to the right RPC:

| Transaction kind                                              | Submit to           |
| ------------------------------------------------------------- | ------------------- |
| Account & funds (`deposit`, `delegate-basket`, `withdraw`, …) | your Solana RPC     |
| Trading (`open-position`, `close-position`, …)                | the v2 RPC endpoint |

See [Signing & submitting](/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/signing-and-submitting.md) for the decode-sign-send code.

## 1. Check the service and read a price

```bash
curl $FLASH_API_URL/health
curl $FLASH_API_URL/prices/SOL
```

## 2. Fund the wallet

`deposit` moves collateral in and bundles any one-time setup (basket, deposit ledger, delegation, trade vault) into the same transaction.

```bash
curl -X POST $FLASH_API_URL/transaction-builder/deposit \
  -H 'Content-Type: application/json' \
  -d '{ "owner": "'$WALLET'", "tokenSymbol": "USDC", "amount": "100.0" }'
```

Sign with the owner, submit to your **Solana RPC**, confirm.

## 3. Delegate (enable trading)

```bash
curl -X POST $FLASH_API_URL/transaction-builder/delegate-basket \
  -H 'Content-Type: application/json' \
  -d '{ "owner": "'$WALLET'", "payer": "'$WALLET'" }'
```

One-time per wallet. Submit to your **Solana RPC**.

## 4. Open a position

```bash
curl -X POST $FLASH_API_URL/transaction-builder/open-position \
  -H 'Content-Type: application/json' \
  -d '{
    "inputTokenSymbol": "USDC",
    "outputTokenSymbol": "SOL",
    "inputAmountUi": "100.0",
    "leverage": 5.0,
    "tradeType": "LONG",
    "owner": "'$WALLET'"
  }'
```

The response carries a quote (entry price, liq price, fees) plus `transactionBase64`. Sign and submit to the **v2 RPC**.

> **Tip:** omit `owner` to get the quote back with `transactionBase64: null` — a free preview before you commit.

## 5. Read your position

Don't reconstruct state from the trade response — read the basket:

```bash
curl $FLASH_API_URL/owner/$WALLET
```

`positionMetrics` gives UI-ready PnL, leverage, and liquidation price keyed by market. For live updates, use the [WebSocket](/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/guides/stream-live-state.md) instead of polling.

## 6. Close

```bash
curl -X POST $FLASH_API_URL/transaction-builder/close-position \
  -H 'Content-Type: application/json' \
  -d '{
    "marketSymbol": "SOL",
    "side": "LONG",
    "inputUsdUi": "500.00",
    "closeAll": true,
    "withdrawTokenSymbol": "USDC",
    "owner": "'$WALLET'"
  }'
```

Submit to the **v2 RPC**.

## 7. Withdraw

```bash
curl -X POST $FLASH_API_URL/transaction-builder/withdraw \
  -H 'Content-Type: application/json' \
  -d '{ "owner": "'$WALLET'", "tokenSymbol": "USDC", "amount": "100.0", "feePayer": "<FEE_PAYER>" }'
```

`feePayer` must differ from `owner`; the client co-signs both. If the response says `custodySettlementRequired`, settle first and retry — see [Withdraw funds](/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/guides/withdraw-funds.md). Submit to your **Solana RPC**.

***

## Next steps

* **Understand the model** → [The Basket model](/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/concepts/basket-model.md) · [Funds lifecycle](/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/concepts/funds-lifecycle.md)
* **Do one task** → [Guides](/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/guides.md)
* **Look up every field** → [API reference](/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/reference.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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.flash.trade/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/quickstart.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
