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

# Add Order

> Send a single new order into the exchange

<div className="api-banner">
  <span className="api-protocol ws">WSS</span>
  <span className="api-detail">ws-auth.kraken.com</span>
  <span className="api-tag">addOrder</span>
</div>

Sends a single, new order into the exchange. A range of order types, Time-In-Force (TIF) and order flags can be specified by the parameters below.

<Tabs>
  <Tab title="Request">
    <ResponseField name="event" type="string" required>
      Value: `addOrder`
    </ResponseField>

    <ResponseField name="ordertype" type="string" required>
      <span className="field-attr">One of:</span> `limit`, `market`, `stop-loss`, `stop-loss-limit`, `take-profit`, `take-profit-limit`, `trailing-stop`, `trailing-stop-limit`, `settle-position`

      The execution model for the order.
    </ResponseField>

    <ResponseField name="type" type="string" required>
      <span className="field-attr">One of:</span> `buy`, `sell`

      Side of the order.
    </ResponseField>

    <ResponseField name="pair" type="string" required>
      <span className="field-attr">Example:</span> `BTC/USD`

      Currency pair.
    </ResponseField>

    <ResponseField name="price" type="string">
      This parameter represents the limit price or trigger price depending on the order type:

      * **limit** price for `limit` orders.
      * **trigger** price for `stop-loss`, `stop-loss-limit`, `take-profit`, `take-profit-limit`, `trailing-stop` and `trailing-stop-limit` orders.

      To specify a relative price, this field can be prefixed by `+`, `-`, or `#` to specify the order price as an offset relative to the last traded price.

      * `+` adds the amount to the last traded price.
      * `-` subtracts the amount from the last traded price.
      * `#` will either add or subtract the amount to the last traded price, depending on the direction.

      Prices can also be suffixed with a `%` to signify the relative amount as a percentage, rather than an absolute price difference in the quote currency. Example, to specify a price as 2% from last price use `"+2%"`.

      Note, trailing stop order types must use a relative price for this field, i.e. `+` to represent the reversion from the peak / trough price.
    </ResponseField>

    <ResponseField name="price2" type="string">
      This parameter represents the **limit** price for `stop-loss-limit`, `take-profit-limit` and `trailing-stop-limit` orders.

      To specify a relative price, this field can be prefixed by `+` or `-` to specify the order price as an offset relative to the market price.

      * `+` adds the amount to the reference price.
      * `-` subtracts the amount from the reference price.

      Prices can also be suffixed with a `%` to signify the relative amount as a percentage, rather than an absolute price difference in the quote currency. Example, to specify a price as 2% from last price use `"+2%"`.

      Note, trailing stop order types must use a relative price for this field, i.e. `+` or `-` to represent the offset from the triggered price.
    </ResponseField>

    <ResponseField name="volume" type="string" required>
      Order volume in base currency.
    </ResponseField>

    <ResponseField name="leverage" type="string">
      <span className="field-attr">One of:</span> `2`, `3`, `4`, `5`

      Funds the order on margin using the amount of leverage specified. The maximum leverage available differs across pairs.
    </ResponseField>

    <ResponseField name="margin" type="boolean">
      <span className="field-attr">One of:</span> `false`, `true`<br />
      <span className="field-attr">Default:</span> `false`

      Funds the order on margin using the maximum leverage for the pair. Note, absolute max leverage is 5.
    </ResponseField>

    <ResponseField name="reduce_only" type="boolean">
      <span className="field-attr">One of:</span> `false`, `true`<br />
      <span className="field-attr">Default:</span> `false`<br />
      <span className="field-attr">Condition:</span> Margin orders only

      If true, order will only reduce a currently open position, not increase it or open a new position.
    </ResponseField>

    <ResponseField name="oflags" type="string">
      <span className="field-attr">One of:</span> `fciq`, `fcib`, `nompp`, `post`, `viqc`

      Comma delimited list of order flags.

      * `fcib`: prefer fee in base currency (default if selling)
      * `fciq`: prefer fee in quote currency (default if buying, mutually exclusive with fcib)
      * `nompp`: no market price protection. DEPRECATED. If supplied, the flag is accepted but ignored
      * `post`: post only order (only on limit orders).
      * `viqc`: volume in quote currency (only available on buy market orders without margin funding).
    </ResponseField>

    <ResponseField name="starttm" type="string">
      Scheduled start time. 0 = now (default) `+n` = schedule start time `n` seconds from now `n` = unix timestamp of start time.
    </ResponseField>

    <ResponseField name="expiretm" type="string">
      Expiration time. 0 = no expiration (default) `+n` = expire `n` seconds from now `n` = unix timestamp of expiration time. GTD orders can have an expiry time up to one month in future.
    </ResponseField>

    <ResponseField name="deadline" type="string">
      <span className="field-attr">Format:</span> RFC3339<br />
      <span className="field-attr">Example:</span> `2022-12-25T09:30:59.123Z`

      Range of valid offsets (from current time) is 500 milliseconds to 60 seconds, default is 5 seconds. The precision of this parameter is to the millisecond. The engine will prevent this order from matching after this time, it provides protection against latency on time sensitive orders.
    </ResponseField>

    <ResponseField name="cl_ord_id" type="string">
      Adds an alphanumeric client order identifier which uniquely identifies an open order for each client. This field is mutually exclusive with `userref` parameter.

      The `cl_ord_id` parameter can be one of the following formats:

      * Long UUID: `6d1b345e-2821-40e2-ad83-4ecb18a06876` 32 hex characters separated with 4 dashes.
      * Short UUID: `da8e4ad59b78481c93e589746b0cf91f` 32 hex characters with no dashes.
      * Free text: `arb-20240509-00010` Free format ascii text up to 18 characters.
    </ResponseField>

    <ResponseField name="userref" type="string">
      <span className="field-attr">Example:</span> `"123456789"`

      This is an optional non-unique, numeric identifier which can be associated with a number of orders by the client. This field is mutually exclusive with `cl_ord_id` parameter.

      Many clients choose a unique integer value generated by their systems (i.e. a timestamp). However, because we don't enforce uniqueness on our side, it can also be used to easily tag a group of orders for querying or cancelling.
    </ResponseField>

    <ResponseField name="sender_sub_id" type="string">
      <span className="field-attr">Condition:</span> For institutional accounts with enhanced Self Trade Prevention (STP)

      Adds an alphanumeric sub-account/trader identifier which enables STP to be performed at a more granular level.

      The `sender_sub_id` parameter can be one of the following formats:

      * Long UUID: `6d1b345e-2821-40e2-ad83-4ecb18a06876` 32 hex characters separated with 4 dashes.
      * Short UUID: `da8e4ad59b78481c93e589746b0cf91f` 32 hex characters with no dashes.
      * Free text: `arb-20240509-00010` Free format ascii text up to 18 characters.
    </ResponseField>

    <ResponseField name="stp_type" type="string">
      <span className="field-attr">One of:</span> `cancel_newest`, `cancel_oldest`, `cancel_both`<br />
      <span className="field-attr">Default:</span> `cancel_newest`

      Self Trade Prevention (STP) is a protection feature to prevent users from inadvertently or deliberately trading against themselves.

      To prevent a self-match, one of the following STP modes can be used to define which order(s) will be expired:

      * `cancel_newest`: arriving order will be canceled.
      * `cancel_oldest`: resting order will be canceled.
      * `cancel_both`: both arriving and resting orders will be canceled.
    </ResponseField>

    <ResponseField name="validate" type="string">
      Validate inputs only; do not submit order.
    </ResponseField>

    <ResponseField name="timeinforce" type="string">
      <span className="field-attr">One of:</span> `GTC`, `GTD`, `IOC`, `FOK`<br />
      <span className="field-attr">Default:</span> `GTC`

      Time-in-force specifies how long an order remains in effect before expiry.

      * `GTC`: Good Till Canceled - until user has cancelled.
      * `GTD`: Good Till Date - until `expiretm` parameter.
      * `IOC`: Immediate Or Cancel - immediately cancels back any quantity that cannot be filled on arrival.
      * `FOK`: Fill Or Kill - immediately fills the full order quantity or cancels it entirely.
    </ResponseField>

    <ResponseField name="close[ordertype]" type="string">
      Order type of the secondary OTO order.
    </ResponseField>

    <ResponseField name="close[price]" type="string">
      `price` of OTO secondary order - see `price` parameter.
    </ResponseField>

    <ResponseField name="close[price2]" type="string">
      `price2` of OTO secondary order - see `price2` parameter.
    </ResponseField>

    <ResponseField name="reqid" type="integer">
      Optional client originated request identifier sent as acknowledgment in the response.
    </ResponseField>

    <ResponseField name="token" type="string" required>
      Session token from the [GetWebSocketsToken](/api-reference/trading/get-websockets-token) REST endpoint.
    </ResponseField>
  </Tab>

  <Tab title="Response">
    <ResponseField name="event" type="string">
      Value: `addOrderStatus`
    </ResponseField>

    <ResponseField name="txid" type="string">
      A Kraken order identifier for the new order.
    </ResponseField>

    <ResponseField name="cl_ord_id" type="string">
      An optional, alphanumeric identifier specified by the client in the `add_order` parameters.
    </ResponseField>

    <ResponseField name="descr" type="string">
      A descriptive summary for the new order.
    </ResponseField>

    <ResponseField name="status" type="string">
      <span className="field-attr">One of:</span> `ok`, `error`
    </ResponseField>

    <ResponseField name="reqid" type="integer">
      Client originated identifier for the request that initiated this response.
    </ResponseField>

    <ResponseField name="errorMessage" type="string">
      Error message for unsuccessful requests.
    </ResponseField>
  </Tab>
</Tabs>

<Panel>
  <CodeGroup>
    ```json Request theme={null}
    {
        "event": "addOrder",
        "ordertype": "limit",
        "pair": "XBT/USD",
        "price": "9000",
        "token": "0000000000000000000000000000000000000000",
        "type": "buy",
        "volume": "10.123"
    }
    ```

    ```json Response theme={null}
    {
        "descr": "buy 0.01770000 XBTUSD @ limit 4000",
        "event": "addOrderStatus",
        "status": "ok",
        "txid": "ONPNXH-KMKMU-F4MR5V"
    }
    ```

    ```json Error theme={null}
    {
        "errorMessage": "EOrder:Order minimum not met",
        "event": "addOrderStatus",
        "status": "error"
    }
    ```
  </CodeGroup>
</Panel>
