> ## Documentation Index
> Fetch the complete documentation index at: https://readme.amana-dev.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Update stop loss or take profit

> Change the stop loss or take profit on an open position.

## Path parameters

<ParamField path="id" type="string" required>
  Unique identifier of the position or order to act on.
</ParamField>

## Body

Content type: `application/json`

<ParamField body="sl" type="number">
  Optional stop loss price. The position will automatically close if the market reaches this level.

  Minimum: `0`
</ParamField>

<ParamField body="tp" type="number">
  Optional take profit price. The position will automatically close in profit if the market reaches this level.

  Minimum: `0`
</ParamField>

<ParamField body="slAmount" type="number">
  Optional (c2c only) stop loss amount. The position will automatically close if pnl reach that much

  Minimum: `0`
</ParamField>

<ParamField body="tpAmount" type="number">
  Optional (c2c only) take profit amount. The position will automatically close if pnl reach that much

  Minimum: `0`
</ParamField>

## Response

`200` Success.

## Possible Errors

| Error | Possible cause | What to do |
| - | - | - |
| 400 | Invalid or missing field, amount outside limits | Check the request against the schema and the instrument's size limits. |
| 401 | Token missing or expired | Log in again or use the refresh token. |
| 403 | IP not whitelisted, or account restricted | Confirm your IP is whitelisted; otherwise contact Amana. |
| 409 / 422 | Market closed, insufficient balance or margin | Check trading hours and balance, then retry. |
| 429 / 5xx | Rate limit, or temporary issue on our side | Retry with backoff; contact support if it persists. |

<RequestExample>
  ```bash cURL theme={null}
  curl --request PUT \
    --url 'https://gateway.amana.io/trading/positions/{id}' \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
    "sl": 123.45,
    "tp": 123.45,
    "slAmount": 123.45,
    "tpAmount": 123.45
  }'
  ```

  ```python Python theme={null}
  import requests

  url = "https://gateway.amana.io/trading/positions/{id}"
  headers = {"Authorization": "Bearer <token>", "Content-Type": "application/json"}
  payload = {
      "sl": 123.45,
      "tp": 123.45,
      "slAmount": 123.45,
      "tpAmount": 123.45
  }

  response = requests.request("PUT", url, json=payload, headers=headers)
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://gateway.amana.io/trading/positions/{id}', {
    method: 'PUT',
    headers: {"Authorization": "Bearer <token>", "Content-Type": "application/json"},
    body: JSON.stringify({"sl": 123.45, "tp": 123.45, "slAmount": 123.45, "tpAmount": 123.45}),
  });
  console.log(await response.json());
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {}
  ```

  ```json 400 theme={null}
  {
    "error": "<string>",
    "message": "<string>"
  }
  ```

  ```json 401 theme={null}
  {
    "error": "<string>",
    "message": "<string>"
  }
  ```

  ```json 403 theme={null}
  {
    "error": "<string>",
    "message": "<string>"
  }
  ```

  ```json 409 theme={null}
  {
    "error": "<string>",
    "message": "<string>"
  }
  ```

  ```json 422 theme={null}
  {
    "error": "<string>",
    "message": "<string>"
  }
  ```

  ```json 429 theme={null}
  {
    "error": "<string>",
    "message": "<string>"
  }
  ```

  ```json 500 theme={null}
  {
    "error": "<string>",
    "message": "<string>"
  }
  ```
</ResponseExample>


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