openapi: 3.0.1
info:
  title: True Markets CeFi REST
  description: |
    ## Overview
    This API allows clients to interact with the **CeFi trading platform** for order management, market data retrieval, and account information.

    ## Base URLs

    | Environment | Base URL |
    |---|---|
    | Production | `https://api.truex.co/v1/cefi/` |
    | UAT (sandbox) | `https://api.uat.truex.co/v1/cefi/` |

    REST is reachable over the internet. Access is restricted by the location of the IP address your requests come from.

    > **Breaking in v1.0.6.** The legacy `/api/v1/` path prefix is **removed** — every operation is now served only under `/v1/cefi/` (admin operations under `/admin/v1/cefi/`). Response formats are unchanged: this release is a path move only, so updating your base path is sufficient.

    > **Coming on November 1, 2026 — `v2024_01_01` is removed.** From that date `v2026_01_23` is the only supported schema version. It becomes the default, so a request that sends no `X-Truex-Version` header will receive the envelope response format described under **API Versioning** below, with paginated list reads and error bodies wrapped in `{ "error": ... }`; and a request that explicitly sends `X-Truex-Version: v2024_01_01` is rejected. There is no way to remain on `v2024_01_01` past that date — it is already past its August 5, 2026 sunset — so pinning that header delays nothing and will fail your requests once the cutoff lands. Send `X-Truex-Version: v2026_01_23` now to adopt the new format on your own schedule beforehand.


    ## Authentication

    Protected endpoints accept **either** of two authentication methods:

    - **JWT bearer token** — mint a JWT from your ES256 API key and send it in the `Authorization` header. This is the recommended method.
    - **HMAC-SHA256** signed requests using a legacy HMAC API key and secret. HMAC keys keep working while they are phased out.

    Market data and service-health endpoints are public and require no authentication.

    ### JWT bearer token

    Create an ES256 (EC P-256) API key at [app.truemarkets.co](https://app.truemarkets.co), under Settings, API keys. Mint a token pair by signing the challenge `{key_id}.{timestamp}` with the private key and posting it to `POST /v1/auth/api-key/token` on `https://api.truemarkets.co` (see the [Auth API](/apis/auth/openapi)). The signature is the raw 64-byte `r || s`, base64url-encoded without padding. Access tokens last one hour; refresh them at `POST /v1/auth/token/refresh`.

    Send on every request:

    - `Authorization: Bearer <access token>`
    - `x-truex-auth-timestamp`: the current time in Unix seconds, no more than 15 seconds old and no more than 1 second in the future. It guards against replayed requests.

    The token carries a `client_id` claim, which scopes every request to your CeFi client, so you don't send `x-truex-auth-userid`. A JWT **without** a `client_id` claim (an account not enabled for CeFi trading) is rejected with `401 Unauthorized`.

    ### HMAC-SHA256 (legacy)

    Send `x-truex-auth-token` (your API key), `x-truex-auth-timestamp`, `x-truex-auth-signature` and `x-truex-auth-userid` (the client the request acts for). Compute the signature as:

    ```
    signature = base64( HMAC_SHA256( secret, TIMESTAMP + METHOD + PATH + BODY ) )
    ```

    where `PATH` excludes the query string and `BODY` is the exact serialized request body (empty string when there is none). The `HMAC` security scheme below has the full rules and an example.

    ## API Versioning
    The API uses date-based versioning via the `X-Truex-Version` header. To request a specific API version, include the header in your request:
    ```
    X-Truex-Version: v2026_01_23
    ```

    **Supported Versions:**
    | Version | Status | Description |
    |---------|--------|-------------|
    | `v2024_01_01` | Deprecated (Default) — **removed November 1, 2026** | Original API format - responses return raw data arrays/objects |
    | `v2026_01_23` | Current — becomes the default and the only supported version on November 1, 2026 | Envelope format - responses wrapped in `{ "data": [...], "pagination": {...} }` |

    If no version header is provided, the API defaults to `v2024_01_01`. From November 1, 2026 the default is `v2026_01_23`, and `v2024_01_01` is rejected whether it is sent explicitly or inherited. Use the `/v1/cefi/versions` endpoint to discover supported versions programmatically.

    **Response Format by Version:**
    - **v2024_01_01**: `[{...}, {...}]` (raw array) or `{...}` (raw object)
    - **v2026_01_23**: `{ "data": [...], "pagination": { "size": 10, "next_cursor": "..." } }`

    **Error Response Format by Version:**
    - **v2024_01_01**: RFC 7807 Problem Details format
    - **v2026_01_23**: `{ "error": { ...RFC 7807 Problem Details... } }`

    **Deprecation Policy:**
    When a version is deprecated, responses will include RFC 8594 headers:
    - `Deprecation`: Date when the version was deprecated
    - `Sunset`: Date when the version will be removed

    Deprecation is a warning, not a grace period that can be extended: once a version passes its removal date it is withdrawn, and requests that ask for it are rejected rather than served in an older format.


    ## Links
    - 📖 **Full API Documentation**: [https://docs.truemarkets.co/](https://docs.truemarkets.co/)
    - 📧 **Support**: [support@truemarkets.co](mailto:support@truemarkets.co)

  contact:
    email: info@truemarkets.co
  termsOfService: https://truex.co/tos
  version: "v1.0.8"
tags:
  - name: Service
    description: Health checks and API version discovery endpoints. These endpoints are publicly accessible and do not require authentication.
  - name: Assets
    description: Query available assets on the exchange by ID or name.
  - name: Instruments
    description: Query tradeable instruments (market definitions) and their statistics.
  - name: Market Data
    description: Real-time market quotes and VWAP computations. These endpoints are publicly accessible and do not require authentication.
  - name: Clients
    description: Retrieve and update client account information and settings.
  - name: Orders
    description: Create, modify, cancel, and query orders including status, trades, and activity history.
  - name: Balances
    description: Query account balances across all assets.
  - name: Transfers
    description: Initiate and track fund transfers between accounts.
  - name: Change Log
    description: |

      | Version   | Date       | Notes                                                 |
      |-----------|------------|-------------------------------------------------------|
      | v1.0.8    | 2026-10-13 | Document JWT bearer auth as the primary method and HMAC as legacy; correct the HMAC header and payload description; REST is reachable over the internet. `x-truex-auth-token`, `x-truex-auth-signature` and `x-truex-auth-userid` are optional, sent only with HMAC. |
      | v1.0.7    | 2026-10-08 | Add client fees endpoint.                             |
      | v1.0.6    | 2026-09-02 | Remove the deprecated /api/v1/ paths.                 |
      | v1.0.5    | 2026-05-05 | Add /v1/cefi/ path prefix.  Deprecate /api/v1/ paths. |
      | v1.0.4    | 2026-03-12 | Compute quote now works for both base and qoute bases.|
      | v1.0.3    | 2026-01-27 | Pluralize all endpoints.  Deprecate singular versions.|
      | v1.0.2    | 2026-01-24 | Add API versioning support and versions endpoint.     |
      | v1.0.1    | 2025-10-24 | Add gateway health endpoint.                          |
      | v1.0.0    | 2025-10-16 | Initial Release.                                      |

servers:
  - url: https://api.truex.co
    description: Production
  - url: https://api.uat.truex.co
    description: UAT (sandbox)

paths:
  # ==================== SERVICE ENDPOINTS ====================
  /v1/cefi/health:
    get:
      tags:
        - Service
      summary: Get service health
      description: >
        Returns the current readiness status for the REST API Gateway. The
        response includes a human-readable status indicator, the service name,
        and the timestamp when the status was generated.
      operationId: getServiceHealthCefi
      responses:
        "200":
          description: Service is ready to handle requests.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ServiceHealth"
        "400":
          $ref: "#/components/responses/BadRequest"
        "503":
          description: Service is degraded or unavailable.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ServiceHealth"
      security:
        - {}
  /v1/cefi/versions:
    get:
      tags:
        - Service
      summary: Get supported API versions
      description: >
        Returns a list of supported API versions with their deprecation status.
        Use this endpoint to discover available versions and plan migrations
        when versions are deprecated.
      operationId: getApiVersionsCefi
      responses:
        "200":
          description: List of supported API versions.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiVersions"
        "400":
          $ref: "#/components/responses/BadRequest"
      security:
        - {}

  # ==================== ASSET ENDPOINTS (plural - standard) ====================
  /v1/cefi/assets:
    get:
      tags:
        - Assets
      summary: Get assets
      description: "Query for assets available on the exchange by specific asset ID or name.  If no query parameters are supplied than ALL available assets will be returned."
      operationId: getAssetsCefi
      responses:
        "200":
          description: "Successful operation."
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/Asset"
        "400":
          $ref: "#/components/responses/BadRequest"
        "500":
          $ref: "#/components/responses/InternalError"
        "503":
          $ref: "#/components/responses/ServiceUnavailable"
      parameters:
        - name: id
          in: query
          description: "ID of asset to query for."
          required: false
          schema:
            type: string
            minLength: 1
            pattern: "^[1-9][0-9]*$"
        - name: name
          in: query
          description: >
            Filters assets by name. Returns assets where the name is an exact match
            or contains the provided substring. Matching is case-sensitive.
          required: false
          schema:
            type: string
            minLength: 1
      security:
        - {}

  # ==================== INSTRUMENT ENDPOINTS (plural - standard) ====================
  /v1/cefi/instruments:
    get:
      tags:
        - Instruments
      summary: Get instruments
      description: "Query for instruments available on the exchange by specific instrument ID or symbol.  If no query parameters are supplied than ALL available instruments will be returned."
      operationId: getInstrumentsCefi
      responses:
        "200":
          description: "Successful operation."
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/Instrument"
        "400":
          $ref: "#/components/responses/BadRequest"
        "500":
          $ref: "#/components/responses/InternalError"
        "503":
          $ref: "#/components/responses/ServiceUnavailable"
      parameters:
        - name: id
          in: query
          description: "ID of instrument to query for."
          required: false
          schema:
            type: string
            minLength: 1
            pattern: "^[1-9][0-9]*$"
        - name: symbol
          in: query
          description: >
            Filters instruments by symbol. Returns instruments where the symbol is an exact match
            or contains the provided substring. Matching is case-sensitive.
          required: false
          schema:
            type: string
            minLength: 1
      security:
        - {}

  # ==================== MARKET DATA ENDPOINTS (plural - standard) ====================
  /v1/cefi/market/quote:
    get:
      tags:
        - Market Data
      summary: Get markets
      description: "Query for the exchange best bid/offer (EBBO) by instrument ID. If no query parameters are supplied then ALL available EBBOs will be returned."
      operationId: getMarketDataCefi
      parameters:
        - name: instrument_id
          in: query
          description: "Instrument ID of the market to query for. Must be a valid non-zero numeric ID."
          required: false
          schema:
            type: string
            minLength: 1
            pattern: "^[1-9][0-9]*$"
      responses:
        "200":
          description: "Successful operation."
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/MarketData"
        "400":
          $ref: "#/components/responses/BadRequest"
        "500":
          $ref: "#/components/responses/InternalError"
        "503":
          $ref: "#/components/responses/ServiceUnavailable"
      security:
        - {}
  /v1/cefi/market/auction:
    get:
      tags:
        - Market Data
      summary: Get auction state and indicative
      description: "Query for the opening-auction state (and, while in an opening auction, the indicative) by instrument ID. If no query parameters are supplied then the state for ALL available instruments is returned. `auction_mode` is always present; the `auction_indicative` object is included only while the instrument is in an opening auction (OPENING or LOCKED) and omitted otherwise."
      operationId: getMarketAuctionCefi
      parameters:
        - name: instrument_id
          in: query
          description: "Instrument ID of the market to query for. Must be a valid non-zero numeric ID."
          required: false
          schema:
            type: string
            minLength: 1
            pattern: "^[1-9][0-9]*$"
      responses:
        "200":
          description: "Successful operation."
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/AuctionState"
        "400":
          $ref: "#/components/responses/BadRequest"
        "500":
          $ref: "#/components/responses/InternalError"
        "503":
          $ref: "#/components/responses/ServiceUnavailable"
      security:
        - {}
  /v1/cefi/markets/quote:
    post:
      tags:
        - Market Data
      summary: Compute market quote
      description: >
        Calculate a quote preview for an asset using current visible order book
        depth. Supports both base quantity and quote (notional) quantity via the
        required qty_unit parameter.

        In schema `v2024_01_01`, successful responses contain only `qty` and
        `price`.

        For `qty_unit=QUOTE`, the exchange computes the largest executable base
        quantity that fits within the requested quote amount while respecting the
        instrument's base increment at the final consumed price level. As a
        result, in schema `v2026_01_23` the returned `notional` may be slightly
        less than the requested quote amount and the difference is reported in
        `notional_residual`.
      operationId: postMarketsQuoteCefi
      requestBody:
        description: "Quote request parameters. qty_unit is required and has no default."
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/MarketsQuoteRequest"
        required: true
      responses:
        "200":
          description: "Successful operation."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MarketsQuoteResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/InternalError"
        "503":
          $ref: "#/components/responses/ServiceUnavailable"
      security:
        - {}

  # ==================== CLIENT ENDPOINTS (plural - standard) ====================
  /v1/cefi/clients:
    get:
      tags:
        - Clients
      summary: Get clients
      description: "Query for a user's information."
      operationId: getClientsCefi
      parameters:
        - $ref: "#/components/parameters/XAuthTimestamp"
        - $ref: "#/components/parameters/XAuthToken"
        - $ref: "#/components/parameters/XAuthSignature"
        - name: id
          in: query
          description: "ID of client to query for."
          required: false
          schema:
            type: string
            minLength: 1
            pattern: "^[1-9][0-9]*$"
        - name: mnemonic
          in: query
          description: >
            Filters clients by mnemonic (human readable text). Returns clients
            where the mnemonic is an exact match or contains the provided substring.
            Matching is case-sensitive.
          required: false
          schema:
            type: string
      responses:
        "200":
          description: "Successful operation."
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/Client"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "408":
          $ref: "#/components/responses/Timeout"
        "415":
          $ref: "#/components/responses/UnsupportedMedia"
        "500":
          $ref: "#/components/responses/InternalError"
        "503":
          $ref: "#/components/responses/ServiceUnavailable"
      security:
        - HMAC: []
        - JWT: []
    patch:
      tags:
        - Clients
      summary: Update settings
      description: "Update client level settings."
      operationId: patchClientsCefi
      parameters:
        - $ref: "#/components/parameters/XAuthUserId"
        - $ref: "#/components/parameters/XAuthTimestamp"
        - $ref: "#/components/parameters/XAuthToken"
        - $ref: "#/components/parameters/XAuthSignature"
      requestBody:
        description: "Client settings context."
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ClientPatch"
        required: true
      responses:
        "200":
          description: "Successful operation."
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/Client"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "408":
          $ref: "#/components/responses/Timeout"
        "415":
          $ref: "#/components/responses/UnsupportedMedia"
        "500":
          $ref: "#/components/responses/InternalError"
        "503":
          $ref: "#/components/responses/ServiceUnavailable"
      security:
        - HMAC: []
        - JWT: []

  /v1/cefi/clients/fees:
    get:
      tags:
        - Clients
      summary: Get client fees
      description: >
        Returns a client's maker and taker fee tiers and the fee rates those
        tiers currently resolve to. Rates are decimal fractions of trade
        notional (`"0.003"` is 0.3%). A tier with no configured fee resolves to
        `"0"`. JWT callers may omit `client_id` to read their own client; an
        HMAC caller without `client_id` reads the client named by
        `X-Truex-Auth-UserId`.
      operationId: getClientFeesCefi
      parameters:
        - $ref: "#/components/parameters/XAuthUserId"
        - $ref: "#/components/parameters/XAuthTimestamp"
        - $ref: "#/components/parameters/XAuthToken"
        - $ref: "#/components/parameters/XAuthSignature"
        - name: client_id
          in: query
          description: >
            Exchange generated client ID to query fees for. Must be a client
            the caller may access.
          required: false
          schema:
            type: string
            minLength: 1
            pattern: "^[1-9][0-9]*$"
      responses:
        "200":
          description: "Successful operation."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ClientFees"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "408":
          $ref: "#/components/responses/Timeout"
        "500":
          $ref: "#/components/responses/InternalError"
        "503":
          $ref: "#/components/responses/ServiceUnavailable"
      security:
        - HMAC: []
        - JWT: []

  # ==================== ORDER ENDPOINTS (plural - standard) ====================
  /v1/cefi/orders:
    get:
      tags:
        - Orders
      summary: Get orders
      description: "Fetches all orders for a client entered within the past 24 hours on the exchange. A filter can be provided to limit the results."
      operationId: getOrdersPluralCefi
      parameters:
        - $ref: "#/components/parameters/XAuthUserId"
        - $ref: "#/components/parameters/XAuthTimestamp"
        - $ref: "#/components/parameters/XAuthToken"
        - $ref: "#/components/parameters/XAuthSignature"
        - name: size
          in: query
          description: "Number of records to return per page. Maximum allowed value is 100."
          required: false
          schema:
            type: integer
            default: 10
            minimum: 1
            maximum: 100
        - name: skip
          in: query
          description: "Number of records to skip before returning results. Used for offset-based pagination."
          required: false
          schema:
            type: integer
            minimum: 0
            maximum: 2147483647
        - name: timestamp
          in: query
          description: >
            A Unix UTC timestamp in nanoseconds used as a reference point for fetching orders. The query will retrieve results created **before** this timestamp, enabling precise time-based filtering and ensuring stable pagination.
            If omitted, the server responds with **400 BAD REQUEST**.
          required: true
          schema:
            type: string
            example: "1741523275598727336"
            pattern: "^[0-9]{19}$"
        - name: status
          in: query
          description: "Comma-separated list of order statuses to filter by."
          required: false
          schema:
            type: string
          examples:
            single:
              summary: Filter for active orders
              value: "ACTIVE"
            multiple:
              summary: Filter for filled and canceled orders
              value: "FILLED,CANCELED"
      responses:
        "200":
          description: "Successful operation."
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/OrderTrade"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "408":
          $ref: "#/components/responses/Timeout"
        "415":
          $ref: "#/components/responses/UnsupportedMedia"
        "500":
          $ref: "#/components/responses/InternalError"
        "503":
          $ref: "#/components/responses/ServiceUnavailable"
      security:
        - HMAC: []
        - JWT: []
    post:
      tags:
        - Orders
      summary: Create order
      description: "Create a new order for a specific instrument."
      operationId: addOrdersCefi
      parameters:
        - $ref: "#/components/parameters/XAuthUserId"
        - $ref: "#/components/parameters/XAuthTimestamp"
        - $ref: "#/components/parameters/XAuthToken"
        - $ref: "#/components/parameters/XAuthSignature"
      requestBody:
        description: "Order new request context."
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/OrderNew"
        required: true
      responses:
        "200":
          description: "Successful operation."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/OrderActive"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "408":
          $ref: "#/components/responses/Timeout"
        "415":
          $ref: "#/components/responses/UnsupportedMedia"
        "500":
          $ref: "#/components/responses/InternalError"
        "503":
          $ref: "#/components/responses/ServiceUnavailable"
      security:
        - HMAC: []
        - JWT: []
    patch:
      tags:
        - Orders
      summary: Modify order
      description: "Modify an existing active order request."
      operationId: modifyOrdersCefi
      parameters:
        - $ref: "#/components/parameters/XAuthUserId"
        - $ref: "#/components/parameters/XAuthTimestamp"
        - $ref: "#/components/parameters/XAuthToken"
        - $ref: "#/components/parameters/XAuthSignature"
      requestBody:
        description: "Order modify request context."
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/OrderModify"
        required: true
      responses:
        "200":
          description: "Successful operation."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/OrderActive"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "408":
          $ref: "#/components/responses/Timeout"
        "415":
          $ref: "#/components/responses/UnsupportedMedia"
        "500":
          $ref: "#/components/responses/InternalError"
        "503":
          $ref: "#/components/responses/ServiceUnavailable"
      security:
        - HMAC: []
        - JWT: []
  /v1/cefi/orders/{ref_id}:
    delete:
      tags:
        - Orders
      summary: Cancel order
      description: >
        Begins the cancellation process of an existing active order from the exchange. N.B. it is still possible to receive trades on the order that is being canceled.
      operationId: cancelOrdersCefi
      responses:
        "200":
          description: "Successful operation."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/OrderActive"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "408":
          $ref: "#/components/responses/Timeout"
        "415":
          $ref: "#/components/responses/UnsupportedMedia"
        "500":
          $ref: "#/components/responses/InternalError"
        "503":
          $ref: "#/components/responses/ServiceUnavailable"
      parameters:
        - $ref: "#/components/parameters/XAuthUserId"
        - $ref: "#/components/parameters/XAuthTimestamp"
        - $ref: "#/components/parameters/XAuthToken"
        - $ref: "#/components/parameters/XAuthSignature"
        - name: ref_id
          in: path
          description: "ID of order to cancel. For id_type=exchange (default): positive integer. For id_type=client: 1-18 char ASCII string or 36-char UUID."
          required: true
          schema:
            type: string
            minLength: 1
            pattern: "^(?!^0$)[a-zA-Z0-9-]+$"
        - name: id_type
          in: query
          description: "Type of ID the ref_id is, must be either 'client' or 'exchange'. If omitted will default to 'exchange'"
          required: false
          schema:
            type: string
            enum: [client, exchange]
      security:
        - HMAC: []
        - JWT: []
  /v1/cefi/orders/all:
    delete:
      tags:
        - Orders
      summary: Cancel all orders
      description: >
        Requests cancellation of every active order belonging to the authenticated client. Processed asynchronously: the gateway dispatches a cancel per order and returns **202 Accepted** immediately, listing the orders a cancel was dispatched for in `accepted`. Per-order completion is reported on the order event stream (cancel reports), not in this response. N.B. it is still possible to receive trades on an order while it is being canceled.
      operationId: cancelAllOrdersCefi
      responses:
        "202":
          description: "Request accepted; cancellations are processed asynchronously."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CancelAllOrdersAccepted"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "500":
          $ref: "#/components/responses/InternalError"
        "503":
          $ref: "#/components/responses/ServiceUnavailable"
      parameters:
        - $ref: "#/components/parameters/XAuthUserId"
        - $ref: "#/components/parameters/XAuthTimestamp"
        - $ref: "#/components/parameters/XAuthToken"
        - $ref: "#/components/parameters/XAuthSignature"
      security:
        - HMAC: []
        - JWT: []
  /v1/cefi/orders/active:
    get:
      tags:
        - Orders
      summary: Active orders
      description: "Query for orders currently active on the exchange."
      operationId: getOrdersActiveCefi
      responses:
        "200":
          description: "Successful operation."
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/OrderActive"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "408":
          $ref: "#/components/responses/Timeout"
        "415":
          $ref: "#/components/responses/UnsupportedMedia"
        "500":
          $ref: "#/components/responses/InternalError"
        "503":
          $ref: "#/components/responses/ServiceUnavailable"
      parameters:
        - $ref: "#/components/parameters/XAuthUserId"
        - $ref: "#/components/parameters/XAuthTimestamp"
        - $ref: "#/components/parameters/XAuthToken"
        - $ref: "#/components/parameters/XAuthSignature"
        - name: id
          in: query
          description: "ID of order to query for."
          required: false
          schema:
            type: string
            minLength: 1
            pattern: "^[1-9][0-9]*$"
      security:
        - HMAC: []
        - JWT: []
  /v1/cefi/orders/trade:
    get:
      tags:
        - Orders
      summary: All order trades
      description: "Fetches all trades for a client executed within the past 24 hours on the exchange."
      operationId: getOrdersTradesPluralCefi
      parameters:
        - $ref: "#/components/parameters/XAuthUserId"
        - $ref: "#/components/parameters/XAuthTimestamp"
        - $ref: "#/components/parameters/XAuthToken"
        - $ref: "#/components/parameters/XAuthSignature"
        - name: size
          in: query
          description: "Number of records to return per page. Maximum allowed value is 100."
          required: false
          schema:
            type: integer
            default: 10
            minimum: 1
            maximum: 100
        - name: skip
          in: query
          description: "Number of records to skip before returning results."
          required: false
          schema:
            type: integer
            minimum: 0
            maximum: 2147483647
        - name: timestamp
          in: query
          description: >
            A Unix UTC timestamp in nanoseconds used as a reference point for fetching trades.
          required: true
          schema:
            type: string
            example: "1741523275598727336"
            pattern: "^[0-9]{19}$"
        - name: client_id
          in: query
          description: "Comma-separated list of client IDs to filter results. Only returns trades for the specified clients."
          required: false
          schema:
            type: string
            example: "78901968715907076"
      responses:
        "200":
          description: "Successful operation."
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/OrderActivityReportTrade"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "408":
          $ref: "#/components/responses/Timeout"
        "415":
          $ref: "#/components/responses/UnsupportedMedia"
        "500":
          $ref: "#/components/responses/InternalError"
        "503":
          $ref: "#/components/responses/ServiceUnavailable"
      security:
        - HMAC: []
        - JWT: []
  /v1/cefi/orders/activity:
    get:
      tags:
        - Orders
      summary: All order activity
      description: "Fetches all activity (trades, confirms, rejects, cancels, modifications) for a client's orders."
      operationId: getOrdersActivityPluralCefi
      parameters:
        - $ref: "#/components/parameters/XAuthUserId"
        - $ref: "#/components/parameters/XAuthTimestamp"
        - $ref: "#/components/parameters/XAuthToken"
        - $ref: "#/components/parameters/XAuthSignature"
        - name: size
          in: query
          description: "Number of records to return per page. Maximum allowed value is 100."
          required: false
          schema:
            type: string
            default: 10
            minimum: 1
            maximum: 100
        - name: skip
          in: query
          description: "Number of records to skip before returning results."
          required: false
          schema:
            type: string
        - name: timestamp
          in: query
          description: >
            A Unix UTC timestamp in nanoseconds used as a reference point for fetching activity.
          required: true
          schema:
            type: string
            example: "1741523275598727336"
            pattern: "^[0-9]{19}$"
        - name: client_id
          in: query
          description: "Comma-separated list of client IDs to filter results."
          required: false
          schema:
            type: string
            example: "78901968715907076"
        - name: order_id
          in: query
          description: "Comma-separated list of order IDs to filter results."
          required: false
          schema:
            type: string
            example: "8005237327190949926"
        - name: msg_type
          in: query
          description: "Comma-separated list of activity message types to filter results (e.g., REPORT_TRADE,REPORT_CONFIRM)."
          required: false
          schema:
            type: string
            example: "REPORT_TRADE"
      responses:
        "200":
          description: "Successful operation."
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/OrderActivity"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "408":
          $ref: "#/components/responses/Timeout"
        "415":
          $ref: "#/components/responses/UnsupportedMedia"
        "500":
          $ref: "#/components/responses/InternalError"
        "503":
          $ref: "#/components/responses/ServiceUnavailable"
      security:
        - HMAC: []
        - JWT: []
  /v1/cefi/orders/status/{ref_id}:
    get:
      tags:
        - Orders
      summary: Status order
      description: >
        Fetches the current status of a specific order identified by `ref_id`.
      operationId: getOrdersStatusCefi
      responses:
        "200":
          description: "Successful operation."
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/Order"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "408":
          $ref: "#/components/responses/Timeout"
        "415":
          $ref: "#/components/responses/UnsupportedMedia"
        "500":
          $ref: "#/components/responses/InternalError"
        "503":
          $ref: "#/components/responses/ServiceUnavailable"
      parameters:
        - $ref: "#/components/parameters/XAuthUserId"
        - $ref: "#/components/parameters/XAuthTimestamp"
        - $ref: "#/components/parameters/XAuthToken"
        - $ref: "#/components/parameters/XAuthSignature"
        - name: ref_id
          in: path
          description: "ID of order to status. For id_type=exchange (default): positive integer. For id_type=client: 1-18 char ASCII string or 36-char UUID."
          required: true
          schema:
            type: string
            minLength: 1
            pattern: "^(?!^0$)[a-zA-Z0-9-]+$"
          example: "123456789"
        - name: id_type
          in: query
          description: "Type of ID the ref_id is, must be either 'client' or 'exchange'. If omitted will default to 'exchange'"
          required: false
          schema:
            type: string
            enum: [client, exchange]
      security:
        - HMAC: []
        - JWT: []

  # ==================== BALANCE ENDPOINTS (plural - standard) ====================
  /v1/cefi/balances:
    get:
      tags:
        - Balances
      summary: Get balance
      description: "Query for balance information current allocated to the exchange."
      operationId: getBalancesCefi
      parameters:
        - $ref: "#/components/parameters/XAuthUserId"
        - $ref: "#/components/parameters/XAuthTimestamp"
        - $ref: "#/components/parameters/XAuthToken"
        - $ref: "#/components/parameters/XAuthSignature"
        - name: asset_id
          in: query
          description: "ID of asset to query balance information for."
          required: false
          schema:
            type: string
            minLength: 1
            pattern: "^[1-9][0-9]*$"
        - name: asset_name
          in: query
          description: "Name of asset to query balance information for. ASCII alphanumeric only."
          required: false
          schema:
            type: string
            minLength: 1
            pattern: "^[a-zA-Z0-9_-]+$"
        - name: client_id
          in: query
          description: "Exchange generated client ID to query balance information for."
          required: false
          schema:
            type: string
            minLength: 1
            pattern: "^[1-9][0-9]*$"
      responses:
        "200":
          description: "Successful operation."
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/Balances"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "408":
          $ref: "#/components/responses/Timeout"
        "415":
          $ref: "#/components/responses/UnsupportedMedia"
        "500":
          $ref: "#/components/responses/InternalError"
        "503":
          $ref: "#/components/responses/ServiceUnavailable"
      security:
        - HMAC: []
        - JWT: []

  /v1/cefi/balances/activity:
    get:
      tags:
        - Balances
      summary: Get balance activity
      description: "Query balance update activity (settlements and adjustments) for a specific client and/or asset. Returns only balance update messages, ordered by timestamp."
      operationId: getBalanceActivityCefi
      parameters:
        - $ref: "#/components/parameters/XAuthUserId"
        - $ref: "#/components/parameters/XAuthTimestamp"
        - $ref: "#/components/parameters/XAuthToken"
        - $ref: "#/components/parameters/XAuthSignature"
        - name: client_id
          in: query
          description: "Exchange generated client ID to filter activity for."
          required: false
          schema:
            type: string
            minLength: 1
            pattern: "^[1-9][0-9]*$"
        - name: asset_id
          in: query
          description: "Exchange generated asset ID to filter activity for."
          required: false
          schema:
            type: string
            minLength: 1
            pattern: "^[1-9][0-9]*$"
        - name: skip
          in: query
          description: "Number of records to skip for pagination."
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
        - name: size
          in: query
          description: "Maximum number of records to return."
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 10
      responses:
        "200":
          description: "Successful operation."
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/BalanceActivity"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "408":
          $ref: "#/components/responses/Timeout"
        "415":
          $ref: "#/components/responses/UnsupportedMedia"
        "500":
          $ref: "#/components/responses/InternalError"
        "503":
          $ref: "#/components/responses/ServiceUnavailable"
      security:
        - HMAC: []
        - JWT: []

  # ==================== TRANSFER ENDPOINTS (plural - standard) ====================
  /v1/cefi/transfers:
    get:
      tags:
        - Transfers
      summary: Get transfer
      description: "Fetches all transfers for a client within the past 24 hours on the exchange."
      operationId: getTransfersPluralCefi
      parameters:
        - $ref: "#/components/parameters/XAuthUserId"
        - $ref: "#/components/parameters/XAuthTimestamp"
        - $ref: "#/components/parameters/XAuthToken"
        - $ref: "#/components/parameters/XAuthSignature"
        - name: size
          in: query
          description: "Number of transfers to return per page. Maximum allowed value is 100."
          required: false
          schema:
            type: integer
            default: 10
            minimum: 1
            maximum: 100
        - name: skip
          in: query
          description: "Number of records to skip before returning results. Used for offset-based pagination."
          required: false
          schema:
            type: integer
            minimum: 0
            maximum: 2147483647
        - name: timestamp
          in: query
          description: >
            A Unix UTC timestamp in nanoseconds used as a reference point for fetching transfers.
          required: true
          schema:
            type: string
            example: "1741523275598727336"
            pattern: "^[0-9]{19}$"
      responses:
        "200":
          description: "Successful response with a list of transfers."
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/HistoricalTransfer"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "408":
          $ref: "#/components/responses/Timeout"
        "415":
          $ref: "#/components/responses/UnsupportedMedia"
        "500":
          $ref: "#/components/responses/InternalError"
        "503":
          $ref: "#/components/responses/ServiceUnavailable"
      security:
        - HMAC: []
        - JWT: []
    post:
      tags:
        - Transfers
      summary: Initiate transfer
      description: "Initiate a new transfer of assets to/from the exchange."
      operationId: addTransfersPluralCefi
      parameters:
        - $ref: "#/components/parameters/XAuthUserId"
        - $ref: "#/components/parameters/XAuthTimestamp"
        - $ref: "#/components/parameters/XAuthToken"
        - $ref: "#/components/parameters/XAuthSignature"
      requestBody:
        description: "Transfer request object."
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Transfer"
        required: true
      responses:
        "200":
          description: "Successful operation."
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TransferDetails"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "408":
          $ref: "#/components/responses/Timeout"
        "415":
          $ref: "#/components/responses/UnsupportedMedia"
        "500":
          $ref: "#/components/responses/InternalError"
        "503":
          $ref: "#/components/responses/ServiceUnavailable"
      security:
        - HMAC: []
        - JWT: []
  /v1/cefi/transfers/active:
    get:
      tags:
        - Transfers
      summary: Get Active transfers
      description: "Fetches all currently active transfers on the exchange."
      operationId: getActiveTransfersPluralCefi
      parameters:
        - $ref: "#/components/parameters/XAuthUserId"
        - $ref: "#/components/parameters/XAuthTimestamp"
        - $ref: "#/components/parameters/XAuthToken"
        - $ref: "#/components/parameters/XAuthSignature"
        - name: transfer_id
          in: query
          description: "Unique identifier of a specific transfer. If omitted, all active transfers for the client will be returned."
          required: false
          schema:
            type: string
            minLength: 1
            pattern: "^[1-9][0-9]*$"
      responses:
        "200":
          description: "Successful response with active transfers."
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/TransferDetails"
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "408":
          $ref: "#/components/responses/Timeout"
        "415":
          $ref: "#/components/responses/UnsupportedMedia"
        "500":
          $ref: "#/components/responses/InternalError"
        "503":
          $ref: "#/components/responses/ServiceUnavailable"
      security:
        - HMAC: []
        - JWT: []

components:
  schemas:
    ServiceHealth:
      type: object
      description: Status information for the REST API Gateway.
      required:
        - status
        - timestamp
        - service
      properties:
        status:
          type: string
          description: Overall readiness indicator for the API.
          enum:
            - healthy
            - degraded
          example: healthy
        timestamp:
          type: string
          description: UTC timestamp the status was generated formatted as `YYYY-MM-DD HH:MM:SS`.
          example: "2025-01-15 14:30:00"
        service:
          type: string
          description: Name of the service reporting health.
          example: rag
    ApiVersions:
      type: object
      description: Information about supported API versions.
      required:
        - supported_versions
        - default_version
        - version_header
      properties:
        supported_versions:
          type: array
          description: List of all supported API versions.
          items:
            $ref: "#/components/schemas/ApiVersionInfo"
        default_version:
          type: string
          description: The version used when no X-Truex-Version header is provided.
          example: "v2024_01_01"
        version_header:
          type: string
          description: The header name to use for specifying API version.
          example: "X-Truex-Version"
    ApiVersionInfo:
      type: object
      description: Information about a specific API version.
      required:
        - version
        - deprecated
      properties:
        version:
          type: string
          description: The version identifier to use in the X-Truex-Version header.
          example: "v2024_01_01"
        deprecated:
          type: boolean
          description: Whether this version is deprecated and scheduled for removal.
          example: false
        deprecation_date:
          type: string
          description: >
            HTTP-date format timestamp of when the version was deprecated.
            Only present if deprecated is true.
          example: "Sat, 01 Feb 2025 00:00:00 GMT"
        sunset_date:
          type: string
          description: >
            HTTP-date format timestamp of when the version will be removed.
            Only present if deprecated is true.
          example: "Sun, 01 Feb 2026 00:00:00 GMT"
    Asset:
      type: object
      properties:
        id:
          type: string
          pattern: "^[1-9][0-9]*$"
          example: "78901949717282824"
          description: "Exchange assigned ID of asset."
        status:
          enum:
            - DISABLED
            - ACTIVE
            - INVALID
          type: string
          example: "ACTIVE"
          description: "Current asset state."
        fields:
          type: object
          properties:
            name:
              type: string
              maxLength: 31
              example: "BTC"
              description: "Human readable name of the asset."
            min_transfer_qty:
              type: string
              example: "1000.01"
              description: "The minimum amount of an asset that can be transferred in a single transaction, specific to each asset."
            max_transfer_qty:
              type: string
              example: "9999.99"
              description: "The maximum amount of an asset that can be transferred in a single transaction, specific to each asset."
            flags:
              type: array
              uniqueItems: true
              items:
                type: string
                enum:
                  - REFERENCE_ASSET
                  - STABLECOIN
                example: "STABLECOIN"
              description: >
                A platform-defined value that provides additional metadata or classification for the asset. This flag is used to denote specific attributes or roles associated with the asset within the exchange ecosystem.

                - **REFERENCE_ASSET** Indicates that the asset is the default reference asset for the exchange. It serves as the primary asset for settling trades by default and is used as the basis for calculating fees.

                - **STABLECOIN** Indicates if the asset is a stablecoin (value pegged to a external source such as fiat currency.
    InstrumentStat:
      type: object
      properties:
        last_24hr_notional:
          type: string
          example: "4325606.30380"
          description: "The notional (quantity * price) amount of REFERENCE_ASSET traded over the last 24hr period."
        last_24hr_quantity:
          type: string
          example: "123754.234598480"
          description: "The quantity traded over the last 24 hour period."
    Instrument:
      type: object
      properties:
        id:
          type: string
          pattern: "^[1-9][0-9]*$"
          example: "78901949723181070"
          description: "Exchange assigned ID of the instrument."
        status:
          enum:
            - INVALID
            - DISABLED
            - OPENING
            - ACTIVE
            - HALTED
          type: string
          example: "ACTIVE"
          description: "Current instrument state. INVALID indicates the requested instrument ID does not exist."
        info:
          type: object
          properties:
            symbol:
              type: string
              maxLength: 31
              example: "BTC-PYUSD"
              description: "Human readable representation of the instrument."
            reference_price:
              type: string
              example: "75000.50"
              description: "Price used for initial price limit/band calcuations."
            base_asset_id:
              type: string
              pattern: "^[1-9][0-9]*$"
              example: "78901949718265865"
              description: "ID of the base asset."
            quote_asset_id:
              type: string
              pattern: "^[1-9][0-9]*$"
              example: "78901949717282824"
              description: "ID of the quote asset."
            price_limit_window_secs:
              type: string
              example: "3600"
              description: "Number of seconds in the price limit's sliding window."
            price_limit_percent:
              type: string
              example: "0.015"
              description: "Specifies the percentage threshold for price movement beyond a reference price (e.g., the midpoint or previous close) at which the exchange will take action. If the price of a trade or order breaches this threshold, the exchange may halt trading, trigger a circuit breaker, or initiate other predefined actions to ensure market stability."
            price_bands_percent:
              type: string
              example: "0.025"
              description: "Defines the acceptable price range for order validation within the market. The price bands ensure that orders are priced within a range around the market's midpoint, adjusted for increments and thresholds."
        stats:
          type: object
          $ref: "#/components/schemas/InstrumentStat"
    MarketQuote:
      type: object
      properties:
        price:
          type: string
          example: "110865.50"
          description: "Price at this level."
        qty:
          type: string
          example: "0.00018"
          description: "Aggregate quantity resting at this level."
        order_count:
          type: string
          example: "10"
          description: "Number of orders resting at this level."
    MarketTrade:
      type: object
      properties:
        price:
          type: string
          example: "110868"
          description: "Price of the last trade."
        qty:
          type: string
          example: "0.00901"
          description: "Quantity of the last trade."
        timestamp:
          type: string
          example: "1752156263825281640"
          description: "The Unix UTC timestamp (in nanoseconds) when the trade was executed."
    MarketsQuoteRequest:
      type: object
      required:
        - qty
        - instrument_id
        - side
        - qty_unit
      properties:
        qty:
          type: string
          minLength: 1
          pattern: "^[0-9]+(\\.[0-9]+)?$"
          example: "1.5"
          description: "The quantity to quote. Interpretation depends on qty_unit: for BASE this is the base asset amount, for QUOTE this is the notional (e.g. USD) amount."
        instrument_id:
          type: string
          minLength: 1
          pattern: "^[1-9][0-9]*$"
          example: "1"
          description: "The instrument ID for which to calculate the quote. Must be a valid non-zero numeric ID."
        side:
          type: string
          enum: [BUY, SELL]
          example: "BUY"
          description: "The side of the quote request. BUY calculates the price to buy the base asset, SELL calculates the price to sell."
        qty_unit:
          type: string
          enum: [BASE, QUOTE]
          example: "BASE"
          description: "Unit of the qty field. BASE means qty is in base asset units, QUOTE means qty is in quote asset (notional) units. Required — no default."
      additionalProperties: false
    MarketsQuoteResponse:
      type: object
      properties:
        qty:
          type: string
          example: "1.5"
          description: "The base quantity. For qty_unit=QUOTE, this is the computed base amount. For qty_unit=BASE, this echoes back the requested base quantity."
        price:
          type: string
          example: "50025.50"
          description: "The calculated VWAP (Volume-Weighted Average Price) across consumed order book levels."
        notional:
          type: string
          example: "75038.25"
          description: "Schema `v2026_01_23` only. The expected quote amount consumed from visible order book liquidity."
        notional_residual:
          type: string
          example: "0.10"
          description: "Schema `v2026_01_23` only. The unfilled portion of the requested quote amount. This is typically zero, but for qty_unit=QUOTE it can be positive when the remaining amount is smaller than one base increment at the final consumed price level."
    MarketData:
      type: object
      properties:
        id:
          type: string
          pattern: "^[1-9][0-9]*$"
          example: "78901949723181070"
          description: "Exchange assigned ID of the market data."
        symbol:
          type: string
          maxLength: 31
          example: "BTC-PYUSD"
          description: "Human readable representation of the instrument."
        info:
          type: object
          properties:
            last_trade:
              type: object
              $ref: "#/components/schemas/MarketTrade"
              description: "Last trade information."
            best_bid:
              type: object
              $ref: "#/components/schemas/MarketQuote"
              description: "Current (at the time of request) exchange best bid."
            best_ask:
              type: object
              $ref: "#/components/schemas/MarketQuote"
              description: "Current (at the time of request) exchange best ask."
            last_update:
              type: string
              example: "1752156513225654386"
              description: "A UTC Unix epoch in nanoseconds indicating when the book was last updated."
    AuctionIndicative:
      type: object
      description: "Opening-auction state and indicative for an instrument. All fields are zero and status is INVALID when the instrument is not in an opening auction."
      properties:
        indicative_price:
          type: string
          example: "100"
          description: "Indicative opening price the auction would currently clear at."
        matched_volume:
          type: string
          example: "0"
          description: "Volume that would cross at the indicative price."
        projected_best_bid_price:
          type: string
          example: "0"
          description: "Projected best bid price after a hypothetical uncross; zero when no bids would remain."
        projected_best_ask_price:
          type: string
          example: "0"
          description: "Projected best ask price after a hypothetical uncross; zero when no asks would remain."
        timestamp:
          type: string
          example: "1752156513225654386"
          description: "A UTC Unix epoch in nanoseconds indicating when the indicative was computed."
        status:
          type: string
          enum:
            - INVALID
            - NORMAL
            - INSUFFICIENT_BUY_INTEREST
            - INSUFFICIENT_SELL_INTEREST
            - NO_CROSS
          example: "INVALID"
          description: "Health of the auction indicative calculation."
    AuctionState:
      type: object
      description: "Opening-auction state for an instrument, returned by /v1/cefi/market/auction. `auction_mode` is always present; `auction_indicative` is included only while the instrument is in an opening auction (OPENING or LOCKED) and omitted otherwise (Coinbase-style nullable object)."
      required:
        - auction_mode
      properties:
        auction_mode:
          type: boolean
          example: true
          description: "True while the instrument is in an opening auction (ST_OPENING or ST_LOCKED). The auction_indicative object is present only when this is true."
        auction_indicative:
          $ref: "#/components/schemas/AuctionIndicative"
          description: "Indicative opening price and projected book. Present only when auction_mode is true; omitted otherwise."
    Client:
      type: object
      properties:
        id:
          type: string
          pattern: "^[1-9][0-9]*$"
          example: "78901949710204932"
        status:
          enum:
            - INITIALIZED
            - ACTIVE
            - DISABLED
          type: string
          example: "ACTIVE"
          description: "Current client state."
        info:
          type: object
          properties:
            organization_id:
              type: string
              format: uuid
              description: "Must be UUIDv4. [RFC 9562](https://datatracker.ietf.org/doc/html/rfc9562#name-uuid-version-4)."
              example: "ed671d2b-bb9e-4cf5-9eb4-71b6db672207"
            mnemonic:
              type: string
              example: "CLIENT1"
              description: "Client supplied human readable name of the client entity."
            type:
              type: string
              enum:
                - INSTITUTION
                - INDIVIDUAL
                - APPLICATION
              example: "INDIVIDUAL"
              description: "Client designation."
            maker_fee_tier:
              type: integer
              example: 1
              description: "Client's current maker fee tier."
            taker_fee_tier:
              type: integer
              example: 2
              description: "Client's current taker fee tier."
            self_trade_prevention:
              type: string
              enum:
                - INVALID
                - NONE
                - CANCEL_AGGRESSIVE
                - CANCEL_BOTH
              example: "CANCEL_AGGRESSIVE"
              description: >
                Client level self trade protection instruction.

                * **INVALID** Client level self trade protections are in an invalid state and may result in order rejection.

                * **NONE** No self trade protections are enabled for this client.  Can be overridden at the order level.

                * **CANCEL_AGGRESSIVE** All orders entered with this client ID will have cancel aggressive self trade protections enabled.

                * **CANCEL_BOTH** All order entered with this client ID will have cancel both self trade protections enabled.
        controls:
          type: object
          description: "Set by the exchange; read-only to clients."
          properties:
            rate_limit_tier:
              type: integer
              example: 0
              description: "The client's request rate-limit tier; 0 is the default."
            instrument_entitlements:
              type: array
              items:
                type: string
                enum:
                  - SPOT
                  - OUTCOME
              example: ["SPOT"]
              description: "Instrument entitlements the client holds."
            flags:
              type: integer
              example: 0
              description: "Reserved client flags."
    ClientFees:
      type: object
      description: A client's fee tiers and the rates they resolve to.
      required:
        - client_id
        - maker_fee_tier
        - taker_fee_tier
        - maker_fee_rate
        - taker_fee_rate
      properties:
        client_id:
          type: string
          example: "1234567890"
          description: "Exchange generated client ID."
        maker_fee_tier:
          type: integer
          example: 1
          description: "Client's current maker fee tier."
        taker_fee_tier:
          type: integer
          example: 2
          description: "Client's current taker fee tier."
        maker_fee_rate:
          type: string
          example: "0.0005"
          description: >
            Fee rate charged on maker fills, as a decimal fraction of trade
            notional. Negative values are rebates.
        taker_fee_rate:
          type: string
          example: "0.003"
          description: >
            Fee rate charged on taker fills, as a decimal fraction of trade
            notional.
    ClientPatch:
      type: object
      required: ["id"]
      properties:
        id:
          type: string
          pattern: "^[1-9][0-9]*$"
          example: "78901949710270469"
        info:
          type: object
          properties:
            self_trade_prevention:
              type: string
              enum:
                - NONE
                - CANCEL_AGGRESSIVE
                - CANCEL_BOTH
              example: "CANCEL_BOTH"
              description: >
                Set the client level self trade protection instruction.

                Individual and application clients may switch between
                **CANCEL_AGGRESSIVE** and **CANCEL_BOTH** but may not disable
                self trade protection; setting **NONE** is rejected for those
                client types.

                * **NONE** No self trade protections are enabled for this client.

                * **CANCEL_AGGRESSIVE** All orders entered with this client ID will have cancel aggressive self trade protections enabled.

                * **CANCEL_BOTH** All order entered with this client ID will have cancel both self trade protections enabled.
    OrderNew:
      type: object
      required: ["info"]
      properties:
        external_id:
          type: string
          example: "321e7654-e89b-42d4-a456-426614174000"
          description: >
            A unique identifier created by the client.  Must be in one of the following formats:

            * **UUID** version 4 in its human readable form, with hypens, and in lowercase.

            * **ASCII** character string of up to 18 characters containing only the unreserved URL characters: letters (a–z, A–Z), digits (0–9), hyphen (-), underscore (\_), period (.), and tilde (~). 
        info:
          type: object
          $ref: "#/components/schemas/OrderInfo"
    OrderInfo:
      type: object
      required: ["client_id", "instrument_id", "qty", "price", "side", "type"]
      properties:
        msg_id:
          type: string
          pattern: "^[1-9][0-9]*$"
          example: "799477895858487977"
          description: "ID of last message to act upon the order."
        parent_id:
          type: string
          pattern: "^[1-9][0-9]*$"
          example: "432351810263056385"
          description: "ID of the application creating the order, may be zero."
        client_id:
          type: string
          pattern: "^[1-9][0-9]*$"
          example: "78901949710204932"
          description: "The client ID the order will be entered on behalf of."
        instrument_id:
          type: string
          pattern: "^[1-9][0-9]*$"
          example: "78901949723181070"
          description: "The ID of the instrument the order will transact in."
        qty:
          type: string
          example: "0.00145"
          description: "The amount of base asset the order is requesting to tranasct, or of quote asset when the `QUOTE_QTY` flag is set."
        price:
          type: string
          example: "111067"
          description: "The highest or lowest price the order will buy or sell, respectively, at. Only required for LIMIT orders; optional on MARKET orders as a worst-price cap."
        flags:
          type: array
          uniqueItems: true
          items:
            type: string
            enum:
              - USE_AGGRESSIVE_PRICING
              - QUOTE_QTY
            example: "USE_AGGRESSIVE_PRICING"
          description: >
            General order flags that can be combined and used together.

            * **USE_AGGRESIVE_PRICING** Applicable to market orders only. When enabled, the exchange calculates a price for the market order that is more aggressive than the current best bid or offer. This is useful when prioritizing liquidity capture over minimizing price slippage.

            * **QUOTE_QTY** Applicable to market orders only. `qty` is an amount of the quote asset, e.g. buy 10 PYUSD of BTC. The exchange converts it to a base quantity against the current book at entry and rejects the order if the book cannot fill it within the price band, or within `price` when one is supplied. Accepted and reported orders carry the converted base `qty`.
        side:
          type: string
          enum:
            - BUY
            - SELL
          description: >
            Side of order, can be `BUY` or `SELL`

            * **BUY** Provide trader's quote asset to acquire the base asset.

            * **SELL** Provide trader's base asset to acquire the quote asset.
          example: "BUY"
        type:
          type: string
          enum:
            - LIMIT
            - MARKET
            - NOTIONAL_LIMIT
          description: >
            Type of order, can be `LIMIT`, `MARKET`, or the deprecated `NOTIONAL_LIMIT`.

            * **LIMIT** A specified limit price sets the maximum amount in quote currency units that the order will exchange to acquire the base currency.

            * **MARKET** The order uses the CeFi exchange market price at time of order entry plus/minus (for buy/sell respectively) the max price allowed by the price band risk limits for the instrument.

            * **NOTIONAL_LIMIT** *Deprecated — use `MARKET` with the `QUOTE_QTY` flag.* The quote amount is sent in `price` and `qty` must be zero. The exchange accepts it as `MARKET` + `QUOTE_QTY`, so the order is reported with that type and flag.
          example: "LIMIT"
        tif:
          type: string
          enum:
            - GTC
            - IOC
          description: >
            The "Time In Force" (TIF) of an order indicates how long the order will remain active before being canceled, can be `GTC`, `IOC`.

            * **GTC** (Good-Till-Cancel) Order remains active for up to 30 days from the time of entry. 

            * **IOC** (Immediate-Or-Cancel) Order will execute as much of the order as possible up to the requested price, provided there are existing orders that match or improve upon the price. An `IOC` order will cancel any unfilled quantity back to the requestor. If no matching orders are found, the `IOC` order will be canceled immediately. If the TIF is omitted, the order will default to `GTC`.
          example: "GTC"
        exec_inst_flags:
          type: array
          uniqueItems: true
          items:
            type: string
            enum:
              - ALO
              - AON
            example: "ALO"
          description: >
            Execution specific instructions that can be combined and used together.

            * **ALO** Ensures the order adds liquidity to the market rather than removing it. When this flag is enabled, the order will only be placed if it would not immediately execute against the current best bid or offer. If the order would otherwise result in an immediate match, it will be canceled or adjusted based on the exchange's rules.
            * **AON** Requests that the order either fully executes or cancel back to user with nothing done. All or none (AON) is only valid on market orders.
        hold_fee_rate:
          type: string
          example: "0.002"
          description: >
            The rate used to hold fee asset against the order. This is not necessarily the fee charge associated with the order.

            May be supplied on a new order to hold at a higher rate than the exchange's own fee; omit it (or send "0") to hold at the exchange rate for the client's fee tiers. A rate below the exchange fee is rejected.
        stp:
          type: string
          enum:
            - INVALID
            - NONE
            - CANCEL_AGGRESSIVE
            - CANCEL_BOTH
          example: "NONE"
          description: >
            Order level self trade protection instruction.

            * **INVALID** Order level self trade protections are in an invalid state and may result in order rejection.

            * **NONE** No self trade protections are enabled for this order.  

            * **CANCEL_AGGRESSIVE** This order will be canceled in the result of a self trade.

            * **CANCEL_BOTH** This order and the resting order will both be canceled in the result of a self trade.
    OrderModify:
      type: object
      required: ["info"]
      properties:
        id:
          type: string
          example: "1159718398822187014"
          description: >
            The internal order ID of the order to be modified. This is the id that was set by the exchange and should be a purely numeric string.
        external_id:
          type: string
          example: "123e7654-e89b-42d4-a456-426614174000"
          description: >
            The external ID for the order to be modified set by the client. Must be in one of the following formats:

            * **UUID** version 4 in its human readable form, with hypens, and in lowercase.

            * **ASCII** character string of up to 18 characters containing only the unreserved URL characters: letters (a–z, A–Z), digits (0–9), hyphen (-), underscore (\_), period (.), and tilde (~). 
        info:
          type: object
          $ref: "#/components/schemas/ModifyInfo"
    ModifyInfo:
      type: object
      required: ["client_id", "new_qty", "new_price"]
      properties:
        msg_id:
          type: string
          pattern: "^[1-9][0-9]*$"
          example: "1"
          description: "ID of last message to act upon the order."
        parent_id:
          type: string
          pattern: "^[1-9][0-9]*$"
          example: "1"
          description: "ID of the application creating the order, may be zero."
        client_id:
          type: string
          pattern: "^[1-9][0-9]*$"
          example: "1"
          description: "The client ID the modification will be entered on behalf of."
        prev_modify:
          type: string
          example: "0"
          description: "ID of previous modify to act upon the order."
        new_qty:
          type: string
          example: "0"
          description: "The new amount of base asset the order is requesting to tranasct."
        new_price:
          type: string
          example: "0"
          description: "The new highest or lowest price the order will buy or sell, respectively, at. Only required for LIMIT orders."
        new_type:
          type: string
          enum:
            - MARKET
          example: "MARKET"
          description: >
            `LIMIT` orders may be converted to `MARKET` orders. The new `MARKET` order will immediately execute against the resting side of the order book providing there is available liquidity on the contra side of the request.
    CancelAllOrdersAccepted:
      type: object
      description: >
        Acknowledgement of an asynchronous cancel-all request. `accepted` lists the ref ids of orders a cancel was dispatched for. Per-order completion is reported on the order event stream (cancel reports), not in this response.
      properties:
        accepted:
          type: array
          description: "Ref ids of orders a cancel was dispatched for."
          items:
            type: string
            example: "799477895858487977"
      required:
        - accepted
    OrderActive:
      type: object
      properties:
        id:
          type: string
          example: "799477895858487977"
        status:
          enum:
            - INITIALIZED
            - NEW_PENDING
            - REJECTED
            - ACTIVE
            - FILLED
            - CANCEL_PENDING
            - CANCELED
            - MODIFY_PENDING
          type: string
          example: "ACTIVE"
          description: >
            The current status of the order.

            * **INITIALIZED** Order has been created, but not sent yet.

            * **NEW_PENDING** Order has been sent, but not confirmed by the exchange or downstream process.

            * **REJECTED** An order setting or market condition prevents the order from getting processed.

            * **ACTIVE** The order was accepted by the system and open to trading (order and market conditions permitting).

            * **FILLED** The entire order traded.

            * **CANCEL_PENDING** Indicates a cancel request was received and being processed.

            * **CANCELED** The order was canceled from a cancel request, order conditions, or market conditions.

            * **MODIFY_PENDING** Indicates a modification request was received and being processed.
        order_info:
          type: object
          $ref: "#/components/schemas/OrderInfo"
        modify_info:
          type: object
          $ref: "#/components/schemas/ModifyInfo"
        external_id:
          type: string
          example: "EXT-ORDER-123"
          description: >
            A unique identifier created by the client.  Must be in one of the following formats:

            * **UUID** version 4 in its human readable form, with hypens, and in lowercase.

            * **ASCII** character string of up to 18 characters containing only the unreserved URL characters: letters (a–z, A–Z), digits (0–9), hyphen (-), underscore (\_), period (.), and tilde (~). 
        ref_external_id:
          type: string
          example: "REF-EXT-ORDER-123"
          description: >
            A unique identifier created by the client.  Must be in one of the following formats:

            * **UUID** version 4 in its human readable form, with hypens, and in lowercase.

            * **ASCII** character string of up to 18 characters containing only the unreserved URL characters: letters (a–z, A–Z), digits (0–9), hyphen (-), underscore (\_), period (.), and tilde (~). 
        pending_qty:
          type: string
          example: "0"
          description: "Order quantity that has been acknowledge by the exchange but is not yet trading."
        leaves_qty:
          type: string
          example: "0.00145"
          description: "Order quantity that is currently active in the market."
        executed_qty:
          type: string
          example: "0.00239"
          description: "Amount of quantity currently executed."
        executed_vwap:
          type: string
          example: "111050.5"
          description: "Volume weighted average price calculation for all executions on the order."
    Order:
      allOf:
        - $ref: "#/components/schemas/OrderActive"
        - type: object
          properties:
            total:
              type: string
              example: "3500000"
              description: "Total notional (quantity X price) of the order."
            timestamp:
              type: string
              example: "1752159930164131767"
              description: "UNIX UTC nanosecond timestamp of when the order was created."
            update_timestamp:
              type: string
              example: "1752159930192000004"
              description: "UNIX UTC nanosecond timestamp of when the order was last updated."
    BalanceActivity:
      type: object
      properties:
        msg_type:
          type: string
          enum:
            - UPDATE
          description: "Message type. Activity endpoint only returns UPDATE messages."
        msg_action:
          type: string
          example: "ACCEPT"
          description: "Message action status."
        amount:
          type: string
          pattern: "^[-+]?\\d+(\\.\\d+)?$"
          example: "100.50"
          description: "Amount of the balance update."
        client_id:
          type: string
          pattern: "^[1-9][0-9]*$"
          example: "78901985055342602"
          description: "Exchange assigned client ID."
        asset_id:
          type: string
          pattern: "^[1-9][0-9]*$"
          example: "78901985048264711"
          description: "Exchange assigned asset ID."
        type:
          type: string
          enum:
            - TRADE_SETTLEMENT
            - FEE_SETTLEMENT
            - BALANCE_ADJUSTMENT
          description: "Type of balance update."
        timestamp:
          type: string
          example: "1752159930192000004"
          description: "UNIX UTC nanosecond timestamp of the update."
        ownership:
          type: object
          properties:
            client_id:
              type: string
              description: "Client ID that owns this balance entry."
    Balance:
      type: object
      description: >
        Per-asset balance entry.


        **Do not treat `balance` as your tradable amount.** `balance` is the
        gross amount on the exchange; it does **not** subtract the holds placed
        against open orders and pending transfers. Sizing an order off `balance`
        alone will lead to rejections for insufficient balance.


        Compute the amount you can trade with as:


        ```

        tradable = balance + unsettled - order_hold - transfer_hold

        ```


        For the asset used to pay fees (the settlement stablecoin), also subtract
        the account-level `fees_hold` and `unsettled_fees` from `Balances`:


        ```

        tradable(fee asset) = balance + unsettled - order_hold - transfer_hold - fees_hold - unsettled_fees

        ```


        Withdrawable amount is stricter: positive `unsettled` (inbound, not yet
        settled) does **not** count, while negative `unsettled` (an outbound
        obligation) still reduces it:


        ```

        withdrawable = balance + min(unsettled, 0) - order_hold - transfer_hold
        (minus fees_hold and any positive unsettled_fees for the fee asset)

        ```


        See the Balances guide for worked examples.
      properties:
        asset_id:
          type: string
          pattern: "^[1-9][0-9]*$"
          example: "78901985048264711"
          description: "Exchange assigned entity ID. For balance entities this will be the same as your client id."
        balance:
          type: string
          example: "10000000.45"
          description: "Gross amount of asset on the exchange. This is NOT your tradable amount — it does not exclude holds. See `order_hold`, `transfer_hold`, and the schema description for how to derive tradable/withdrawable amounts."
        unsettled:
          type: string
          example: "0"
          description: "Net amount traded but awaiting settlement by the asset custodian. Positive = inbound (counts toward tradable, not withdrawable); negative = an outbound obligation (reduces both tradable and withdrawable)."
        order_hold:
          type: string
          example: "3586008.49833"
          description: "Amount held against open/resting orders. Subtract from `balance` to get tradable amount; released as orders fill or cancel."
        transfer_hold:
          type: string
          example: "100.00"
          description: "Amount held against pending transfers/withdrawals. Subtract from `balance` to get tradable amount; released when the transfer settles or is rejected."
        state:
          type: string
          enum:
            - INVALID
            - INITIALIZED
            - OPEN
            - LOCKED
            - CLOSING
          example: "OPEN"
          description: >
            Current state of the balance.

            * **INVALID** Balance is not active on the exchange and currently in an error state.

            * **INITIALIZED** Balance has been created on the exchange but is not currently active.

            * **OPEN** Balance is active on the exchange.

            * **LOCKED** Balance is on the exchange but cannot be used for transactions.

            * **CLOSING** Balance is currently be moved off of the exchange and cannot be used for transactions."
    Balances:
      type: object
      properties:
        id:
          type: string
          example: "78901985055342602"
          description: "Exchange assigned entity ID."
        status:
          type: string
          enum:
            - INVALID
          example: "INVALID"
          description: "Exchange only status value, will always be INVALID."
        unsettled_fees:
          type: string
          example: "9210.236229375"
          description: "Account-level fees accrued from trading but not yet settled, denominated in the fee asset (settlement stablecoin). Reduces the tradable/withdrawable amount of the fee asset only."
        fees_hold:
          type: string
          example: "179300.4249165"
          description: "Account-level amount of the fee asset held against anticipated fees on open orders. Reduces the tradable/withdrawable amount of the fee asset only."
        balances:
          type: array
          items:
            $ref: "#/components/schemas/Balance"
    FiatInstructions:
      type: object
      required: ["fiat_account_id", "identity_id", "account_id", "includes_fee"]
      properties:
        fiat_account_id:
          type: string
          format: uuid
          description: "The ID of the fiat account to use for the transfer."
          example: "ed671d2b-bb9e-4cf5-9eb4-71b6db672207"
        identity_id:
          type: string
          format: uuid
          description: "The identity ID of the individual submitting the transfer."
          example: "b2a99c93-f1ee-41ed-9e9e-ec704cfbca4b"
        account_id:
          type: string
          format: uuid
          description: The account ID of the institution submitting the transfer.
          example: "b2a99c93-f1ee-41ed-9e9e-ec704cfbca4b"
        includes_fee:
          type: boolean
          description: "Indicates whether the transfer amount includes or doesn't include the fee."
    CryptoInstructions:
      type: object
      required: ["address", "identity_id", "account_id", "includes_fee", "network"]
      properties:
        address:
          type: string
          description: "A wallet address (including prefix) to use for the crypto transfer."
          example: "0x4b6f5a3dfc911e992c3d8f38c6bb9d1563b5e9a5"
        fee_id:
          type: string
          format: uuid
          description: "The ID of a pre-arranged fee guarantee to use with the transfer."
          example: "ed671d2b-bb9e-4cf5-9eb4-71b6db672207"
        identity_id:
          type: string
          format: uuid
          description: The identity ID of the institution submitting the transfer.
          example: "b2a99c93-f1ee-41ed-9e9e-ec704cfbca4b"
        account_id:
          type: string
          format: uuid
          description: The account ID of the institution submitting the transfer.
          example: "ed671d2b-bb9e-4cf5-9eb4-71b6db672207"
        includes_fee:
          type: boolean
          description: "Indicates whether the transfer amount includes or doesn't include the fee."
        network:
          type: string
          enum:
            - BITCOIN
            - ETHEREUM
            - SOLANA
          description: "The crypto network to perform the transfer on."
          example: "SOLANA"
    TransferNew:
      type: object
      required: ["asset_id", "client_id", "amount", "type", "platform"]
      properties:
        amount:
          type: string
          example: "1000000"
          description: "Amount of asset to transfer."
        asset_id:
          type: string
          pattern: "^[1-9][0-9]*$"
          example: "78901985055342602"
          description: "Exchange assigned ID of asset."
        client_id:
          type: string
          pattern: "^[1-9][0-9]*$"
          example: "78901985048264710"
          description: "Exchange assigned ID of client."
        type:
          type: string
          enum:
            - DEPOSIT
            - WITHDRAW
          example: "WITHDRAW"
          description: >
            Direction of the transfer.

            * **DEPOSIT** Place the amount specified on the exchange.

            * **WITHDRAW** Remove the amount specified from the exchange.
        platform:
          type: string
          enum:
            - FIAT
            - CRYPTO
          example: "FIAT"
          description: >
            The type of service to use for the transfer. Must match with the corresponding instructions defined below.

            * **FIAT** Indicates the transfer should use the traditional banking system used to handle the corresponding fiat currency. Note, performing a transfer with fiat on a stablecoin asset will result in an automatic conversion.

            * **CRYPTO** Indicates the transfer uses a blockchain platform.
        instructions:
          oneOf:
            - $ref: "#/components/schemas/FiatInstructions"
            - $ref: "#/components/schemas/CryptoInstructions"
          description: >
            Platform specific instructions. The defined object must match with the platform value.

            * **FiatInstructions** Must be used when setting the platform to `FIAT`

            * **CryptoInstructions** Must be used when setting the platform to `CRYPTO`
    Transfer:
      type: object
      required: ["request"]
      properties:
        request:
          type: object
          $ref: "#/components/schemas/TransferNew"
    TransferDetails:
      type: object
      properties:
        id:
          type: string
          example: "799477925457100828"
        status:
          type: string
          enum:
            - INITIALIZED
            - PENDING
            - COMPLETED
            - FAILED
            - REJECTED
          example: "INITIALIZED"
        request:
          $ref: "#/components/schemas/TransferNew"
    HistoricalTransfer:
      type: object
      properties:
        id:
          type: string
          example: "799477925458083869"
        status:
          type: string
          enum:
            - INITIALIZED
            - PENDING
            - COMPLETED
            - FAILED
            - REJECTED
          example: "INITIALIZED"
        request:
          $ref: "#/components/schemas/TransferNew"
        timestamp:
          type: string
          format: int64
          description: "The UNIX UTC nanosecond timestamp of when the transfer was initiated."
          example: "1740740509058376312"
        updated_timestamp:
          type: string
          format: int64
          description: "The UNIX UTC nanosecond timestamp of the last update to the transfer."
          example: "1740740509058376312"
    OrderTrade:
      type: object
      description: "A single trade execution against an order."
      properties:
        client_id:
          type: string
          pattern: "^[1-9][0-9]*$"
          description: "A unique identifier assigned to the client."
          example: "78901968715907076"
        external_id:
          type: string
          description: "External identifier supplied by the client when the order was created."
          example: "550e8400-e29b-41d4-a716-446655440000"
        instrument_id:
          type: string
          pattern: "^[1-9][0-9]*$"
          description: "A unique identifier for the trading instrument."
          example: "78901968728948750"
        order_id:
          type: string
          pattern: "^[1-9][0-9]*$"
          description: "A unique identifier for the order."
          example: "8005237327190949926"
        trade_price:
          type: string
          description: "The price at which the trade was executed."
          example: "111480.5"
        trade_qty:
          type: string
          description: "The quantity of the asset traded."
          example: "0.06089"
        side:
          type: string
          enum: ["BUY", "SELL"]
          description: "The side of the order (BUY/SELL)."
          example: "BUY"
        trade_fee_rate:
          type: string
          description: "The fee rate applied to the trade."
          example: "0.0005"
        liq_flag:
          type: string
          description: "Indicates whether the trade was executed as a taker or a maker."
          enum: ["TAKER", "MAKER"]
          example: "TAKER"
        match_id:
          type: string
          pattern: "^[1-9][0-9]*$"
          description: "A unique identifier for the trade match event."
          example: "147670564223998146302870408890920992792"
        timestamp:
          type: string
          description: "The Unix UTC timestamp (in nanoseconds) when the trade was executed."
          example: "1752163579133484200"
    OrderActivityBase:
      type: object
      description: "Common fields present in all order activity events."
      required:
        - client_id
        - instrument_id
        - msg_type
        - timestamp
        - side
      properties:
        client_id:
          type: string
          description: "A unique identifier assigned to the client."
          example: "78975249877368840"
        external_id:
          type: string
          description: "An external identifier for the order."
          example: "550e8400-e29b-41d4-a716-446655440000"
        instrument_id:
          type: string
          description: "A unique identifier for the trading instrument."
          example: "78975249883267118"
        msg_type:
          type: string
          description: "The type of activity event."
          enum:
            - "REQUEST_NEW"
            - "REQUEST_CANCEL"
            - "REQUEST_MODIFY"
            - "REPORT_CONFIRM"
            - "REPORT_REJECT"
            - "REPORT_TRADE"
            - "REPORT_CANCELED"
            - "REPORT_MODIFIED"
        timestamp:
          type: string
          description: "The Unix UTC timestamp (in nanoseconds) when the activity occurred."
          example: "1770919994854735762"
        side:
          type: string
          description: "The side of the order (BUY/SELL)."
          enum: ["BUY", "SELL"]
          example: "BUY"
    OrderActivityRequestNew:
      description: "Activity event for a new order request."
      allOf:
        - $ref: "#/components/schemas/OrderActivityBase"
        - type: object
          properties:
            msg_type:
              type: string
              enum: ["REQUEST_NEW"]
            order_price:
              type: string
              description: "The requested order price."
              example: "66000"
            order_qty:
              type: string
              description: "The requested order quantity."
              example: "0.0001"
    OrderActivityRequestCancel:
      description: "Activity event for a cancel order request."
      allOf:
        - $ref: "#/components/schemas/OrderActivityBase"
        - type: object
          properties:
            msg_type:
              type: string
              enum: ["REQUEST_CANCEL"]
    OrderActivityRequestModify:
      description: "Activity event for a modify order request."
      allOf:
        - $ref: "#/components/schemas/OrderActivityBase"
        - type: object
          properties:
            msg_type:
              type: string
              enum: ["REQUEST_MODIFY"]
    OrderActivityReportConfirm:
      description: "Activity event for an order confirmation."
      allOf:
        - $ref: "#/components/schemas/OrderActivityBase"
        - type: object
          required:
            - order_id
          properties:
            msg_type:
              type: string
              enum: ["REPORT_CONFIRM"]
            order_id:
              type: string
              description: "A unique identifier for the order."
              example: "2312760665443598349"
    OrderActivityReportReject:
      description: "Activity event for an order rejection."
      allOf:
        - $ref: "#/components/schemas/OrderActivityBase"
        - type: object
          required:
            - order_id
          properties:
            msg_type:
              type: string
              enum: ["REPORT_REJECT"]
            order_id:
              type: string
              description: "A unique identifier for the order."
              example: "2312760665443598349"
            reject_reason:
              type: string
              description: "The reason for order rejection."
              example: "INSUFFICIENT_FUNDS"
            reject_message:
              type: string
              description: "Human-readable rejection message."
              example: "Insufficient funds to place order"
    OrderActivityReportTrade:
      description: "Activity event for a trade execution."
      allOf:
        - $ref: "#/components/schemas/OrderActivityBase"
        - type: object
          required:
            - order_id
          properties:
            msg_type:
              type: string
              enum: ["REPORT_TRADE"]
            order_id:
              type: string
              description: "A unique identifier for the order."
              example: "2312760665443598349"
            trade_price:
              type: string
              description: "The price at which the trade was executed."
              example: "111480.5"
            trade_qty:
              type: string
              description: "The quantity of the asset traded."
              example: "0.06089"
            trade_fee_rate:
              type: string
              description: "The fee rate applied to the trade."
              example: "0.0005"
            liq_flag:
              type: string
              description: "Liquidity flag indicating whether the order was a maker or taker."
              enum: ["TAKER", "MAKER"]
              example: "TAKER"
            match_id:
              type: string
              description: "A unique identifier for the trade match."
              example: "147670564223998146302870408890920992792"
    OrderActivityReportCanceled:
      description: "Activity event for an order cancellation."
      allOf:
        - $ref: "#/components/schemas/OrderActivityBase"
        - type: object
          required:
            - order_id
          properties:
            msg_type:
              type: string
              enum: ["REPORT_CANCELED"]
            order_id:
              type: string
              description: "A unique identifier for the order."
              example: "2312760665443598349"
            canceled_qty:
              type: string
              description: "The quantity that was canceled."
              example: "1.5"
            cancel_reason:
              type: string
              description: "The reason for cancellation."
              example: "USER_REQUESTED"
    OrderActivityReportModified:
      description: "Activity event for an order modification."
      allOf:
        - $ref: "#/components/schemas/OrderActivityBase"
        - type: object
          required:
            - order_id
          properties:
            msg_type:
              type: string
              enum: ["REPORT_MODIFIED"]
            order_id:
              type: string
              description: "A unique identifier for the order."
              example: "2312760665443598349"
            old_qty:
              type: string
              description: "The original order quantity before modification."
              example: "0.0001"
            old_price:
              type: string
              description: "The original order price before modification."
              example: "66000"
            new_qty:
              type: string
              description: "The new order quantity after modification."
              example: "0.0001"
            new_price:
              type: string
              description: "The new order price after modification."
              example: "66001"
            old_type:
              type: string
              description: "The original order type before modification."
              example: "LIMIT"
            new_type:
              type: string
              description: "The new order type after modification."
              example: "LIMIT"
    OrderActivity:
      oneOf:
        - $ref: "#/components/schemas/OrderActivityRequestNew"
        - $ref: "#/components/schemas/OrderActivityRequestCancel"
        - $ref: "#/components/schemas/OrderActivityRequestModify"
        - $ref: "#/components/schemas/OrderActivityReportConfirm"
        - $ref: "#/components/schemas/OrderActivityReportReject"
        - $ref: "#/components/schemas/OrderActivityReportTrade"
        - $ref: "#/components/schemas/OrderActivityReportCanceled"
        - $ref: "#/components/schemas/OrderActivityReportModified"
      discriminator:
        propertyName: msg_type
        mapping:
          REQUEST_NEW: "#/components/schemas/OrderActivityRequestNew"
          REQUEST_CANCEL: "#/components/schemas/OrderActivityRequestCancel"
          REQUEST_MODIFY: "#/components/schemas/OrderActivityRequestModify"
          REPORT_CONFIRM: "#/components/schemas/OrderActivityReportConfirm"
          REPORT_REJECT: "#/components/schemas/OrderActivityReportReject"
          REPORT_TRADE: "#/components/schemas/OrderActivityReportTrade"
          REPORT_CANCELED: "#/components/schemas/OrderActivityReportCanceled"
          REPORT_MODIFIED: "#/components/schemas/OrderActivityReportModified"
    Problem:
      type: object
      required:
        - type
        - title
        - status
      properties:
        type:
          type: string
          format: uri
          description: A URI reference that identifies the problem type.
          example: "about:blank"
        title:
          type: string
          description: A short, human-readable summary of the problem type.
          example: "An Error Occured"
        status:
          type: integer
          format: int32
          description: The HTTP status code generated by the origin server.
          example: 400
        detail:
          type: string
          description: A human-readable explanation specific to this occurrence of the problem.
          example: "A more detailed sentence about the error"
        instance:
          type: string
          format: uri-reference
          description: A URI reference that identifies the specific occurrence of the problem.
          example: "/v1/cefi/endpoint"
        extensions:
          type: object
          additionalProperties: true
          description: A map for extension members (custom fields not defined by the RFC).
  securitySchemes:
    HMAC:
      type: apiKey
      in: header
      name: x-truex-auth-token
      description: |
        Legacy authentication, being phased out in favour of `JWT`. Clients must compute and send an HMAC signature in `x-truex-auth-signature`.

        Compute the payload exactly as:

        `timestamp + method + path + body`

        Then compute the signature as:

        `Base64( HMAC_SHA256(secret, payload) )`

        Rules:
        * `timestamp` is `x-truex-auth-timestamp` in **seconds since Unix epoch**.
        * `timestamp` must be no older than 15 seconds and no more than 1 second in the future.
        * `method` is uppercase HTTP method (`GET`, `POST`, `DELETE`, etc.).
        * `path` is everything after the domain, including leading `/` (e.g. `/v1/cefi/orders`) and excludes query string parameters.
        * `body` is the exact raw request body string. Use an empty string for requests with no body.

        Example payload:
        * `1700000000POST/v1/cefi/orders{"client_id":"7","instrument_id":"1","qty":"1","price":"100"}`

        Example signature (shell):
        * `printf '%s' "$PAYLOAD" | openssl dgst -sha256 -hmac "$SECRET" -binary | base64`

        Note, method is all upper case and path is everything after the domain name including the / (e.g. /v1/cefi/orders).
        Required headers:
        * `x-truex-auth-token`: The ID of the HMAC key being used (API key).
        * `x-truex-auth-signature`: The signature generated from processing the payload with the HMAC key.
        * `x-truex-auth-timestamp`: Current time as seconds since epoch.
        * `x-truex-auth-userid`: Client identifier.
    JWT:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: |
        Recommended authentication. Present a True Markets-issued JWT access
        token as `Authorization: Bearer <token>`, together with
        `x-truex-auth-timestamp` (current Unix seconds, which guards against
        replays). No request signing is required.

        Obtain a token pair by exchanging a signed challenge for your
        registered ES256 (EC P-256) API key at `POST /v1/auth/api-key/token`
        (see the Auth API); the same token is issued by the standard sign-in
        flows.

        The token must carry a `client_id` claim, which scopes every request
        to your CeFi client. The claim is present only once your account is
        enabled for CeFi trading; a JWT without a `client_id` claim is
        rejected with `401 Unauthorized`.
  parameters:
    XTruexVersion:
      in: header
      name: X-Truex-Version
      required: false
      schema:
        type: string
        enum:
          - v2024_01_01
          - v2026_01_23
        default: v2024_01_01
      description: >
        API version to use for the request. Controls response format:
        - `v2024_01_01` (default, deprecated — sunset August 5, 2026): Raw data arrays/objects
        - `v2026_01_23`: Envelope format with `{ "data": [...], "pagination": {...} }`
    XAuthUserId:
      in: header
      name: x-truex-auth-userid
      required: false
      schema:
        type: string
      description: HMAC only. The client the request acts for. Omit it with a JWT, which carries your client id.
    XAuthTimestamp:
      in: header
      name: x-truex-auth-timestamp
      required: true
      schema:
        type: string
      description: Timestamp when request was made in seconds since epoch. Must be no older than 15 seconds and no more than 1 second in the future. Required with both JWT and HMAC authentication; it guards against replayed requests.
    XAuthToken:
      in: header
      name: x-truex-auth-token
      required: false
      schema:
        type: string
      description: HMAC only. The UUID affiliated with the HMAC key. Omit it with a JWT.
    XAuthSignature:
      in: header
      name: x-truex-auth-signature
      required: false
      schema:
        type: string
      description: HMAC only. The computed HMAC signature. Omit it with a JWT.
  responses:
    BadRequest:
      description: "Bad request."
      content:
        application/problem+json:
          schema:
            type: object
            $ref: "#/components/schemas/Problem"
    Unauthorized:
      description: "Unauthorized."
      content:
        application/problem+json:
          schema:
            type: object
            $ref: "#/components/schemas/Problem"
    Forbidden:
      description: "Forbidden."
      content:
        application/problem+json:
          schema:
            type: object
            $ref: "#/components/schemas/Problem"
    NotFound:
      description: "Not found."
      content:
        application/problem+json:
          schema:
            type: object
            $ref: "#/components/schemas/Problem"
    Timeout:
      description: "Request timeout."
      content:
        application/problem+json:
          schema:
            type: object
            $ref: "#/components/schemas/Problem"
    UnsupportedMedia:
      description: "Unsupported media type."
      content:
        application/problem+json:
          schema:
            type: object
            $ref: "#/components/schemas/Problem"
    InternalError:
      description: "Internal server error."
      content:
        application/problem+json:
          schema:
            type: object
            $ref: "#/components/schemas/Problem"
    ServiceUnavailable:
      description: "Service unavailable."
      content:
        application/problem+json:
          schema:
            type: object
            $ref: "#/components/schemas/Problem"
