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

# List margin states

> Lists the account's margin state per margin group.



## OpenAPI

````yaml api-reference/platform/plurex-platform-api.yaml POST /api/v1/hosts/query/ListAccountMarginStates
openapi: 3.2.0
info:
  title: Plurex Platform API
  version: 1.0.0
  description: >-
    Trade across exchanges and brokers through one API, and paper trade any of
    them with the same calls.


    **Venues** are the exchanges where markets trade. Venue operations are
    public market data: markets, order books, recent trades, prices, quotes,
    statistics, funding, open interest and candles. They need no API key.


    **Hosts** hold trading accounts and execute orders on a venue's markets, for
    example an exchange's own account service or a broker. Host operations cover
    each host's tradable markets and order rules, and every account action:
    orders, fills, balances, positions, margin, leverage and transactions. A
    venue market tells you what is trading; the matching host market tells you
    what you may order there.


    **Tenants** own trading resources: every account belongs to one tenant. You
    act as your tenant, and your API keys are created under it. Find your tenant
    ID next to your API keys on the DevTools page of the Plurex app.


    **Accounts** are your accounts on hosts. Connect an exchange or broker
    account with its API credentials, or create a **paper** account. A paper
    host simulates a real host against that venue's live order book, so a paper
    account trades through exactly the same host operations and can be switched
    for a real one without code changes.


    **Capabilities.** Hosts and venues differ. Each host and venue lists every
    operation it supports, and each market lists its order types, settings and
    market data. Check these before calling: an unsupported call returns 422
    NotSupported.


    **Requests.** Every operation is a POST with a JSON body (Content-Type
    application/json). Account operations need both the X-API-KEY and
    X-API-SECRET headers. Unknown fields, unknown enum values and wrong types
    are rejected with 400. Every error has the ErrorEnvelope shape; its code
    says what went wrong. Account changes also arrive as WebSocket streams,
    described in the AsyncAPI document.


    **Compatibility.** Enum values, union variants, error codes and fields are
    added over time without a new version. Ignore fields you do not recognise,
    and treat unknown enum values and variants as an unrecognised case instead
    of failing. Removing or renaming any of them would be a breaking change.
servers:
  - url: https://api.plurex.io
security:
  - ApiKey: []
    ApiSecret: []
tags:
  - name: venues
    summary: Market data
    description: >-
      Public market data from the exchanges where markets trade. No API key
      needed.
    kind: nav
  - name: venue-markets
    summary: Venues and markets
    description: The venues and their markets, with the market data each market supports.
    parent: venues
    kind: nav
  - name: order-books
    summary: Order books
    description: A market's current bids and asks.
    parent: venues
    kind: nav
  - name: public-trades
    summary: Public trades
    description: A market's recent public trades.
    parent: venues
    kind: nav
  - name: market-observations
    summary: Prices and market statistics
    description: >-
      Current prices, best quotes, statistics, indicative funding and open
      interest, read in batches of instruments.
    parent: venues
    kind: nav
  - name: candles
    summary: Candles
    description: Closed OHLC candles by price kind and interval, newest first.
    parent: venues
    kind: nav
  - name: hosts
    summary: Trading
    description: >-
      Trading on an account: each host's tradable markets and order rules,
      orders, fills, balances, positions, margin, market settings and
      transactions. Paper accounts use these same operations.
    kind: nav
  - name: host-markets
    summary: Hosts and markets
    description: >-
      The hosts and their tradable markets, with each market's order types,
      order rules and settings.
    parent: hosts
    kind: nav
  - name: orders
    summary: Orders
    description: Submit, cancel and read orders.
    parent: hosts
    kind: nav
  - name: fills
    summary: Fills
    description: The account's executions, by order, instrument or across the account.
    parent: hosts
    kind: nav
  - name: portfolio
    summary: Balances and positions
    description: Wallet balances, open positions, margin and per-market account state.
    parent: hosts
    kind: nav
  - name: market-settings
    summary: Leverage and position mode
    description: Read and set the account's leverage and position mode for a market.
    parent: hosts
    kind: nav
  - name: transactions
    summary: Transactions
    description: 'Balance postings: fees, funding payments, deposits and so on.'
    parent: hosts
    kind: nav
  - name: accounts
    summary: Accounts
    description: Connect, list and manage a tenant's exchange, broker and paper accounts.
    kind: nav
  - name: paper
    summary: Paper trading
    description: >-
      Create and fund paper accounts and set their simulated fees. Trade them
      through the hosts operations like any other account.
    kind: nav
  - name: paper-accounts
    summary: Paper accounts
    description: Create and fund paper accounts.
    parent: paper
    kind: nav
  - name: paper-fees
    summary: Paper fees
    description: Choose the fee tier a paper account is charged.
    parent: paper
    kind: nav
  - name: public
    summary: No API key
    description: Public market data and discovery; no authentication needed.
    kind: badge
  - name: optional
    summary: Check capabilities
    description: >-
      Not every host or venue supports this operation; check its capabilities
      first or expect 422 NotSupported.
    kind: badge
  - name: paged
    summary: Paged
    description: Returns pages; follow nextCursor until null.
    kind: badge
  - name: batch
    summary: Batch
    description: >-
      Takes a list of identifiers or instruments and returns one result for
      each.
    kind: badge
  - name: not-repeat-safe
    summary: Not safe to repeat
    description: >-
      Repeating the call repeats its effect. If the outcome is unclear, check
      before retrying.
    kind: badge
paths:
  /api/v1/hosts/query/ListAccountMarginStates:
    post:
      tags:
        - portfolio
        - paged
      summary: List margin states
      description: Lists the account's margin state per margin group.
      operationId: hostsListAccountMarginStates
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ListAccountMarginStatesQuery'
      responses:
        '200':
          description: Successful result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PageResponseAccountMarginState'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthenticated'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '415':
          $ref: '#/components/responses/UnsupportedMediaType'
        '422':
          $ref: '#/components/responses/Rejected'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/UnexpectedError'
        '502':
          $ref: '#/components/responses/UpstreamFailure'
        '503':
          $ref: '#/components/responses/Unavailable'
        '504':
          $ref: '#/components/responses/UpstreamTimeout'
      security:
        - ApiKey: []
          ApiSecret: []
components:
  schemas:
    ListAccountMarginStatesQuery:
      type: object
      properties:
        accountId:
          type: string
        cursor:
          type:
            - string
            - 'null'
          description: >-
            nextCursor from the previous page; omit for the first page. Only
            valid with the same query: same variant, account and filters.
      required:
        - accountId
    PageResponseAccountMarginState:
      type: object
      description: >-
        One page of results; the server sets the page size. Send nextCursor as
        cursor for the next page. Pages are read live, so items can change while
        you page.
      required:
        - items
        - nextCursor
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/AccountMarginState'
        nextCursor:
          type:
            - string
            - 'null'
          description: Pass as cursor to get the next page; null on the last page.
    AccountMarginState:
      type: object
      properties:
        baseCollateralAsset:
          type: string
        totalCollateralValue:
          $ref: '#/components/schemas/Decimal'
        totalInitialMargin:
          $ref: '#/components/schemas/Decimal'
        totalMaintenanceMargin:
          $ref: '#/components/schemas/Decimal'
        accountMarginRatio:
          anyOf:
            - $ref: '#/components/schemas/Decimal'
            - type: 'null'
          description: Host-reported value; null if the host does not supply it.
      required:
        - baseCollateralAsset
        - totalCollateralValue
        - totalInitialMargin
        - totalMaintenanceMargin
        - accountMarginRatio
    ErrorEnvelope:
      type: object
      properties:
        code:
          $ref: '#/components/schemas/ErrorCode'
        message:
          type: string
        error:
          type:
            - string
            - 'null'
          description: Reserved for structured detail; currently always null.
      required:
        - code
        - message
        - error
      description: >-
        Every error has this shape, at every HTTP status, including unknown
        paths (404 NotFound) and wrong methods (405 MethodNotAllowed). code is
        the specific reason. Each operation describes when to retry and how to
        check the outcome; an error alone does not prove a command had no
        effect.
    Decimal:
      type: string
      pattern: ^-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
      description: >-
        An exact decimal number encoded as a string. No binary floating-point
        rounding.
    ErrorCode:
      type: string
      enum:
        - InvalidRequest
        - Unauthenticated
        - Forbidden
        - AccountNotFound
        - OrderNotFound
        - NotFound
        - MethodNotAllowed
        - DuplicateClientOrderId
        - OrderAlreadyClosed
        - Conflict
        - UnsupportedMediaType
        - InsufficientFunds
        - InvalidProviderCredentials
        - AccountLimit
        - NotSupported
        - Rejected
        - RateLimited
        - UnexpectedError
        - CancelAllFailed
        - UpstreamFailure
        - Unavailable
        - UpstreamTimeout
      description: >-
        Stable error reason. The HTTP status for each code is fixed:
        InvalidRequest (400): Malformed JSON, wrong types, unknown fields or
        enum values, or invalid values.; Unauthenticated (401): Missing or
        invalid API key headers.; Forbidden (403): Authenticated, but without
        access to the account or operation.; AccountNotFound (404): The
        accountId does not exist.; OrderNotFound (404): The account exists, but
        the order identifier does not.; NotFound (404): Unknown path, host or
        venue.; MethodNotAllowed (405): The path exists but only accepts POST.;
        DuplicateClientOrderId (409): An order with this clientOrderId already
        exists.; OrderAlreadyClosed (409): The order is already filled,
        cancelled or rejected.; Conflict (409): A unique value (for example an
        account name) is already used.; UnsupportedMediaType (415): The request
        is not Content-Type application/json.; InsufficientFunds (422): The
        account cannot fund the order.; InvalidProviderCredentials (422): The
        provider rejected the account credentials.; AccountLimit (422): An
        account or subscription limit was reached.; NotSupported (422): The host
        does not support this operation, variant or instrument.; Rejected (422):
        The host or validation rejected the command.; RateLimited (429): The
        provider rate limited the request.; UnexpectedError (500): Unexpected
        server failure.; CancelAllFailed (502): At least one sub-cancel failed;
        reconcile with ListOpenOrders.; UpstreamFailure (502): The provider
        failed or returned an unusable response.; Unavailable (503): The service
        or provider is temporarily unavailable.; UpstreamTimeout (504): The
        provider did not respond in time. New codes may be added; treat an
        unknown code by its HTTP status.
  responses:
    BadRequest:
      description: 400 BadRequest; code is InvalidRequest.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
    Unauthenticated:
      description: 401 Unauthenticated; code is Unauthenticated.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
    Forbidden:
      description: 403 Forbidden; code is Forbidden.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
    NotFound:
      description: 404 NotFound; code is AccountNotFound, OrderNotFound or NotFound.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
    UnsupportedMediaType:
      description: 415 UnsupportedMediaType; code is UnsupportedMediaType.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
    Rejected:
      description: >-
        422 Rejected; code is InsufficientFunds, InvalidProviderCredentials,
        AccountLimit, NotSupported or Rejected.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
    RateLimited:
      description: 429 RateLimited; code is RateLimited.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
    UnexpectedError:
      description: 500 UnexpectedError; code is UnexpectedError.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
    UpstreamFailure:
      description: 502 UpstreamFailure; code is UpstreamFailure or CancelAllFailed.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
    Unavailable:
      description: 503 Unavailable; code is Unavailable.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
    UpstreamTimeout:
      description: 504 UpstreamTimeout; code is UpstreamTimeout.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: X-API-KEY
    ApiSecret:
      type: apiKey
      in: header
      name: X-API-SECRET

````

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