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

# Build an order

> Build a tokenized-**equity** (Ondo) buy/sell order; the product account is the
maker.

Returns everything needed to place the order in one round-trip: a price quote,
a one-time token approval to sign (only until the settlement contract is
approved), and the order payload the owner signs off-chain. Only the approval
ever touches the chain — the signed order is relayed to market makers, never
broadcast. Equities only; RWA yield tokens use `/transact/buy` and
`/transact/sell`.



## OpenAPI

````yaml /v2/combined_spec.json post /v2/tokenized_assets/order
openapi: 3.1.0
info:
  title: Compass API
  description: Compass Labs DeFi API
  version: 0.0.1
servers:
  - url: https://api.compasslabs.ai
    description: Production server
security:
  - ApiKeyAuth: []
paths:
  /v2/tokenized_assets/order:
    post:
      tags:
        - Tokenized Assets
      summary: Build an order
      description: >-
        Build a tokenized-**equity** (Ondo) buy/sell order; the product account
        is the

        maker.


        Returns everything needed to place the order in one round-trip: a price
        quote,

        a one-time token approval to sign (only until the settlement contract is

        approved), and the order payload the owner signs off-chain. Only the
        approval

        ever touches the chain — the signed order is relayed to market makers,
        never

        broadcast. Equities only; RWA yield tokens use `/transact/buy` and

        `/transact/sell`.
      operationId: v2_tokenized_assets_order
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TokenizedAssetsBuildOrderRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TokenizedAssetsBuildOrderResponse'
        '400':
          description: >-
            `Tokenized Assets Account not deployed` — the requesting `owner`
            does not have a Tokenized Assets Account on Ethereum mainnet. Call
            `POST /v2/tokenized_assets/create_account` first.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TokenizedAssetsErrorResponse'
        '404':
          description: '`Market not found.` — `from_token`/`to_token` is unsupported.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TokenizedAssetsErrorResponse'
        '409':
          description: >-
            `Insufficient liquidity` — no market maker could fill the trade. Try
            a different size or retry shortly.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TokenizedAssetsErrorResponse'
        '410':
          description: '`Quote expired` — re-quote and retry.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TokenizedAssetsErrorResponse'
        '422':
          description: >-
            `Wrong trade flow` — an RWA yield token (mTBILL/mBASIS/mBTC) was
            passed to this equity order endpoint; use `/transact/buy` or
            `/transact/sell` instead. **or** `Slippage exceeded` — the on-chain
            auction may fill below the requested `slippage_bps` tolerance; raise
            `slippage_bps` or pick a more liquid market. (Standard 422
            input-validation errors use FastAPI's default `{detail: [...]}`
            shape; both labels above use the Compass envelope.)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TokenizedAssetsErrorResponse'
        '502':
          description: >-
            `Swap service unavailable` — the swap service is temporarily
            unavailable.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TokenizedAssetsErrorResponse'
      x-codeSamples:
        - lang: python
          label: Python (SDK)
          source: |-
            from compass_api_sdk import CompassAPI


            with CompassAPI(
                api_key_auth="<YOUR_API_KEY_HERE>",
            ) as compass_api:

                res = compass_api.tokenized_assets.tokenized_assets_order(from_token="<value>", to_token="<value>", amount="578.28", owner="<value>", slippage_bps=50)

                # Handle response
                print(res)
        - lang: typescript
          label: Typescript (SDK)
          source: |-
            import { CompassApiSDK } from "@compass-labs/api-sdk";

            const compassApiSDK = new CompassApiSDK({
              apiKeyAuth: "<YOUR_API_KEY_HERE>",
            });

            async function run() {
              const result = await compassApiSDK.tokenizedAssets.tokenizedAssetsOrder({
                fromToken: "<value>",
                toToken: "<value>",
                amount: "578.28",
                owner: "<value>",
                slippageBps: 50,
              });

              console.log(result);
            }

            run();
components:
  schemas:
    TokenizedAssetsBuildOrderRequest:
      properties:
        from_token:
          type: string
          title: Token
          description: >-
            Token the sender is paying. Either an on-chain symbol (e.g.
            `TSLAon`), the literal `USDC`, or a 0x-prefixed token address.
          examples:
            - USDC
            - WETH
            - '0xA0b86a33E6441ccF30EE5DdEF1E9b652C91ac1c8'
        to_token:
          type: string
          title: Token
          description: Token the sender is receiving. Same accepted forms as `from_token`.
          examples:
            - USDC
            - WETH
            - '0xA0b86a33E6441ccF30EE5DdEF1E9b652C91ac1c8'
        amount:
          type: string
          title: Amount
          description: >-
            Human-readable amount of `from_token` to swap (decimal string).
            Decimals are applied server-side.
        owner:
          type: string
          title: Owner
          description: >-
            Wallet that owns the Tokenized Assets Account. The product account
            address is derived deterministically from this owner. The owner
            signs the EIP-712 payloads returned by this endpoint (the optional
            approval and the order itself).
        slippage_bps:
          type: integer
          maximum: 5000
          minimum: 1
          title: Slippage Bps
          description: >-
            Max acceptable slippage in basis points (1 bp = 0.01%). Range 1-5000
            (0.01%-50%); defaults to 50 (0.5%). The upper bound is intentionally
            wide so callers can clear the wide auction floors quoted for
            thinly-traded tokenized stocks.
          default: 50
      type: object
      required:
        - from_token
        - to_token
        - amount
        - owner
      title: TokenizedAssetsBuildOrderRequest
      description: Build a buy or sell order for a tokenized equity.
      example:
        amount: '100'
        from_token: USDC
        owner: '0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B'
        slippage_bps: 50
        to_token: TSLAon
    TokenizedAssetsBuildOrderResponse:
      properties:
        quote:
          $ref: '#/components/schemas/Quote'
          description: Preview of input/output amounts and fees for the proposed order.
        approval_safe_tx_eip712:
          anyOf:
            - $ref: '#/components/schemas/BatchedSafeOperationsResponse-Output'
            - type: 'null'
          description: >-
            EIP-712 payload that authorizes a one-time max-approve of
            `from_token` to the settlement contract. Populated when the
            Tokenized Assets Account's existing allowance is below `amount`. The
            owner signs it, then it is broadcast via `POST
            /v2/gas_sponsorship/prepare` (or directly by the owner) to set the
            allowance on-chain. `null` when the allowance is already sufficient.
        order:
          $ref: '#/components/schemas/OrderToSign'
          description: >-
            Order metadata plus the EIP-712 payload to sign. The owner signs
            `order.safe_message_eip712` and submits the resulting signature to
            `/order/submit` along with the rest of the order fields.
      type: object
      required:
        - quote
        - order
      title: TokenizedAssetsBuildOrderResponse
      description: Quote, optional approval payload, and the EIP-712 order to sign.
      example:
        approval_safe_tx_eip712:
          domain:
            chainId: 1
            verifyingContract: '0x2ed5C9c14E1F8baA94CD3e9b5b6e3F8e3D27504F'
          message:
            baseGas: '0'
            data: >-
              0x095ea7b3000000000000000000000000111111125421ca6dc452d289314280a0f8842a65ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
            gasPrice: '0'
            gasToken: '0x0000000000000000000000000000000000000000'
            nonce: '0'
            operation: 0
            refundReceiver: '0x0000000000000000000000000000000000000000'
            safeTxGas: '0'
            to: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'
            value: '0'
          primaryType: SafeTx
          types:
            EIP712Domain:
              - name: chainId
                type: uint256
              - name: verifyingContract
                type: address
            SafeTx:
              - name: to
                type: address
              - name: value
                type: uint256
              - name: data
                type: bytes
              - name: operation
                type: uint8
              - name: safeTxGas
                type: uint256
              - name: baseGas
                type: uint256
              - name: gasPrice
                type: uint256
              - name: gasToken
                type: address
              - name: refundReceiver
                type: address
              - name: nonce
                type: uint256
        order:
          extension: '0x000000a4000000a4000000a40000005200000000'
          order_hash: '0x14459af3a06abf6f7a0d3c2c1fa3b64d2e1b8a7c5e3d2b1f0a9876543210596b'
          order_message:
            maker: '0x2ed5C9c14E1F8baA94CD3e9b5b6e3F8e3D27504F'
            makerAsset: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'
            makerTraits: '0'
            makingAmount: '100000000'
            receiver: '0x399740157391a9f1bf4e9921a8834f9bc8f2678e'
            salt: '102030405060708090'
            takerAsset: '0xf6b1117ec07684D3958caD8BEb1b302bfD21103f'
            takingAmount: '281678000000000000'
          quote_id: 9afa6d80-9216-4bcd-b762-87151f9dae51
          safe_message_eip712:
            domain:
              chainId: 1
              verifyingContract: '0x2ed5C9c14E1F8baA94CD3e9b5b6e3F8e3D27504F'
            message:
              message: >-
                0x14459af3a06abf6f7a0d3c2c1fa3b64d2e1b8a7c5e3d2b1f0a9876543210596b
            primaryType: SafeMessage
            types:
              EIP712Domain:
                - name: chainId
                  type: uint256
                - name: verifyingContract
                  type: address
              SafeMessage:
                - name: message
                  type: bytes
        quote:
          est_fill_seconds: 180
          fee:
            amount_usd: '0.06'
            bps: 6
          input:
            amount: '100'
            amount_usd: '100.00'
            contract_address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'
            symbol: USDC
          output:
            amount: '0.281678'
            amount_usd: '99.94'
            contract_address: '0xf6b1117ec07684D3958caD8BEb1b302bfD21103f'
            symbol: TSLAon
    TokenizedAssetsErrorResponse:
      properties:
        error:
          type: string
          title: Error
          description: >-
            Short human-readable error label (e.g. `Market not found.`,
            `Insufficient liquidity`, `Order not found.`).
        message:
          type: string
          title: Message
          description: Human-readable explanation.
      type: object
      required:
        - error
        - message
      title: TokenizedAssetsErrorResponse
      description: >-
        Standard error envelope returned by every non-2xx response.


        Surfaced in OpenAPI ``responses`` declarations so SDK consumers can
        decode

        failures uniformly without inspecting per-status-code shapes.
    Quote:
      properties:
        input:
          $ref: '#/components/schemas/TokenAmount'
          description: Token the sender is paying.
        output:
          $ref: '#/components/schemas/TokenAmount'
          description: Token the sender is receiving.
        fee:
          $ref: '#/components/schemas/QuoteFee'
          description: Aggregate fee.
        est_fill_seconds:
          type: integer
          title: Est Fill Seconds
          description: Estimated upper bound on time-to-fill, in seconds.
      type: object
      required:
        - input
        - output
        - fee
        - est_fill_seconds
      title: Quote
      description: Quote preview returned alongside an order.
    BatchedSafeOperationsResponse-Output:
      properties:
        domain:
          $ref: >-
            #/components/schemas/compass__api_backend__v2__models__safe__transact__response__batched_safe_operations__EIP712Domain
          description: EIP-712 domain separator
        types:
          $ref: >-
            #/components/schemas/compass__api_backend__v2__models__safe__transact__response__batched_safe_operations__EIP712Types
          description: EIP-712 type definitions
        primaryType:
          type: string
          const: SafeTx
          title: Primarytype
          description: Primary type for the structured data
        message:
          $ref: '#/components/schemas/SafeTxMessage'
          description: Safe transaction message data
      type: object
      required:
        - domain
        - types
        - primaryType
        - message
      title: BatchedSafeOperationsResponse
      description: Response containing EIP-712 typed data for Safe transaction signing.
      example:
        domain:
          chainId: 8453
          verifyingContract: '0x6B90E8B4E3E971E74C1A47a3a20976377E2dB4b1'
        message:
          baseGas: '0'
          data: >-
            0x8d80ff0a0000000000000000000000000000000000000000000000000000000000000020
          gasPrice: '0'
          gasToken: '0x0000000000000000000000000000000000000000'
          nonce: '7'
          operation: 1
          refundReceiver: '0x0000000000000000000000000000000000000000'
          safeTxGas: '0'
          to: '0x93C23AAE4793C14D6DF35D2A2A2234204e1559dA'
          value: '0'
        primaryType: SafeTx
        types:
          EIP712Domain:
            - name: chainId
              type: uint256
            - name: verifyingContract
              type: address
          SafeTx:
            - name: to
              type: address
            - name: value
              type: uint256
            - name: data
              type: bytes
            - name: operation
              type: uint8
            - name: safeTxGas
              type: uint256
            - name: baseGas
              type: uint256
            - name: gasPrice
              type: uint256
            - name: gasToken
              type: address
            - name: refundReceiver
              type: address
            - name: nonce
              type: uint256
    OrderToSign:
      properties:
        order_hash:
          type: string
          title: Order Hash
          description: >-
            The on-chain order hash. Wrapped inside
            `safe_message_eip712.message.message` for the owner to sign; also
            passed back to `/order/submit` so the API can return a usable handle
            even if the upstream submit response omits the hash.
        extension:
          type: string
          title: Extension
          description: >-
            Opaque hex blob from the upstream quote — pass back to
            `/order/submit` unchanged.
        quote_id:
          type: string
          title: Quote Id
          description: Upstream quote identifier — must be echoed back at `/order/submit`.
        order_message:
          additionalProperties: true
          type: object
          title: Order Message
          description: >-
            Order struct (maker, makerAsset, makingAmount, etc.) — pass back to
            `/order/submit` unchanged. The maker is the Tokenized Equities
            Account, not the owner's wallet.
        safe_message_eip712:
          $ref: '#/components/schemas/SafeMessageEip712Response'
          description: >-
            EIP-712 payload the owner signs off-chain to authorize the order.
            Sign with `wallet.signTypedData(...)` and submit the signature to
            `/order/submit`. This signature is never broadcast on-chain.
      type: object
      required:
        - order_hash
        - extension
        - quote_id
        - order_message
        - safe_message_eip712
      title: OrderToSign
      description: |-
        Order metadata plus the EIP-712 payload the owner signs to authorize it.

        The owner signs ``safe_message_eip712`` off-chain. At submit time the
        signature is sent back to ``/order/submit`` together with
        ``order_message``, ``extension``, and ``quote_id``; the signature is
        validated against the Tokenized Assets Account at fill time.
    TokenAmount:
      properties:
        symbol:
          type: string
          title: Symbol
          description: On-chain token symbol (e.g. `USDC`, `TSLAon`).
        contract_address:
          type: string
          title: Contract Address
          description: Ethereum mainnet ERC-20 address.
        amount:
          type: string
          title: Amount
          description: Human-readable amount as a decimal string.
        amount_usd:
          anyOf:
            - type: string
            - type: 'null'
          title: Amount Usd
          description: USD value of `amount`.
      type: object
      required:
        - symbol
        - contract_address
        - amount
      title: TokenAmount
      description: A token + amount pair for one leg of the quote.
    QuoteFee:
      properties:
        amount_usd:
          anyOf:
            - type: string
            - type: 'null'
          title: Amount Usd
          description: Total fee in USD as a decimal string.
        bps:
          anyOf:
            - type: integer
            - type: 'null'
          title: Bps
          description: Fee as basis points of the input amount.
      type: object
      title: QuoteFee
      description: Aggregate fee charged for the order.
    compass__api_backend__v2__models__safe__transact__response__batched_safe_operations__EIP712Domain:
      properties:
        chainId:
          type: integer
          title: Chainid
          description: Chain ID
        verifyingContract:
          type: string
          title: Verifyingcontract
          description: Address of the Product Account
      type: object
      required:
        - chainId
        - verifyingContract
      title: EIP712Domain
      description: The EIP-712 domain separator.
    compass__api_backend__v2__models__safe__transact__response__batched_safe_operations__EIP712Types:
      properties:
        EIP712Domain:
          items:
            $ref: '#/components/schemas/EIP712DomainField'
          type: array
          title: Eip712Domain
          description: EIP712Domain type definition
        SafeTx:
          items:
            $ref: '#/components/schemas/SafeTxField'
          type: array
          title: Safetx
          description: SafeTx type definition
      type: object
      required:
        - EIP712Domain
        - SafeTx
      title: EIP712Types
      description: The type definitions for EIP-712 structured data.
    SafeTxMessage:
      properties:
        to:
          type: string
          title: To
          description: Destination address
        value:
          type: string
          title: Value
          description: Value in wei as a string
        data:
          type: string
          title: Data
          description: Transaction data as hex string
        operation:
          $ref: '#/components/schemas/OperationType'
          description: Operation type (0=Call, 1=DelegateCall)
        safeTxGas:
          type: string
          title: Safetxgas
          description: Gas for the transaction
        baseGas:
          type: string
          title: Basegas
          description: Base gas costs
        gasPrice:
          type: string
          title: Gasprice
          description: Gas price
        gasToken:
          type: string
          title: Gastoken
          description: Token address for gas payment
        refundReceiver:
          type: string
          title: Refundreceiver
          description: Address to receive gas refund
        nonce:
          type: string
          title: Nonce
          description: Transaction nonce
      type: object
      required:
        - to
        - value
        - data
        - operation
        - safeTxGas
        - baseGas
        - gasPrice
        - gasToken
        - refundReceiver
        - nonce
      title: SafeTxMessage
      description: The message data for the transaction.
    SafeMessageEip712Response:
      properties:
        domain:
          $ref: >-
            #/components/schemas/compass__api_backend__v2__models__safe__transact__response__batched_safe_operations__EIP712Domain
          description: EIP-712 domain separator.
        types:
          $ref: '#/components/schemas/SafeMessageEip712Types'
          description: EIP-712 type definitions.
        primaryType:
          type: string
          const: SafeMessage
          title: Primarytype
          description: Primary type for the structured data.
        message:
          $ref: '#/components/schemas/SafeMessageMessage'
          description: Message bytes the product account is signing.
      type: object
      required:
        - domain
        - types
        - primaryType
        - message
      title: SafeMessageEip712Response
      description: '``signTypedData`` payload for ``SafeMessage(bytes message)``.'
      example:
        domain:
          chainId: 1
          verifyingContract: '0x2ed5C9c14E1F8baA94CD3e9b5b6e3F8e3D27504F'
        message:
          message: >-
            0x14459af3a06abf6f7a1234567890abcdef1234567890abcdef1234567890596b016a
        primaryType: SafeMessage
        types:
          EIP712Domain:
            - name: chainId
              type: uint256
            - name: verifyingContract
              type: address
          SafeMessage:
            - name: message
              type: bytes
    EIP712DomainField:
      properties:
        name:
          type: string
          title: Name
        type:
          type: string
          title: Type
      type: object
      required:
        - name
        - type
      title: EIP712DomainField
      description: A field in the EIP712Domain type definition.
    SafeTxField:
      properties:
        name:
          type: string
          title: Name
        type:
          type: string
          title: Type
      type: object
      required:
        - name
        - type
      title: SafeTxField
      description: A field in the SafeTx type definition.
    OperationType:
      type: integer
      enum:
        - 0
        - 1
      title: OperationType
      description: Safe operation types.
    SafeMessageEip712Types:
      properties:
        EIP712Domain:
          items:
            $ref: '#/components/schemas/EIP712DomainField'
          type: array
          title: Eip712Domain
          description: EIP712Domain type definition
        SafeMessage:
          items:
            $ref: '#/components/schemas/SafeMessageField'
          type: array
          title: Safemessage
          description: SafeMessage type definition
      type: object
      required:
        - EIP712Domain
        - SafeMessage
      title: SafeMessageEip712Types
      description: Type definitions for the ``SafeMessage`` EIP-712 payload.
    SafeMessageMessage:
      properties:
        message:
          type: string
          title: Message
          description: >-
            Raw bytes the product account is signing under ERC-1271. For a
            tokenized-asset order this is the 32-byte order hash.
      type: object
      required:
        - message
      title: SafeMessageMessage
      description: Body of the ``SafeMessage`` typed-data — a single ``bytes message``.
    SafeMessageField:
      properties:
        name:
          type: string
          title: Name
        type:
          type: string
          title: Type
      type: object
      required:
        - name
        - type
      title: SafeMessageField
      description: A field in the ``SafeMessage`` type definition.
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        Your Compass API Key. Get your key
        [here](https://www.compasslabs.ai/dashboard).

````