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

# Conventions, errors and limits

> The request format, paging, retries, error codes and rate limits shared by every Hypernova API endpoint.

## Requests

| | |
| - | - |
| **Method** | HTTPS POST to `https://hypernova.xyz/api/v1/<Endpoint>`, with a JSON object as the body. Send `{}` when there is nothing to pass: an empty body answers `invalid_argument`. |
| **Content type** | `application/json` only. [StreamAccountEvents](https://hypernova.xyz/docs/api/streaming.md) is the one exception and has its own framing. The body must be uncompressed: `Content-Encoding: identity` is accepted, any real encoding answers `unimplemented`. |
| **Body size** | At most 1 MiB. |
| **Field names** | Lower camel case: `accountId`, `startingBalance`. A field the endpoint does not define answers `invalid_argument`, so a typo cannot pass as a default. |
| **Decimals** | Quantities, prices, leverages and `maxSlippageBps` are decimal strings, never floats: `"0.25"`, `"5"`. At most 256 bytes; an order's size and every price on it must be below 1,000,000,000,000. |
| **Integers** | `limit`, `offset` and `maxLeverage` are JSON numbers. A request may also send `limit` or `offset` as a quoted string. |
| **Timestamps** | RFC 3339 in UTC, with a fraction of up to nine digits when the value has one: `"2026-10-15T06:30:00.123456Z"`. |
| **Enumerations** | Upper-case names, such as `"ORDER_SIDE_BUY"`. See [Enumerations](https://hypernova.xyz/docs/api/enumerations.md). |
| **Symbols** | Exactly as [ListMarkets](https://hypernova.xyz/docs/api/accounts.md#listmarkets) lists them, because symbols are case-sensitive: `kPEPE`, not `KPEPE`. A `symbol` filter that names no market answers `invalid_argument`. |
| **Missing values** | An optional field with no value is left out, and so is a timestamp or nested object that has none, such as `filledAt` or `balance`. Every other field is always present, at `""`, `0`, `false` or its `_UNSPECIFIED` name when unset, and an empty list is `[]`. A figure that cannot be computed is left out, never sent as zero. |
| **Changes** | Within v1, fields and enum values are only added, never removed or renamed. Ignore fields you do not know, and treat an unknown enum name as unspecified. |
| **Timeout** | The server gives every call ten seconds; a slower call answers `deadline_exceeded`. [StreamAccountEvents](https://hypernova.xyz/docs/api/streaming.md) is the exception: an open stream has no time limit of this kind, so never put a ten-second timeout on it. Time a stream by its [45-second silence rule](https://hypernova.xyz/docs/api/streaming.md#reconnecting). |
| **Connections** | Reuse one HTTPS connection, with keep-alive or HTTP/2, rather than one per call: most of a call's time is the network, and a new connection adds TCP and TLS handshakes. |
| **Browsers** | Server to server only. There is no CORS support. |

## Paging

ListOrderHistory, ListTrades and ListFundingPayments take a `window`, `limit` and `offset`:

* `window.from` is inclusive and `window.to` exclusive. Either may be left out, and a `to` before `from` answers `invalid_argument`.
* No `limit`, or `0`, means 50; above 200 is clamped to 200. A negative `limit` or `offset` answers `invalid_argument`.
* `hasMore` says a further page exists: request it at `offset` plus the number of rows returned.
* On ListTrades and ListFundingPayments `hasMore` is worked out just before the page is read, so a row recorded in between can leave a full page saying `false` with a row still behind it. Where no row may be missed, as when reconciling fills, fetch the next page after every full page and stop at the first short one.
* Pin `window.to` while paging, so a row recorded after it cannot shift later offsets. A row recorded late inside the window still can, so de-duplicate on each row's id.

## Retries

* Every read, CancelOrder, CancelAllOrders and SetLeverage are safe to retry.
* PlaceOrder is safe to retry **with the `clientOrderId` the first attempt carried**: a retry answers the first order instead of placing another.
* ClosePosition never closes twice: a retry with the first `clientOrderId` replays the first close, and one without closes whatever is left.
* CloseAllPositions is a new flatten on every call, closing whatever is still open.

## Errors

A call that reaches an endpoint and fails answers with a non-200 status and a JSON body, `{ "code": "failed_precondition", "message": "order is not open" }`.
Switch on `code`, not on the HTTP status: two codes share 400, and `resource_exhausted` comes with 429 or 413.
[StreamAccountEvents](https://hypernova.xyz/docs/api/streaming.md#stream-errors) answers HTTP 200 and reports an error in its last frame instead.

| `code` | HTTP | When | What to do |
| - | - | - | - |
| `invalid_argument` | 400 | A malformed request: a bad id, a negative page, an inverted window, an unknown field or symbol, an empty body. | Fix the request; the message says which. |
| `failed_precondition` | 400 | The order cannot be placed or cancelled as asked, a position cannot be closed as asked, a `clientOrderId` was reused for a different order, or a leverage change needs more margin than is free. | Read the message and the [error kind](#error-kinds); don't retry as is. |
| `unauthenticated` | 401 | No key, a malformed or unknown key, or a key that was revoked or switched off. Once the API is fully live, also a key whose owner has never held an Assessment or funded account, kind `ACCOUNT_REQUIRED`. | Check the key in Settings. With `ACCOUNT_REQUIRED` the key is fine, so do not replace it. |
| `permission_denied` | 403 | A read key on a write endpoint. Once the API is fully live, also a call that names a demo account, kind `DEMO_VIA_API_KEY`. | Use a write key. With `DEMO_VIA_API_KEY` the key is fine: name an Assessment or funded account, or use the test environment. |
| `not_found` | 404 | The account or order does not exist for your user. | Check the id. |
| `already_exists` | 409 | The `clientOrderId` already names an order on another account. | Mint a new one. |
| `resource_exhausted` | 429 | Over the rate limit, with `Retry-After` in seconds. | Wait, then retry. See [Rate limits](#rate-limits). |
| `resource_exhausted` | 413 or 429 | A body over 1 MiB, with no `Retry-After`: 413 when the request carried a `Content-Length`, 429 when it did not. | Send a smaller body; no retry fixes it. |
| `internal` | 500 | A fault on our side. A placement may still have gone through. | Retry later. If it persists, send us the request id. |
| `unimplemented` | 501 | A `Content-Encoding` other than `identity`. | Send the body uncompressed. |
| `unavailable` | 503 | A dependency of ours is unreachable. | Retry with backoff. |
| `deadline_exceeded` | 504 | The call took longer than ten seconds. A placement may still have gone through. | Retry a read or a cancel, or a placement with its first `clientOrderId`. |

Messages are generic except for `invalid_argument`, `failed_precondition` and `resource_exhausted`, which name the cause.
An error from an endpoint carries an `X-Request-Id` header: if a failed call needs our help, send it in the [Hypernova Discord](https://discord.gg/PBvZbvRTrN).

### Error kinds

Some refusals name their case in an `X-Hn-Error-Kind` header, so a bot can branch without parsing the message.
No other response carries the header; treat a kind you do not know as its `code` alone.
The stream has kinds of its own, listed under [Stream errors](https://hypernova.xyz/docs/api/streaming.md#stream-errors), and carries them in its last frame.

| Kind | When | What to do |
| - | - | - |
| `TOO_MANY_OPEN_ORDERS` | PlaceOrder hit one of the two [caps on resting orders](https://hypernova.xyz/docs/api/place-order.md#limits): the one on orders that open or add to a position, or the one on reduce-only orders, take-profits and stop-losses. | The message says which: it begins `too many open orders` for the first and `too many open exit orders` for the second, and gives the number to cancel. Cancel from that group, or wait for one of it to fill. |
| `ORDER_ALREADY_FILLED` | CancelOrder named an order that has filled. | A lost race: read the position and decide from there. |
| `POSITION_ALREADY_CLOSED` | An exit named a position that has already closed. | Treat the close as done. |
| `REDUCE_ONLY_NO_CAPACITY` | A reduce-only exit would lie wholly beyond the size its ladder covers. | Read the position's exits in ListOpenOrders before sizing another. |
| `ACCOUNT_REQUIRED` | With `unauthenticated`: the key's owner has never held an Assessment or funded account. | The key is fine and works once its owner holds either, so do not replace it. |
| `DEMO_VIA_API_KEY` | With `permission_denied`: the call named a demo account, which no key reaches once the API is fully live. | Name an Assessment or funded account, or use the test environment. |

### Refusals that carry no error body

| Condition | Answer |
| - | - |
| A method other than POST, or a path that is not an endpoint | The gateway's bare 404 `{"message":"Not Found"}`, with no `code` and no request id |
| An OPTIONS request | 204 at the edge |
| A content type other than `application/json` | 415 with a plain-text body |
| A request from a restricted country, or from a Tor node, proxy or other anonymising service | 403 with an HTML page |
| A path with a doubled or trailing slash, a segment not starting with a letter or digit, a percent-encoded character, or punctuation other than `.`, `_` and `-` | 403 with an HTML page |
| The gateway's own throttle, when many partners burst at once | **A bare 429 with no `code` and no `Retry-After`** |

> [!WARNING]
>
> A client that reads `Retry-After` blindly will crash on the gateway's bare 429. Back off and retry on any 429 you can't parse.

## Rate limits

Limits apply **per user**, shared across all of that user's keys, as a sustained rate with a burst allowance.

| Class | Endpoints | Sustained | Burst |
| - | - | - | - |
| **read** | Every List and Get endpoint | 20 per second | 40 |
| **write** | PlaceOrder, SetLeverage | 1 per second | 20 |
| **exit** | CancelOrder, CancelAllOrders, ClosePosition, CloseAllPositions | 10 per second | 40 |
| **stream** | StreamAccountEvents, each connect | 1 per 5 seconds | 20 |

* Exits have a budget of their own that placements cannot use up, so an emergency flatten never queues behind entries.
* The class follows the endpoint, never the body: a PlaceOrder counts as a write even when it only reduces a position. CancelAllOrders and CloseAllPositions count as one call however much they affect.
* You may hold 20 streams open at once, and the events on an open stream cost nothing against any limit. To follow an account, open one [real-time stream](https://hypernova.xyz/docs/api/streaming.md) instead of polling.
* A call over a per-user limit answers `resource_exhausted` with a `Retry-After` in whole seconds. No response carries a remaining-calls or reset header, so pace calls from the limits above.
* Calls from one address are also limited at the edge, across every user they act for, and so are all calls to the API together. A call over either answers 429 `resource_exhausted` with `Retry-After: 60`.


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