# Cancel every resting order on a wallet

`POST https://app.skylit.ai/api/nexus/v1/trading/wallets/{book}/orders/cancel`

API: Nexus.

`"cancelAll": true` cancels everything resting on the wallet, options stops included. `"ticker": "SPY"` cancels only that underlying's. It closes nothing: your positions stay open.

A stock stop that's been set off, or an options stop that's firing, can't be cancelled. They're skipped and listed in `meta.stopsFilling`. `meta.nothingToCancel: true` means nothing was resting.

## Authentication

Send your Skylit API key as a bearer token: `Authorization: Bearer <key>`. No other header is accepted.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `book` | path | string | yes | `main` is your own paper wallet, `agent` is your bot's. (one of `main`, `agent`) |

## Request body

`application/json`

```json
{
  "cancelAll": false,
  "ticker": "string",
  "test": false
}
```

## Example request

```bash
curl "https://app.skylit.ai/api/nexus/v1/trading/wallets/main/orders/cancel" \
  -H "Authorization: Bearer $SKYLIT_API_KEY"
```

## Responses

### 200

What was cancelled. `meta.count` is how many.

One limit buy cancelled.:

```json
{
  "data": {
    "book": "main",
    "cancelled": [
      {
        "id": "5b0e9a6c-3f1d-4c2e-9a7b-1d2e3f4a5b6c",
        "assetClass": "options",
        "source": "api",
        "book": "main",
        "clientOrderId": "spy-dip-0001",
        "ticker": "SPY",
        "strike": 600,
        "direction": "call",
        "expiration": "2026-10-16",
        "side": "buy",
        "positionEffect": "open",
        "quantity": 2,
        "filledQuantity": 0,
        "orderType": "limit",
        "timeInForce": "day",
        "status": "cancelled",
        "limitPrice": 2,
        "reservedCents": 0,
        "placedAt": "2026-10-12T14:31:07Z",
        "expiresAt": "2026-10-12T20:00:00Z"
      }
    ]
  },
  "meta": {
    "book": "main",
    "count": 1
  }
}
```

Nothing on SPY was resting.:

```json
{
  "data": {
    "book": "main",
    "cancelled": []
  },
  "meta": {
    "book": "main",
    "count": 0,
    "nothingToCancel": true
  }
}
```

### 400

The request was refused before anything was traded. Codes: `bad_request`, `bad_contract`, `invalid_quantity`, `invalid_price`, `unsupported_asset_class`, `unsupported_order_type`, `only_market_orders`, `limit_price_required` (a limit with no `limitPrice`), `invalid_limit_price` (not in cents, or outside 0.01 to 99,999.99 for options or 999,999.99 for stocks), `stop_price_required` (a stop with no `stopPrice`), `invalid_stop_price` (not in cents, or outside 0.01 to 999,999.99), `invalid_take_profit`, `test_orders_unavailable`, `test_modify_unavailable`.

A typo in the body.:

```json
{
  "error": {
    "code": "bad_request",
    "message": "Unknown field \"quantitty\". See the trades API docs for the fields you can send."
  }
}
```

### 401

No key, or a key that isn't valid. Codes: `missing_api_key`, `invalid_api_key`.

No key sent.:

```json
{
  "error": {
    "code": "missing_api_key",
    "message": "Send your Skylit API key in the Authorization header: Authorization: Bearer YOUR_SKYLIT_API_KEY."
  }
}
```

### 429

Over a rate limit. Wait `Retry-After` seconds, then retry. Codes: `rate_limited`, and `stream_limit_reached` (too many live streams open: 3 per key, 6 per account).

Headers: `Retry-After`, `X-RateLimit-Limit`, `X-RateLimit-Remaining`.

Too many writes from this key.:

```json
{
  "error": {
    "code": "rate_limited",
    "message": "Too many requests (limit 30). Slow down and retry in 12 seconds."
  }
}
```

### 503

Try again in a moment (honour `Retry-After` when it's sent). Codes: `stale_quote` (the quote, or a stock's last trade, is more than 15 seconds old, so nothing filled), `no_live_price`, `rules_pending`, `unavailable`, `auth_unavailable`, `access_check_unavailable`, `api_keys_unavailable`, `trades_api_disabled`, `stream_unavailable` (the live stream isn't on, or the server is restarting: try again shortly, or poll the reads).

Headers: `Retry-After`.

No live price right now.:

```json
{
  "error": {
    "code": "no_live_price",
    "message": "There's no live price for this contract right now, so nothing was filled. Try again in a moment."
  }
}
```
