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

# Get Workspace Stats

> Aggregate statistics across every connected org in the workspace: repository and dependency counts, artifact orphan breakdowns, last scan summary, and the declaration-outcome breakdown.



## OpenAPI

````yaml /openapi.json get /api/v1/workspaces/{workspace_id}/stats
openapi: 3.1.0
info:
  description: Change Impact Engine for multi-repo systems
  title: Riftmap
  version: 1.25.2
servers: []
security: []
paths:
  /api/v1/workspaces/{workspace_id}/stats:
    get:
      tags:
        - workspaces
      summary: Get Workspace Stats
      description: >-
        Aggregate statistics across every connected org in the workspace:
        repository and dependency counts, artifact orphan breakdowns, last scan
        summary, and the declaration-outcome breakdown.
      operationId: get_workspace_stats_api_v1_workspaces__workspace_id__stats_get
      parameters:
        - in: path
          name: workspace_id
          required: true
          schema:
            format: uuid
            title: Workspace Id
            type: string
        - in: header
          name: X-Workspace-Id
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Workspace-Id
        - in: cookie
          name: riftmap_access
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Riftmap Access
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrgStats'
          description: Successful Response
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
          description: Validation Error
      security:
        - APIKeyHeader: []
        - HTTPBearer: []
components:
  schemas:
    OrgStats:
      description: >-
        Per-connected-org stats payload (scoped to one connected org).


        Artifact-count semantics. Every count is a raw artifact-row count — no

        canonical-name dedup — **restricted to first-party artifacts**: rows a
        forked

        repo produces only because it kept the upstream project's package
        identity are

        excluded and counted separately (issue #258; ``is_first_party_artifact``
        in

        ``src/resolver/fork_alias.py`` is the single source of truth, cached on

        ``artifacts.is_first_party``). Consumption is computed by the single
        source of

        truth ``src/graph/artifact_stats.py`` (the type-matched union), so an

        artifact's orphan status here always matches its ``is_orphan`` on

        ``GET /connected-orgs/{id}/artifacts``:

          - ``total_artifact_rows`` — first-party artifact rows. Equals the
            ``X-Total-Count`` header of ``GET /connected-orgs/{id}/artifacts`` with its
            default ``include_upstream_aliases=false``.
          - ``upstream_alias_artifact_count`` — the rows that filter excludes. Add it
            to ``total_artifact_rows`` for every row the org has, which is what
            ``?include_upstream_aliases=true`` returns and what a disconnect deletes.
          - ``orphan_artifact_count`` — first-party rows with **zero** consumers
            (``consumer_count == 0``). Equals the count of ``is_orphan==true`` rows on
            the artifacts endpoint and the Artifacts page "Hide orphans (N)" toggle.
          - ``consumed_artifact_count`` — first-party rows with **at least one**
            consumer (``== total_artifact_rows - orphan_artifact_count``).
          - ``artifact_type_breakdown`` — **first-party** artifact rows grouped by
            ``artifact_type`` (includes every type present; never drops one).
            Invariant: ``sum(artifact_type_breakdown.values()) == total_artifact_rows``.

        ``total_declarations`` vs ``total_dependencies``: the former counts
        every

        manifest-context dependency *declaration* parsed out of the org's repos,
        the

        latter counts the deduped cross-repo *edges* those declarations resolved
        to.

        The gap between them is the org's coverage story — Patrimore parsed
        4,390 and

        got 9 edges — and naming both numbers is what lets a near-empty graph
        explain

        itself instead of reading as a broken product (issue #225).


        ``declaration_outcomes`` breaks that gap down: it partitions the same

        ``total_declarations`` population into why each declaration did or did
        not

        become an edge, so a large gap can be read as the ~99% correct
        rejections it

        usually is rather than as a failure count (issue #264). It replaced

        ``health``, whose ``unresolved_declarations`` was that misreadable
        number and

        whose other two fields were hardcoded zeros; the real on-latest /
        lagging

        figures live on ``GET /artifacts/{id}/consumers``.
      properties:
        artifact_type_breakdown:
          additionalProperties:
            type: integer
          title: Artifact Type Breakdown
          type: object
        consumed_artifact_count:
          title: Consumed Artifact Count
          type: integer
        declaration_outcomes:
          $ref: '#/components/schemas/DeclarationOutcomes'
        dependency_type_breakdown:
          additionalProperties:
            type: integer
          title: Dependency Type Breakdown
          type: object
        last_scan:
          anyOf:
            - $ref: '#/components/schemas/LastScanSummary'
            - type: 'null'
        orphan_artifact_count:
          title: Orphan Artifact Count
          type: integer
        total_artifact_rows:
          title: Total Artifact Rows
          type: integer
        total_declarations:
          title: Total Declarations
          type: integer
        total_dependencies:
          title: Total Dependencies
          type: integer
        total_repositories:
          title: Total Repositories
          type: integer
        upstream_alias_artifact_count:
          default: 0
          title: Upstream Alias Artifact Count
          type: integer
      required:
        - total_repositories
        - total_declarations
        - total_dependencies
        - consumed_artifact_count
        - orphan_artifact_count
        - total_artifact_rows
        - dependency_type_breakdown
        - artifact_type_breakdown
        - last_scan
        - declaration_outcomes
      title: OrgStats
      type: object
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          title: Detail
          type: array
      title: HTTPValidationError
      type: object
    DeclarationOutcomes:
      description: >-
        What became of every dependency declaration parsed from the org (issue
        #264).


        Five mutually exclusive buckets over the same population as

        ``total_declarations`` — manifest-context declarations, scoped per repo
        to its

        ``current_scan_id``. **They sum to ``total_declarations``.**


        Replaces ``health.unresolved_declarations``, which counted every
        unresolved

        declaration regardless of why, named the result as if it were a failure
        count,

        and — because it was computed over all reference contexts while

        ``total_declarations`` is manifest-only — could exceed the total it was
        shown

        against (cloudposse: 13,225 unresolved against 6,374 total).


        Only ``unresolved_in_org`` means "Riftmap may have missed something".
        The other

        three non-resolved buckets are correct rejections: a third-party package
        is

        supposed to stay unresolved, a ``workspace:`` dependency lives in the
        same repo

        by definition, and a repo importing its own subpackage is not a
        cross-repo edge.

        Measured across all 321,445 production declarations on 2026-09-12:
        86.13%

        ``external``, 4.73% ``resolved_in_org``, 4.46% ``local_reference``,
        3.86%

        ``self_reference``, **0.81% ``unresolved_in_org``**. Those are
        *platform*

        shares — a single org can sit far from them, so do not read the platform

        figure as a per-org expectation. They predate v1.25.0, which counts
        every

        repeated declaration of a reference (a second ``uses:`` of one action in
        a

        workflow, a package listed as both a dev and a peer dependency), so
        every

        bucket rises for an org once it is rescanned.


        ``resolved_in_org`` is normally **larger** than ``total_dependencies``,
        and that

        is not a bug: it counts declarations, while ``total_dependencies``
        counts deduped

        graph edges. A declaration is not an edge — read-time ``DISTINCT ON``
        collapses

        declarations that share a ``(source, target, dependency_type)`` key,
        self-edges

        are excluded from the graph, and an artifact target with no producing
        repo

        renders no edge.


        Classification is owned by ``src/graph/declaration_outcomes.py`` — the
        single

        source of truth, which also documents what these buckets structurally
        cannot

        see (a fork-alias rejection lands in ``external``).
      properties:
        external:
          description: >-
            Unresolved and the reference does not name anything in this org —
            third-party packages, base images and actions. Correctly not in your
            graph. Note this means 'does not name your namespace', not 'you do
            not depend on it'.
          title: External
          type: integer
        local_reference:
          description: >-
            Unresolved because the version constraint denotes a local/intra-repo
            protocol (pnpm/yarn 'workspace:', 'catalog:', 'link:', 'file:',
            'portal:'). Intra-repo by definition and must never mint a
            cross-repo edge. A correct rejection.
          title: Local Reference
          type: integer
        resolved_in_org:
          description: >-
            Resolved to a target inside this org — these are what the graph is
            built from.
          title: Resolved In Org
          type: integer
        self_reference:
          description: >-
            Unresolved and the reference names the declaring repository itself —
            a monorepo importing its own subpackage, or an image tagged from its
            own repo. A correct rejection.
          title: Self Reference
          type: integer
        unresolved_in_org:
          description: >-
            Unresolved, and the reference names this org's own namespace. THE
            ONLY BUCKET THAT MEANS RIFTMAP MAY HAVE MISSED AN EDGE — everything
            else here is expected behaviour. 0.81% of all production
            declarations, but that is a platform-wide share and not a per-org
            expectation: a single org can be far higher, usually because one
            repeated reference shape does not parse.
          title: Unresolved In Org
          type: integer
      required:
        - resolved_in_org
        - local_reference
        - self_reference
        - unresolved_in_org
        - external
      title: DeclarationOutcomes
      type: object
    LastScanSummary:
      description: Summary of the most recent scan.
      properties:
        completed_at:
          anyOf:
            - format: date-time
              type: string
            - type: 'null'
          title: Completed At
        errors:
          title: Errors
          type: integer
        id:
          format: uuid
          title: Id
          type: string
        repos_scanned:
          title: Repos Scanned
          type: integer
        status:
          title: Status
          type: string
      required:
        - id
        - status
        - completed_at
        - repos_scanned
        - errors
      title: LastScanSummary
      type: object
    ValidationError:
      properties:
        ctx:
          title: Context
          type: object
        input:
          title: Input
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          title: Location
          type: array
        msg:
          title: Message
          type: string
        type:
          title: Error Type
          type: string
      required:
        - loc
        - msg
        - type
      title: ValidationError
      type: object
  securitySchemes:
    APIKeyHeader:
      in: header
      name: X-API-Key
      type: apiKey
    HTTPBearer:
      description: API key as Bearer token (rfm_live_... prefix)
      scheme: bearer
      type: http

````

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