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

# Post a new order

> Submit a new maker order to the SX Bet orderbook. Requires an EIP-712 signature.

<Note>**Rate limit:** All `POST /orders/*` endpoints share a combined limit of 5,500 requests/min. See [Rate Limits](/developers/rate-limits).</Note>

Note you can offer as many orders as you wish, provided your total exposure for each token (as measured by `totalBetSize - fillAmount`) remains under your wallet balance. If your wallet balance dips under your total exposure, orders will be removed from the book until it reaches the minimum again.

<Info>Your assets must be on SX Mainnet to place orders.</Info>

<Warning>If the API finds that your balance is consistently below your total exposure requiring orders to be cancelled, your account may be temporarily restricted.</Warning>

To offer bets on sx.bet via the API, make sure you first enable betting. The simplest way is to place a test bet through [sx.bet](https://sx.bet) (or [toronto.sx.bet](https://toronto.sx.bet) for testnet) with the account you'll be using. To do it programmatically, use the [POST /orders/approve](/api-reference/post-approve) endpoint.

## Status messages

The following status messages exist for each order:

| Message                | Description                                                                     |
| ---------------------- | ------------------------------------------------------------------------------- |
| `OK`                   | The order was created successfully                                              |
| `INSUFFICIENT_BALANCE` | The order could not be created due to insufficient maker token balance          |
| `INVALID_MARKET`       | The order could not be created since the user specified non-unique marketHashes |
| `ORDERS_ALREADY_EXIST` | The order already exists                                                        |

<Info>Note that `totalBetSize` is from **the perspective of the market maker**. `totalBetSize` can be thought of as the maximum amount of tokens the maker (you) will be putting into the pot if the order was fully filled. This is the maximum amount you will risk.</Info>


## OpenAPI

````yaml POST /orders/new
openapi: 3.0.1
info:
  title: SX Bet API
  version: 1.0.0
  description: >-
    REST API for the SX Bet decentralized sports betting exchange. Retrieve
    sports data, markets, and orderbook information. Post, cancel, and fill
    orders with signed payloads.


    Base URLs:

    - **Mainnet**: `https://api.sx.bet`

    - **Testnet**: `https://api.toronto.sx.bet`
servers:
  - url: https://api.sx.bet
    description: Mainnet (SX Network, chainId 4162)
  - url: https://api.toronto.sx.bet
    description: Testnet (Toronto, chainId 79479957)
security: []
tags:
  - name: Connection
    description: Server metadata and heartbeat management
  - name: Sports Data
    description: Sports, leagues, teams, fixtures, and live scores
  - name: Markets
    description: Active, specific, and popular betting markets
  - name: Trades
    description: Matched trades and portfolio history
  - name: Orders
    description: Orderbook queries, posting, cancelling, and filling orders
paths:
  /orders/new:
    post:
      tags:
        - Orders
      summary: Post a new order
      description: >-
        This endpoint offers new orders on the exchange (market making).
        Offering orders does not cost any fee.
      operationId: postNewOrder
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - orders
              properties:
                orders:
                  type: array
                  items:
                    $ref: '#/components/schemas/SignedNewOrder'
                  description: Array of signed orders to post
            example:
              orders:
                - marketHash: 0x...
                  maker: 0xYourWalletAddress
                  baseToken: '0x6629Ce1Cf35Cc1329ebB4F63202F3f197b3F050B'
                  totalBetSize: '10000000'
                  percentageOdds: '52500000000000000000'
                  expiry: 2209006800
                  apiExpiry: 1735689600
                  executor: '0x52adf738AAD93c31f798a30b2C74D658e1E9a562'
                  salt: 0x...
                  isMakerBettingOutcomeOne: true
                  signature: 0x...
      responses:
        '201':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    description: '`success` or `failure` if the request succeeded or not'
                  data:
                    type: object
                    properties:
                      orders:
                        type: array
                        items:
                          type: string
                        description: The order hashes corresponding to the new orders
                      statuses:
                        type: object
                        additionalProperties:
                          type: string
                        description: >-
                          Map of order hash to status string for each submitted
                          order
                      inserted:
                        type: number
                        description: The number of new orders successfully inserted
              example:
                status: success
                data:
                  orders:
                    - >-
                      0x7a9d420551c4a635849013dd908f7894766e97aee25fe656d0c5ac857e166fac
                  statuses:
                    '0x7a9d420551c4a635849013dd908f7894766e97aee25fe656d0c5ac857e166fac': OK
                  inserted: 1
        '400':
          description: >-
            Error Codes:


            `TOO_MANY_DIFFERENT_MARKETS` — More than 3 different markets queried


            `ORDERS_MUST_HAVE_IDENTICAL_MARKET` — All orders must be for the
            same network, either `SXN` or `SXR`


            `BAD_BASE_TOKEN` — All orders must be for the same base token,
            either `USDC` or `WSX`


            `ACCOUNT_SUSPENDED` — Your account has been suspended


            `INSUFFICIENT_KYC` — user has not registered on sx.bet
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                  errorCode:
                    type: string
      x-codeSamples:
        - lang: javascript
          label: Sign & Post Order
          source: >-
            import { Wallet, solidityPackedKeccak256, getBytes, randomBytes,
            hexlify } from "ethers";


            const order = {
              marketHash:
                "0x0eeace4a9bbf6235bc59695258a419ed3a05a2c8e3b6a58fb71a0d9e6b031c2b",
              maker: "0x6F75bA6c90E3da79b7ACAfc0fb9cf3968aa4ee39",
              totalBetSize: "10000000",
              percentageOdds: "52500000000000000000",
              baseToken: "0x6629Ce1Cf35Cc1329ebB4F63202F3f197b3F050B", // Mainnet — see References for testnet address
              apiExpiry: 1631233201,
              expiry: 2209006800,
              executor: "0x52adf738AAD93c31f798a30b2C74D658e1E9a562", // Mainnet — use GET /metadata → executorAddress for testnet
              isMakerBettingOutcomeOne: true,
              salt: BigInt(hexlify(randomBytes(32))).toString(),
            };


            const orderHash = getBytes(
              solidityPackedKeccak256(
                [
                  "bytes32",
                  "address",
                  "uint256",
                  "uint256",
                  "uint256",
                  "uint256",
                  "address",
                  "address",
                  "bool",
                ],
                [
                  order.marketHash,
                  order.baseToken,
                  order.totalBetSize,
                  order.percentageOdds,
                  order.expiry,
                  order.salt,
                  order.maker,
                  order.executor,
                  order.isMakerBettingOutcomeOne,
                ]
              )
            );


            // Example with an ethers.js wallet using a private key

            const wallet = new Wallet(process.env.SX_PRIVATE_KEY);

            const signature = await wallet.signMessage(orderHash);


            // Example with an injected web3 provider such as MetaMask

            // const provider = new BrowserProvider(window.ethereum);

            // const signer = await provider.getSigner();

            // const signature = await signer.signMessage(orderHash);


            const signedOrder = { ...order, signature };


            const result = await fetch("https://api.sx.bet/orders/new", { //
            Mainnet — use https://api.toronto.sx.bet for testnet
              method: "POST",
              body: JSON.stringify({ orders: [signedOrder] }),
              headers: { "Content-Type": "application/json" },
            });
components:
  schemas:
    SignedNewOrder:
      type: object
      required:
        - marketHash
        - maker
        - baseToken
        - totalBetSize
        - percentageOdds
        - expiry
        - apiExpiry
        - executor
        - salt
        - isMakerBettingOutcomeOne
        - signature
      properties:
        marketHash:
          type: string
          description: The market you wish to place this order under
        maker:
          type: string
          description: >-
            The ethereum address offering the bet. The address in the `maker`
            field must match the account being used to create the signature!
        baseToken:
          type: string
          description: >-
            The token this order is denominated in. Token addresses vary by
            network — see the `addresses` field in GET /metadata or the
            References page for the correct address.
        totalBetSize:
          type: string
          description: The total bet size of the order in Ethereum units. Minimum 10 USDC.
        percentageOdds:
          type: string
          description: >-
            The odds the maker will be receiving as this order gets filled. Must
            be on the odds ladder or will be rejected.
        expiry:
          type: integer
          description: >-
            Deprecated. Time in UNIX seconds after which this order is no longer
            valid. Must always be 2209006800.
        apiExpiry:
          type: integer
          description: Time in UNIX seconds after which this order is no longer valid.
        executor:
          type: string
          description: >-
            The sx.bet executor address. See the metadata section for where to
            get this address
        salt:
          type: string
          description: >-
            A random 32 byte string to differentiate between orders with
            otherwise identical parameters
        isMakerBettingOutcomeOne:
          type: boolean
          description: >-
            `true` if the maker is betting outcome one (and hence taker is
            betting outcome two if filled)
        signature:
          type: string
          description: The signature of the maker on this order payload

````