# HTTP — overview

Production base URL: `https://production.mosaiq.0d.finance`.

REST endpoints under `/v1` return `{ status, data, server_time_ms }`. On
success, `status` is `"ok"`. On a request-level failure, `status` is `"error"`
and `data` is the [error object](/api/errors#error-object). A successful
`POST /v1/exchange` response also carries `server_receive_time_ms`. A
request-level error does not. Every response has `Cache-Control: no-store`.

A decimal value is a JSON string, such as `"1.5"`. Every decimal string that
Mosaiq answers, on REST and on the WebSockets, has no trailing zeros: `"1.5"`,
`"100"` and `"0.01"`, never `"1.50"`, `"100.000000"` or `"0.010"`, whatever
digits the request had. You can send either form. Compare a value that Mosaiq
returns with a value that you sent as numbers, not as strings. There are two
exceptions:

* The `px` and `sz` of `bbo`, `l2Book`, and `trades` carry the venue's strings.
* The fields of `marginSummary`, `positions`, and `userCaps` in
  `clearinghouseState` are JSON numbers.

## Unauthenticated endpoints

| Endpoint | Description |
| -------- | ----------- |
| [`GET /v1/fees`](/api/fees) | Effective venue and Mosaiq fee rates. |
| [`GET /v1/spotMeta`](/api/spot-meta) | Spot tokens and spot markets, with their order limits. |
| [`GET /v1/outcomeMeta`](/api/outcome-meta) | HIP-4 outcome markets, with their meaning, order limits and status. |
| [`GET /v1/clearinghouseState`](/api/clearinghouse-state) | Account state snapshot for a `user`. |
| [`GET /v1/openOrders`](/api/open-orders) | Live open-order snapshot for a `user`. |
| [`GET /v1/userFills`](/api/user-fills) | Confirmed fills, oldest first for WebSocket gap recovery or newest first for history views. |
| [`GET /v1/userFunding`](/api/user-funding) | Settled funding paid or received by a `user`. |
| [`GET /v1/portfolioHistory`](/api/portfolio-history) | Account value, cash and net deposits of a `user` over time. |
| [`GET /v1/liabilities`](/api/liabilities) | What Mosaiq owes its clients, for the proof of reserves. |
| [`GET /v1/points`](/api/points) | Venue points that a `user` earned, per period. |
| [`GET /v1/outcomeSettlements`](/api/outcome-settlements) | Booked HIP-4 settlements of a `user`, with their fees and where the USDC landed. |
| [`GET /v1/maintenance`](/api/maintenance) | Announcements of a Mosaiq stop and of venue maintenance. |

## Authenticated endpoints

Trading requests use an API key. Each API key acts for one account: the
master account or a [sub-account](/concepts/sub-accounts). These requests use a
Para JWT instead: key management, the list and the creation of sub-accounts,
funding status, withdrawals, and transfers. The first Para-authenticated
request of an allowlisted wallet creates its Mosaiq account.

```http
Authorization: Bearer <api-key or para-jwt>
```

| Endpoint | Auth | Description |
| -------- | ---- | ----------- |
| [`POST /v1/exchange`](/api/exchange) | API key (Para JWT for `withdraw` and `transfer`, either for `deposit`) | Place, modify, cancel, mass cancel, deposit and withdrawal requests, and transfers between accounts. |
| [`GET /v1/rateLimits`](/api/rate-limits) | API key | Current usage and remaining capacity of the exchange request budget of the key's account. |
| [`GET /v1/apiKeys`](/api/api-key) | Para JWT | The 20 most recent API keys of each account of the owner, with their status. |
| [`POST /v1/apiKeys`](/api/api-key) | Para JWT | Create an API key for one account, that expires at a chosen time up to 365 days away, 30 days by default. |
| [`DELETE /v1/apiKeys/{keyId}`](/api/api-key) | Para JWT | Revoke the named API key if it is still the unrevoked key of its account. |
| [`GET /v1/subAccounts`](/api/get-sub-accounts) | Para JWT | The accounts of the owner, and how many sub-accounts it can hold. |
| [`POST /v1/subAccounts`](/api/post-sub-accounts) | Para JWT | Create a sub-account. |
| [`GET /v1/funding`](/api/funding) | Para JWT | Recent deposit and withdrawal requests, and transfers between accounts. |
| [`POST /v1/invitations/redeem`](#redeem-an-invitation) | Para JWT | Approve a wallet using an invitation. |

## Redeem an invitation

`POST /v1/invitations/redeem` accepts a Para JWT and a JSON body
`{ "code": "<invitation-code>" }`. The wallet does not need prior approval.
Send `X-Tessera-Wallet` when the JWT contains several EVM wallets.

Success returns HTTP `200` with
`data: { "activated": true, "alreadyApproved": false }`. Redemption approves
the wallet and creates its account. An already-approved wallet receives
`alreadyApproved: true` without consuming the supplied code.

| HTTP | `code` | `detail` | Meaning |
| --- | --- | --- | --- |
| `429` | `rate_limited` | `rate_limited` | Redemption or HTTP budget exceeded. |
| `401` | `unauthorized` | `wallet_auth_required` | The bearer is an API key. |
| `404` | `forbidden` | `invitation_not_found` | Invalid invitation code. |
| `410` | `forbidden` | `invitation_expired`, `invitation_disabled` | The invitation code expired or was disabled. |
| `409` | `forbidden` | `invitation_already_used` | Another wallet redeemed the invitation code. |
| `403` | `forbidden` | `wallet_revoked` | Wallet access was revoked. |

The default redemption budget is 5 requests per minute per wallet, separate
from the exchange budget. See the shared
[Para token and wallet-selection errors](/api/api-key#errors).

## Rate limits

| Limit | Value | Applies to |
| ----- | ----- | ---------- |
| HTTP requests | `600`/minute/IP | Every HTTP request, including WebSocket upgrades. |
| Exchange requests | `1200`/minute/account | `POST /v1/exchange` and write WebSocket frames. One request or frame counts once regardless of batch size, except a `cancel` or `mass_cancel` with `fastCancel: true`, which counts twice. With 1 unit left, such a cancel is still accepted, and the next request waits until 2 units refill. Deposit, withdrawal, and transfer actions count. With a Para JWT, they count on the master account. `/v1/apiKeys` and `/v1/funding` do not count. |
| API key creation | `10`/hour/wallet | `POST /v1/apiKeys`. Revoking a key does not count. |

Each account has its own exchange budget at the owner's limit. Mosaiq can set
another limit for an owner, and that limit applies to each account of the
owner. [`GET /v1/rateLimits`](/api/rate-limits) shows the limit, the usage, and
the remaining capacity of an account's budget. The
[user-data WebSocket](/api/websocket#rate-limits) page lists the WebSocket
connection and message limits.

Budgets are token buckets. Capacity refills continuously, and a burst can spend
the whole budget at once. An exceeded limit returns HTTP `429` with
`rate_limited`, the detail `rate_limited`, and `retryAfterMs`, the milliseconds
until the bucket admits a request again.

## Busy server

`GET /v1/userFills`, `GET /v1/userFunding`, `GET /v1/portfolioHistory`,
`GET /v1/points`, and `GET /v1/outcomeSettlements` read the database on every
request. The server runs a fixed number of these reads at the same time, for
all clients together. A request that waits too long for a free slot returns
HTTP `503` with `temporarily_unavailable` and the detail `public_reads_busy`.

The server is shedding load. You did not exceed a rate limit. The request
still counts toward the HTTP limit of 600 requests per minute per IP, so retry
with exponential backoff and jitter.

```json
{
  "status": "error",
  "data": {
    "code": "temporarily_unavailable",
    "detail": "public_reads_busy",
    "msg": "server is busy with other reads; retry with backoff"
  },
  "server_time_ms": 1790085600000
}
```

## Errors

Every endpoint and both WebSockets answer errors with the same error object.
[Errors](/api/errors) explains its fields, the 14 codes and what to do about
each, and lists the errors of every endpoint.
