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

# Rate limits

> Price a quoting loop, size batches and connections, and handle REST and WebSocket refusals.

The Order Management System (OMS) and Market Data Service (MDS) have separate request budgets. The tables give the allowances, costs and connection caps production is configured with. They are settings, not protocol rules, and can change.

## Request budgets

| Traffic on one service instance | Units per second |
| - | -: |
| Public priced reads, shared by all callers | 1,000 |
| Authenticated priced requests, shared by all users | 5,000 |
| Ordinary OMS user, or any MDS user including a designated market maker | 500 per user |
| Designated market maker (DMM) on OMS | 2,500 per user, five times the ordinary allowance |

All tokens and sub-accounts for one user share that user's allowance. OMS REST and the control WebSocket draw from it together. A priced user request spends its cost first from the user budget, then from shared authenticated capacity. A user refusal spends no shared units. A shared refusal leaves the user units spent. Priced public reads use the public budget even with a token. Units replenish continuously. A full budget can admit a burst of up to one second’s allowance, provided every applicable budget has enough units.

Your OMS inventory (`GET /inventory/user/{user_id}`) reports DMM status in `is_mm`.

### Read your remaining budget

Priced user REST replies expose `X-RateLimit-Cost` (attempted request units) and `X-RateLimit-Remaining` (whole user units left when the reply is prepared, including refill). Both successful replies and errors after the user check carry them when limiting is enabled. A user-bucket refusal spends nothing; a global-bucket refusal leaves the user charge spent. Remaining capacity belongs to the policy and tier that checked the request, and never reports shared capacity.

Public, operator-signed and unpriced routes, requests refused before the user check, and requests with limiting disabled carry neither header. OMS, MDS and the gateway expose both to browsers. Control WebSocket replies are unchanged. See [API conventions](https://docs.tplus.cx/api-reference/overview.md#rate-limits) for the complete header contract.

### Nonce and login requests

Generating a new nonce and logging in uses two attempts. `POST /auth` and `POST /auth/with-signer` share that counter. Returning a cached nonce uses no attempt, and a failed login can still count. Each service starts a separate window on the first counted attempt from a connecting IP. Workers behind the same proxy can share it.

| Service | Window | Attempts admitted per connecting IP |
| - | - | -: |
| OMS | 1 second | 499 |
| MDS | 30 minutes | 99 |

OMS also counts a correctly formed nonce request for an unknown user. When the IP window is exhausted, counted attempts return `429 RATE_LIMITED` with `error.details.retry_after_ms` and `Retry-After`. Reuse a valid session or honor the retry hint. These IP refusals carry no user-budget usage headers. On a protected MDS read, failed bearer authentication spends the ordinary public price. See [Authentication](https://docs.tplus.cx/api-reference/overview.md#authentication).

## Request costs

| Request | Units |
| - | -: |
| OMS `POST /orders/create`, `PATCH /orders/replace`, `PATCH /orders/amend`. Other priced requests include margin reads, simulations, withdrawals and settlements. | 2 |
| Single cancel, `DELETE /orders/cancel` | 1 |
| Cancel-all, `DELETE /orders/cancel-all` or `DELETE /orders/cancel-all/{asset_id}` | 50 |
| `POST /orders/batch-create`, `PATCH /orders/batch-replace`, `PATCH /orders/batch-amend`, `DELETE /orders/cancel-batch` | Multiply the **submitted** item count by 1.5, round up once, then take at least 2 |
| OMS public market lists and details, asset details, funding-rate and registry reads | 2 |
| MDS public depth, candlesticks, trades, tickers and open interest | 2 |
| MDS authenticated position-basis or sub-account name snapshot | 2 |
| MDS REST user trade history (`GET /trades/user/{user_id}`, optionally by market) | 25 per page |
| OMS order lists (`GET /orders/user/{user_id}`, optionally by market), order lookups, inventory and position reads, close-all preview, and `GET /market/{id}/ready` | 0 |

The control WebSocket charges the same prices for order actions. Through the gateway, REST user trade history goes to MDS and user order lists go to OMS.

### Reverted matches

When the clearing engine reverts a match because your order failed one of its checks on the order or on your account, for example the margin check, the trade reports `Rollbacked` with the reason for your order, and OMS refuses your priced requests with `429 RATE_LIMITED` for a while. The block spends no units, yours or shared. Each refusal carries the time left in the block, in `error.details.retry_after_ms` and `Retry-After` on REST, and in the control socket's retry delay.

| | First block | Each later block | Longest block |
| - | -: | -: | -: |
| User | 10 s | 10 s longer | 120 s |
| DMM | 5 s | 5 s longer | 60 s |

The first such revert blocks you for the first duration. A revert while you are blocked does not lengthen the block. A revert after a block has ended starts a longer one: 10, 20, 30 seconds and so on for a user, up to the longest. After 600 seconds without such a revert, counting the ones while you were blocked, the next block is the first duration again.

These reasons block you:

| Reason | Your order |
| - | - |
| `MarginCheckFailed` | Left your account failing its margin check |
| `RiskIncreaseForbidden` | Added risk on a sub-account that may only reduce it |
| `InvalidInventory` | Traded on a sub-account that does not exist or cannot take the trade |
| `WrongAccountType` | Traded on an account of the wrong type for the market |
| `WrongSignature` | Carried a signature the clearing engine rejected |
| `NotReduceOnly` | Was reduce-only and would have opened or grown a position |

You are not blocked for any other reason: when the counterparty's order was at fault, when the oracle price was missing, stale or out of bounds (`PricingIssue`), when a cap shared by the whole venue was reached (`BreachTotalOiCap`, `BreachSpotMarginOiCap`, `BreachCollateralCap`), when the clearing engine refused the match as a whole because it reached clearing too late (`InvalidRelativeTime`) or its orders could not trade with each other (`InvalidOrderConditions`), or when the clearing engine could not process the match (`ProcessingError`). You are not blocked either for a liquidation or auto-deleveraging order placed on your account.

### Budget a quoting loop

Suppose one OMS user refreshes nine resting quotes with `PATCH /orders/batch-replace` and separately cancels one order each cycle. The batch costs **14** units (9 × 1.5 rounded up). The single cancel brings the cycle to **15**. At 30 cycles per second, plan for **450 units/s** from both the user and shared authenticated budgets. That leaves 50 units/s of ordinary user capacity or 2,050 for a DMM. Those 30 cycles can fit in a single burst only if both budgets have 450 units available. Space out refreshes to leave room for urgent cancels. Other users can consume the shared capacity even while your own budget has room.

## Connections and streams

| Connection | Concurrent limit | At capacity |
| - | - | - |
| Authenticated OMS WebSockets, including control and order events | 10 per user, 20 per DMM across all streams | Direct OMS refuses the upgrade with HTTP `429 RATE_LIMITED`, `error.retryable: true` and `error.details.max_ws_streams`. Close an unused stream. |
| Public MDS WebSockets, across all markets and stream types | 1,000 per instance | Direct MDS returns HTTP `503 SERVICE_UNAVAILABLE`, `error.retryable: true`, with the message `public WebSocket connection limit reached`. Back off before reconnecting. |
| TLS connections accepted by the gateway | 10,000 per listener | New connections wait for acceptance. |

WebSocket upgrades take a slot independently of the request budget. Closing the stream frees it. Lowering the OMS cap affects new connections. Pings and incoming feed updates cost no request units.

**Through the gateway**, a stream-cap refusal preserves the final HTTP status (`429` for OMS or `503` for MDS) but replaces the service body with `{"error":"upstream websocket handshake failed"}`. A gateway `503` alone cannot identify a full MDS stream pool. Back off before reconnecting. Neither stream-cap refusal gives a retry time. For a connection that closes with `1013` and `resync_required`, follow [Lag and resync](https://docs.tplus.cx/api-reference/websockets.md#lag-and-resync).

## Request and batch sizes

| Request | Fixed limit |
| - | - |
| REST login or signer login on either service, and OMS logout | 16 KiB per body |
| Ordinary REST action | 256 KiB per body |
| OMS batch create, replace, amend or cancel by ID over REST | 512 KiB per body |
| Any HTTP body through the gateway | 8 MiB outer limit, with smaller limits on individual routes |
| Batch create, replace or amend over REST or control | 50 items per request |
| Cancel by explicit ID list | No separate item-count cap. The unit cost and, on REST, the byte limit still apply. |

Shrink a body rejected by the service with HTTP `400 INVALID_REQUEST` for excess size or by the gateway with HTTP `413`. Split a batch that reaches the item check and gets `400 BATCH_TOO_LARGE` on REST or `BATCH_TOO_LARGE` on control v1. Control v0 returns a raw request error, for example `{"request":{"status":"error","error":"Maximum 50 amends per batch"}}`. REST checks body size before pricing. On both transports the unit check precedes the item-count check. If a batch costs more than a full user or shared budget, split it before retrying. For example, 334 cancel IDs cost 501 units, more than the ordinary user's 500-unit budget. See [Managing orders](https://docs.tplus.cx/trading/orders.md#managing-orders).

A position-basis read can also be too large. MDS allows 100,000 history rows per calculation. If it returns `422 BASIS_REPLAY_LIMIT_EXCEEDED`, compare `error.details.minimum_rows` with `error.details.max_rows` and narrow the query by asset or sub-account.

## When to retry

| Refusal | Client action |
| - | - |
| REST `429` with `error.code: RATE_LIMITED` and `error.retryable: true` | For a request-budget, sign-in window or [reverted-match](#reverted-matches) refusal, honor `error.details.retry_after_ms` (rounded up milliseconds) or `Retry-After` (rounded up seconds, at least 1). Neither is sent for an oversized cost or a stream cap. OMS can identify a user refusal as `{"error":{"code":"RATE_LIMITED","message":"Rate limit exceeded for this user","retryable":true}}`. Shared OMS and both MDS budgets use `Rate limit exceeded`. |
| Open OMS control socket, v1 | Match the error frame below by `request_id` (null if omitted). Use `error.details.retry_after_ms` when present. Keep the socket open and pace the next send; an oversized cost has no wait and must be split. |
| Open OMS control socket, v0 | The raw reply includes `retry_after_ms`, for example `{"error":"rate_limited","retryable":true,"retry_after_ms":4}`. An oversized cost has no wait and must be split. |
| OMS overload, `503 SERVER_BUSY` on REST | Honor `error.details.retry_after_ms`. Service-wide overload also sends `Retry-After` in whole seconds. Control v1 carries the delay in `error.details.retry_after_ms`, v0 in `retry_after_ms`. |

A v1 control refusal for a request tagged `req_123` can look like this.

```json theme={"dark"}
{
  "type": "error",
  "channel": "control",
  "request_id": "req_123",
  "timestamp_ns": 1710000000000000000,
  "data": null,
  "error": {"code": "RATE_LIMITED", "message": "Rate limit exceeded for this user", "retryable": true, "details": {"retry_after_ms": 4}}
}
```

See [WebSocket protocols](https://docs.tplus.cx/api-reference/websockets.md#connecting) for version selection and [API errors](https://docs.tplus.cx/api-reference/overview.md#errors) for the REST envelope.


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