> For the complete documentation index, see [llms.txt](https://docs.anchored.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.anchored.finance/trading-api/trading/place-and-cancel-orders.md).

# Place & Cancel Orders

## Build order calldata

```
POST /api/v1/orders/calldata
```

| Field          | Type            | Required    | Description                                                 |
| -------------- | --------------- | ----------- | ----------------------------------------------------------- |
| `stockAddress` | string          | Yes         | Stock token address (EVM).                                  |
| `side`         | string          | Yes         | `Buy` or `Sell`.                                            |
| `type`         | string          | Yes         | `Market` or `Limit`.                                        |
| `quantity`     | string / number | Conditional | Limit orders; market sells.                                 |
| `notional`     | string / number | Conditional | Market buys.                                                |
| `price`        | string / number | Conditional | Limit orders.                                               |
| `timeInForce`  | string          | Conditional | Limit orders. See [enums](/trading-api/reference/enums.md). |
| `deadline`     | number          | Yes         | Tx deadline (Unix seconds).                                 |

### Market buy

```json
{
  "stockAddress": "0x0000000000000000000000000000000000000001",
  "side": "Buy",
  "type": "Market",
  "notional": "10",
  "deadline": 1893456000
}
```

### Limit sell

```json
{
  "stockAddress": "0x0000000000000000000000000000000000000001",
  "side": "Sell",
  "type": "Limit",
  "quantity": "1.25",
  "price": "180.50",
  "timeInForce": "DAY",
  "deadline": 1893456000
}
```

Response `data`:

| Field         | Type   | Description                              |
| ------------- | ------ | ---------------------------------------- |
| `chainId`     | number | Chain ID.                                |
| `productType` | string | Product type.                            |
| `toAddress`   | string | Router address.                          |
| `value`       | string | Native value (`"0"`).                    |
| `callData`    | string | Encoded calldata.                        |
| `method`      | string | `placeMarketOrder` or `placeLimitOrder`. |

Submit `toAddress` + `callData` on-chain, then record via [order-status-and-history.md](/trading-api/trading/order-status-and-history.md).

## One Click place order

```
POST /api/v1/orders/send
```

Same body as `/calldata`, plus optional `gasLimit`. Requires One Click enabled and API key `userAddress` configured.

## Build Order-With-Deposit Calldata

```
POST /api/v1/orders/with-deposit/calldata
```

Use this endpoint when the order transaction should also use `StockRouter` as the approved spender before placing the order. For buys, `StockRouter` transfers the cash token to `Cashier`; for sells, it transfers the stock token to `Stock`.

| Field                 | Type            | Required    | Description                                                                                                |
| --------------------- | --------------- | ----------- | ---------------------------------------------------------------------------------------------------------- |
| `stockAddress`        | string          | Yes         | Stock token address.                                                                                       |
| `depositAmount`       | string / number | Yes         | Human-readable deposit amount. For buys, this is cash token amount. For sells, this is stock token amount. |
| `depositTokenAddress` | string          | Conditional | Cash token address. Required for buy orders.                                                               |
| `side`                | string          | Yes         | `Buy` or `Sell`.                                                                                           |
| `type`                | string          | Yes         | `Market` or `Limit`.                                                                                       |
| `quantity`            | string / number | Conditional | Limit orders; market sells.                                                                                |
| `notional`            | string / number | Conditional | Market buys.                                                                                               |
| `price`               | string / number | Conditional | Limit orders.                                                                                              |
| `timeInForce`         | string          | Conditional | Limit orders.                                                                                              |
| `deadline`            | number          | Yes         | Tx deadline (Unix seconds).                                                                                |

For buy orders, the cash token must be approved for `StockRouter`, and the cash deposit must be eligible for instant deposit; otherwise the combined transaction reverts. For sell orders, the wallet stock token must be approved for `StockRouter`.

### Market buy with deposit

```json
{
  "stockAddress": "0x0000000000000000000000000000000000000001",
  "depositTokenAddress": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
  "depositAmount": "100",
  "side": "Buy",
  "type": "Market",
  "notional": "10",
  "deadline": 1893456000
}
```

### Market sell with stock deposit

```json
{
  "stockAddress": "0x0000000000000000000000000000000000000001",
  "depositAmount": "1.25",
  "side": "Sell",
  "type": "Market",
  "quantity": "1.25",
  "deadline": 1893456000
}
```

## One Click Order With Deposit

```
POST /api/v1/orders/with-deposit/send
```

Same body as `/with-deposit/calldata`, plus optional `gasLimit`. Requires One Click enabled and API key `userAddress` configured.

## Cancel limit order

### Self-submit cancel calldata

```
DELETE /api/v1/orders/{orderId}/calldata?deadline=1893456000
```

> `orderId` must be bytes32 hex (64 characters, no `0x` prefix in path per server convention — verify against your integration).

### One Click cancel

```
DELETE /api/v1/orders/{orderId}/send?deadline=1893456000
```

Returns `uuid` and `txHash`.

### Cancel rules

* Order belongs to current API key
* Order is open
* Limit orders only
* No pending cancel in flight
* API key `userAddress` matches order user


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.anchored.finance/trading-api/trading/place-and-cancel-orders.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
