> ## 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.

# Place a market order

> Open a position immediately at the current market price. Set the size in USD.

## Body

Content type: `application/json`

<ParamField body="symbol" type="string" required>
  Trading symbol, for example XAUUSD, EURUSD, or AAPL.
</ParamField>

<ParamField body="side" type="enum<string>" required>
  Trade direction. Use 'buy' to go long, 'sell' to go short.

  Available options: `buy`, `sell`
</ParamField>

<ParamField body="amount" type="number" required>
  Trade size in account currency (USD). For example, 1000 means \$1,000 worth of the instrument.

  Minimum: `0`
</ParamField>

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

  Minimum: `0`
</ParamField>

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

  Minimum: `0`
</ParamField>

<ParamField body="comment" type="string">
  Optional comment or note for the order.
</ParamField>

## Response

`200` Success.

<ResponseField name="success" type="boolean" />

<ResponseField name="orderId" type="string" />

<ResponseField name="err" type="string" />

<ResponseField name="message" type="string" />

## 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 POST \
    --url 'https://gateway.amana.io/trading/positions/market' \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
    "symbol": "<string>",
    "side": "buy",
    "amount": 123.45,
    "sl": 123.45,
    "tp": 123.45,
    "comment": "<string>"
  }'
  ```

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

  url = "https://gateway.amana.io/trading/positions/market"
  headers = {"Authorization": "Bearer <token>", "Content-Type": "application/json"}
  payload = {
      "symbol": "<string>",
      "side": "buy",
      "amount": 123.45,
      "sl": 123.45,
      "tp": 123.45,
      "comment": "<string>"
  }

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

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

<ResponseExample>
  ```json 200 theme={null}
  {
    "success": true,
    "orderId": "<string>",
    "err": "<string>",
    "message": "<string>"
  }
  ```

  ```json 400 theme={null}
  {
    "success": true,
    "orderId": "<string>",
    "err": "<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}
  {}
  ```
</ResponseExample>


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