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

# Get order stats

> Returns aggregate broker order stats for the authenticated user or API-key principal's organization over the requested trailing day window, optionally filtered by trading account. API-key callers need organization intent read permission; user callers need an organization admin, member, or read-only role. When `trading_account_id` is supplied, the trading account must belong to the caller's organization. `days` is required and capped at 90.



## OpenAPI

````yaml /api-reference/ledger.openapi.json get /v1/orders/stats
openapi: 3.1.0
info:
  title: ledger
  description: ''
  license:
    name: ''
  version: 0.1.0
servers:
  - url: https://api.anthid.com
    description: Production
security: []
tags:
  - name: Ledger
    description: Ledger API
paths:
  /v1/orders/stats:
    get:
      tags:
        - Ledger
      summary: Get order stats
      description: >-
        Returns aggregate broker order stats for the authenticated user or
        API-key principal's organization over the requested trailing day window,
        optionally filtered by trading account. API-key callers need
        organization intent read permission; user callers need an organization
        admin, member, or read-only role. When `trading_account_id` is supplied,
        the trading account must belong to the caller's organization. `days` is
        required and capped at 90.
      operationId: getOrderStats
      parameters:
        - name: trading_account_id
          in: query
          description: Filter stats by trading account id
          required: false
          schema:
            type: string
            format: uuid
        - name: days
          in: query
          description: >-
            Required trailing number of days to include. Values above 90 are
            capped at 90
          required: true
          schema:
            type: integer
            format: int64
          example: 30
      responses:
        '200':
          description: Order stats retrieved
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderStatsResponse'
        '400':
          description: Query parameters are invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: >-
            Missing or invalid authentication credentials or organization
            context
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: >-
            Caller lacks intent read access, organization access, or ownership
            of the requested trading account
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Unexpected server error while reading order stats
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearerAuth: []
        - apiKeyAuth: []
components:
  schemas:
    OrderStatsResponse:
      type: object
      required:
        - count
        - closed_count
        - rejected_count
        - filled_count
        - cancelled_count
      properties:
        cancelled_count:
          type: integer
          format: int64
          minimum: 0
        closed_count:
          type: integer
          format: int64
          minimum: 0
        count:
          type: integer
          format: int64
          minimum: 0
        filled_count:
          type: integer
          format: int64
          minimum: 0
        rejected_count:
          type: integer
          format: int64
          minimum: 0
    Error:
      oneOf:
        - type: object
          required:
            - EncryptionError
          properties:
            EncryptionError:
              type: string
        - type: object
          required:
            - WorkOsError
          properties:
            WorkOsError:
              type: string
        - type: object
          required:
            - KvError
          properties:
            KvError:
              type: string
        - type: object
          required:
            - StreamError
          properties:
            StreamError:
              type: string
        - type: object
          required:
            - InternalError
          properties:
            InternalError:
              type: string
        - type: object
          required:
            - ThirdPartyError
          properties:
            ThirdPartyError:
              type: string
        - type: object
          required:
            - ParseError
          properties:
            ParseError:
              type: string
        - type: object
          required:
            - NotFound
          properties:
            NotFound:
              type: string
        - type: object
          required:
            - AlreadyExists
          properties:
            AlreadyExists:
              type: string
        - type: object
          required:
            - BadRequest
          properties:
            BadRequest:
              type: string
        - type: object
          required:
            - Forbidden
          properties:
            Forbidden:
              type: string
        - type: object
          required:
            - Unauthorized
          properties:
            Unauthorized:
              type: string
        - type: object
          required:
            - Database
          properties:
            Database:
              type: string
        - type: object
          required:
            - TooManyRequests
          properties:
            TooManyRequests:
              type: string
        - type: object
          required:
            - BrokerError
          properties:
            BrokerError:
              type: string
        - type: object
          required:
            - AuthError
          properties:
            AuthError:
              type: string
        - type: object
          required:
            - InvalidInput
          properties:
            InvalidInput:
              type: string
        - type: object
          required:
            - ConnectionLimitExceeded
          properties:
            ConnectionLimitExceeded:
              type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````