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

# Get consumption per supply

> Reads consumption per supply in its own unit, bucketed by UTC day or week from the immutable stock ledger, as an evidence contract. Requires analytics:read. Quantities of different supplies or units are never added together; coverage reports movements without a verified unit, a restricted warehouse scope and the covered window when the scan is truncated. A narration is included only when it passes the deterministic numeric-faithfulness check. Quantities only. The window defaults to the last 30 days ending now; a malformed, backwards, or too-wide window is a 400. Deterministic; computed live over the workspace data.



## OpenAPI

````yaml /openapi.en.json get /v1/analytics/consumption-trend
openapi: 3.1.0
info:
  description: >-
    The Muveya public developer API: opaque-API-key-authenticated,
    tenant-scoped, read-only /v1 resources. One rate-limit budget per key.
  title: Muveya Developer API
  version: 0.1.0
servers:
  - description: Production
    url: https://api.muveya.com
security: []
tags:
  - name: API key
  - name: Clinics
  - name: Warehouses
  - name: Catalog
  - name: Inventory
  - name: Orders
  - name: Fulfillments
  - name: Analytics
paths:
  /v1/analytics/consumption-trend:
    get:
      tags:
        - Analytics
      summary: Get consumption per supply
      description: >-
        Reads consumption per supply in its own unit, bucketed by UTC day or
        week from the immutable stock ledger, as an evidence contract. Requires
        analytics:read. Quantities of different supplies or units are never
        added together; coverage reports movements without a verified unit, a
        restricted warehouse scope and the covered window when the scan is
        truncated. A narration is included only when it passes the deterministic
        numeric-faithfulness check. Quantities only. The window defaults to the
        last 30 days ending now; a malformed, backwards, or too-wide window is a
        400. Deterministic; computed live over the workspace data.
      operationId: getAnalyticsConsumptionTrend
      parameters:
        - name: from
          in: query
          required: false
          description: >-
            Inclusive ISO-8601 start of the window (defaults to 30 days before
            `to`).
          schema:
            type: string
            format: date-time
        - name: to
          in: query
          required: false
          description: Exclusive ISO-8601 end of the window (defaults to now).
          schema:
            type: string
            format: date-time
        - name: granularity
          in: query
          required: false
          description: Bucket size; defaults to `day`.
          schema:
            type: string
            enum:
              - day
              - week
        - name: catalogItemId
          in: query
          required: false
          description: Narrows the trend to one catalog item.
          schema:
            type: string
      responses:
        '200':
          description: The consumption trend.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConsumptionTrend'
          headers:
            X-RateLimit-Limit:
              description: The per-key request budget for the current window.
              schema:
                type: integer
                minimum: 1
            X-RateLimit-Remaining:
              description: Requests left in the current window (0 when exhausted).
              schema:
                type: integer
                minimum: 0
            X-RateLimit-Reset:
              description: Seconds until the current window resets.
              schema:
                type: integer
                minimum: 1
            RateLimit:
              description: >-
                IETF draft budget snapshot, e.g. "limit=120, remaining=119,
                reset=60".
              schema:
                type: string
            RateLimit-Policy:
              description: IETF draft policy, e.g. "120;w=60" (limit;window-seconds).
              schema:
                type: string
        '400':
          description: The window is malformed, backwards, or wider than the maximum.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
          headers:
            X-RateLimit-Limit:
              description: The per-key request budget for the current window.
              schema:
                type: integer
                minimum: 1
            X-RateLimit-Remaining:
              description: Requests left in the current window (0 when exhausted).
              schema:
                type: integer
                minimum: 0
            X-RateLimit-Reset:
              description: Seconds until the current window resets.
              schema:
                type: integer
                minimum: 1
            RateLimit:
              description: >-
                IETF draft budget snapshot, e.g. "limit=120, remaining=119,
                reset=60".
              schema:
                type: string
            RateLimit-Policy:
              description: IETF draft policy, e.g. "120;w=60" (limit;window-seconds).
              schema:
                type: string
        '401':
          description: >-
            The API key is missing, invalid, revoked, expired, or bound to a
            suspended workspace.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
        '403':
          description: The API key lacks the scope this route requires.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
        '429':
          description: The API key exceeded its rate limit for the current window.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
          headers:
            Retry-After:
              description: Positive delta-seconds until another request is allowed.
              schema:
                type: integer
                minimum: 1
            X-RateLimit-Limit:
              description: The per-key request budget for the current window.
              schema:
                type: integer
                minimum: 1
            X-RateLimit-Remaining:
              description: Requests left in the current window (0 when exhausted).
              schema:
                type: integer
                minimum: 0
            X-RateLimit-Reset:
              description: Seconds until the current window resets.
              schema:
                type: integer
                minimum: 1
            RateLimit:
              description: >-
                IETF draft budget snapshot, e.g. "limit=120, remaining=119,
                reset=60".
              schema:
                type: string
            RateLimit-Policy:
              description: IETF draft policy, e.g. "120;w=60" (limit;window-seconds).
              schema:
                type: string
      security:
        - apiKeyBearer: []
components:
  schemas:
    ConsumptionTrend:
      type: object
      additionalProperties: false
      required:
        - metric
        - definition
        - granularity
        - period
        - movementCount
        - timezone
        - asOf
        - freshness
        - evidenceId
        - truncated
        - filters
        - coverage
        - series
        - unverifiedItems
      properties:
        metric:
          type: string
        definition:
          type: string
          description: The human-readable definition of the metric.
        granularity:
          type: string
          enum:
            - day
            - week
        period:
          type: object
          additionalProperties: false
          required:
            - from
            - to
          properties:
            from:
              type: string
              format: date-time
            to:
              type: string
              format: date-time
        movementCount:
          type: integer
          description: Every consumption movement read, measured or not.
        timezone:
          type: string
        asOf:
          type: string
          format: date-time
        freshness:
          type: string
          enum:
            - live
        evidenceId:
          type: string
        truncated:
          type: boolean
          description: >-
            True when the ledger scan hit its cap; it reads newest first, so
            coverage.coveredFrom says where the figures start.
        filters:
          type: object
          additionalProperties:
            type: string
        coverage:
          $ref: '#/components/schemas/ConsumptionCoverage'
        series:
          type: array
          items:
            $ref: '#/components/schemas/ConsumptionSeries'
        unverifiedItems:
          type: array
          items:
            $ref: '#/components/schemas/ConsumptionUnverifiedItem'
        narration:
          $ref: '#/components/schemas/ConsumptionNarration'
    ProblemDetails:
      type: object
      additionalProperties: false
      required:
        - type
        - title
        - status
        - detail
        - instance
        - code
        - requestId
      properties:
        type:
          type: string
          format: uri
        title:
          type: string
        status:
          type: integer
          minimum: 400
          maximum: 599
        detail:
          type: string
        instance:
          type: string
        code:
          type: string
        requestId:
          type: string
    ConsumptionCoverage:
      type: object
      additionalProperties: false
      required:
        - measuredMovementCount
        - unverifiedMovementCount
        - warehouseScope
      properties:
        measuredMovementCount:
          type: integer
          description: Movements with a verified unit, folded into the series.
        unverifiedMovementCount:
          type: integer
          description: >-
            Movements without a verified unit, counted apart and added to no
            series.
        warehouseScope:
          type: string
          enum:
            - all
            - restricted
          description: >-
            `restricted` when the reader sees only some warehouses: the series
            are not workspace totals.
        coveredFrom:
          type: string
          format: date-time
          description: >-
            Present when the scan hit its cap: the figures cover only
            [coveredFrom, period.to).
    ConsumptionSeries:
      type: object
      additionalProperties: false
      description: >-
        Consumption of one supply in one measured unit. Quantities are added
        only inside a series, never across series.
      required:
        - seriesKey
        - catalogItemId
        - unitOfMeasure
        - totalConsumed
        - usedQuantity
        - issuedQuantity
        - movementCount
        - buckets
      properties:
        seriesKey:
          type: string
          description: >-
            Stable key of the series in this report:
            `<catalogItemId>:<unitOfMeasure>`.
        catalogItemId:
          type: string
        itemName:
          type: string
          description: The supply name; omitted when the catalog no longer knows the id.
        sku:
          type: string
          description: The supply SKU; omitted when the catalog no longer knows the id.
        unitOfMeasure:
          type: string
          description: >-
            The unit recorded on the movements of this series (immutable
            measurement identity).
        totalConsumed:
          type: number
          description: Quantity consumed, in `unitOfMeasure`.
        usedQuantity:
          type: number
          description: >-
            The observed use: stock recorded where it was used, in
            `unitOfMeasure`.
        issuedQuantity:
          type: number
          description: >-
            Stock delivered to rooms that do not count their stock: an estimated
            consumption, in `unitOfMeasure`. usedQuantity + issuedQuantity =
            totalConsumed.
        movementCount:
          type: integer
        buckets:
          type: array
          items:
            $ref: '#/components/schemas/ConsumptionTrendBucket'
    ConsumptionUnverifiedItem:
      type: object
      additionalProperties: false
      description: >-
        A supply with consumption recorded before unit identity existed:
        counted, never quantified.
      required:
        - catalogItemId
        - movementCount
      properties:
        catalogItemId:
          type: string
        itemName:
          type: string
          description: The supply name; omitted when the catalog no longer knows the id.
        sku:
          type: string
          description: The supply SKU; omitted when the catalog no longer knows the id.
        movementCount:
          type: integer
    ConsumptionNarration:
      type: object
      additionalProperties: false
      description: >-
        The claims a summary may state, each equal to the evidence in its own
        unit. Included only when it passes the deterministic
        numeric-faithfulness check.
      required:
        - evidenceId
        - period
        - acknowledgesTruncation
        - acknowledgesUnverified
        - acknowledgesRestrictedScope
        - claims
      properties:
        evidenceId:
          type: string
        period:
          type: object
          additionalProperties: false
          required:
            - from
            - to
          properties:
            from:
              type: string
              format: date-time
            to:
              type: string
              format: date-time
        acknowledgesTruncation:
          type: boolean
        acknowledgesUnverified:
          type: boolean
        acknowledgesRestrictedScope:
          type: boolean
        claims:
          type: array
          items:
            oneOf:
              - type: object
                additionalProperties: false
                required:
                  - kind
                  - seriesKey
                  - field
                  - value
                  - unit
                properties:
                  kind:
                    type: string
                    enum:
                      - series
                  seriesKey:
                    type: string
                  field:
                    type: string
                    enum:
                      - totalConsumed
                      - movementCount
                  value:
                    type: number
                  unit:
                    type: string
              - type: object
                additionalProperties: false
                required:
                  - kind
                  - field
                  - value
                  - unit
                properties:
                  kind:
                    type: string
                    enum:
                      - coverage
                  field:
                    type: string
                    enum:
                      - movementCount
                      - unverifiedMovementCount
                  value:
                    type: number
                  unit:
                    type: string
                    enum:
                      - movements
    ConsumptionTrendBucket:
      type: object
      additionalProperties: false
      required:
        - bucketStart
        - consumedQuantity
        - usedQuantity
        - issuedQuantity
        - movementCount
      properties:
        bucketStart:
          type: string
          format: date-time
          description: UTC start of the interval.
        consumedQuantity:
          type: number
          description: >-
            Quantity consumed in the interval, in the unit of the series it
            belongs to.
        usedQuantity:
          type: number
          description: 'The observed use in the interval: stock recorded where it was used.'
        issuedQuantity:
          type: number
          description: >-
            Stock delivered in the interval to rooms that do not count their
            stock: an estimated consumption. usedQuantity + issuedQuantity =
            consumedQuantity.
        movementCount:
          type: integer
  securitySchemes:
    apiKeyBearer:
      type: http
      scheme: bearer
      bearerFormat: opaque
      description: >-
        Opaque mvy_test_ API key sent as a Bearer token. It derives exactly one
        workspace server-side; the path never carries a workspace selector.

````

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