> 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

One golden path from an empty wallet to a trade and back to cash.

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