> 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/take-profit-and-stop-loss.md).

# Take-profit & stop-loss

Attach and manage TP/SL trigger orders.

Trigger orders close (part of) a position when the price crosses a level. Up to **5 TP + 5 SL** per market + side.

## At open time

Add `takeProfit` / `stopLoss` to the [open-position](/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/guides/open-and-close-positions.md) request — they're appended as trigger orders.

## On an existing position

**One trigger:**

```bash
curl -X POST $FLASH_API_URL/transaction-builder/place-trigger-order -d '{
  "marketSymbol": "SOL", "side": "LONG",
  "triggerPriceUi": "160.00", "sizeAmountUi": "0.5", "isStopLoss": false, "owner": "<WALLET>"
}'
```

`isStopLoss: false` = take-profit, `true` = stop-loss.

**TP and SL atomically:**

```bash
curl -X POST $FLASH_API_URL/transaction-builder/place-tp-sl -d '{
  "marketSymbol": "SOL", "side": "LONG",
  "takeProfitUi": "160.00", "stopLossUi": "140.00", "sizeAmountUi": "0.5", "owner": "<WALLET>"
}'
```

## Edit / cancel

```bash
# Edit replaces BOTH price and size (no keep-existing)
curl -X POST $FLASH_API_URL/transaction-builder/edit-trigger-order -d '{
  "marketSymbol": "SOL", "side": "LONG", "orderId": 0, "isStopLoss": false,
  "triggerPriceUi": "170.00", "sizeAmountUi": "0.5", "owner": "<WALLET>"
}'

# Cancel one (orderId 0–4), or all
curl -X POST $FLASH_API_URL/transaction-builder/cancel-trigger-order -d '{
  "marketSymbol": "SOL", "side": "LONG", "orderId": 0, "isStopLoss": false, "owner": "<WALLET>"
}'
curl -X POST $FLASH_API_URL/transaction-builder/cancel-all-trigger-orders -d '{
  "marketSymbol": "SOL", "side": "LONG", "owner": "<WALLET>"
}'
```

## Check before you place

Preview the PnL of a trigger price (or solve for the price that hits a target PnL/ROI) with [`preview/tp-sl`](/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/guides/preview-fees-and-pnl.md) before committing.

→ Full fields: [API reference › Trading › Trigger orders](/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/reference/trading.md#trigger-orders)


---

# 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/take-profit-and-stop-loss.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.
