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

# Get what organizations created and who worked on the platform in a window

> Per organization: what each product created in the window, who created it, and flags such as a first evaluation or a quiet client. Staff rows, soft-deleted rows, seed sessions and demo clones are left out of the counts. `posthog` and `loki` add dashboard visits and API client types. A source that is not `ok` leaves its fields out, never zero. Needs `organization.readUsageReport` on the organization, plus a cross-organization role without `organizationId`. `format=pdf` answers `{ downloadUrl }` instead, and `format=both` answers `{ report, downloadUrl }`; the PDF is stored under the caller's organization.



## OpenAPI

````yaml /openapi.json get /reports/usage
openapi: 3.0.0
info:
  version: 1.0.0
  title: Product Management Service API
  description: API documentation for Product Management Service
  contact:
    name: Galtea AI
servers:
  - url: https://api.galtea.ai
security:
  - bearerAuth: []
tags: []
externalDocs:
  description: Galtea Platform Documentation
  url: https://docs.galtea.ai
paths:
  /reports/usage:
    get:
      tags:
        - reports
      summary: >-
        Get what organizations created and who worked on the platform in a
        window
      description: >-
        Per organization: what each product created in the window, who created
        it, and flags such as a first evaluation or a quiet client. Staff rows,
        soft-deleted rows, seed sessions and demo clones are left out of the
        counts. `posthog` and `loki` add dashboard visits and API client types.
        A source that is not `ok` leaves its fields out, never zero. Needs
        `organization.readUsageReport` on the organization, plus a
        cross-organization role without `organizationId`. `format=pdf` answers
        `{ downloadUrl }` instead, and `format=both` answers `{ report,
        downloadUrl }`; the PDF is stored under the caller's organization.
      operationId: getUsageReport
      parameters:
        - schema:
            type: string
            minLength: 1
            description: >-
              The organization to report on. Omitted reports on every
              organization, which only a caller that may read across
              organizations may ask.
          required: false
          description: >-
            The organization to report on. Omitted reports on every
            organization, which only a caller that may read across organizations
            may ask.
          name: organizationId
          in: query
        - schema:
            type: string
            format: date-time
            description: Start of the window, inclusive (ISO 8601).
          required: true
          description: Start of the window, inclusive (ISO 8601).
          name: from
          in: query
        - schema:
            type: string
            format: date-time
            description: >-
              End of the window, exclusive (ISO 8601). At most 92 days after
              `from`, or 31 days when `sources` holds `posthog` or `loki`, else
              400.
          required: true
          description: >-
            End of the window, exclusive (ISO 8601). At most 92 days after
            `from`, or 31 days when `sources` holds `posthog` or `loki`, else
            400.
          name: to
          in: query
        - schema:
            type: string
            default: UTC
            description: >-
              IANA time zone, only echoed in `window` so a reader knows which
              local days `from` and `to` meant. It changes no count, flag or
              bound: send `from` and `to` as the local day bounds yourself.
            example: Europe/Madrid
          required: false
          description: >-
            IANA time zone, only echoed in `window` so a reader knows which
            local days `from` and `to` meant. It changes no count, flag or
            bound: send `from` and `to` as the local day bounds yourself.
          name: timeZone
          in: query
        - schema:
            type: string
            description: >-
              Comma-separated sources: `db` (the application database),
              `posthog` (dashboard visits and recordings) and `loki` (API
              requests per client type). Default `db`, which every report reads.
              `posthog` and `loki` need `organization.readUsageTelemetry`, else
              403.
            example: db,posthog,loki
          required: false
          description: >-
            Comma-separated sources: `db` (the application database), `posthog`
            (dashboard visits and recordings) and `loki` (API requests per
            client type). Default `db`, which every report reads. `posthog` and
            `loki` need `organization.readUsageTelemetry`, else 403.
          name: sources
          in: query
        - schema:
            type: string
            enum:
              - aggregate
              - ids
              - names
            default: ids
            description: >-
              How people are shown: `names`, `ids` or `aggregate` (no per-person
              list). The deployment can cap it lower; `peopleDetail` in the
              answer says what applied.
          required: false
          description: >-
            How people are shown: `names`, `ids` or `aggregate` (no per-person
            list). The deployment can cap it lower; `peopleDetail` in the answer
            says what applied.
          name: people
          in: query
        - schema:
            type: string
            enum:
              - json
              - pdf
              - both
            default: json
            description: >-
              `json` (default) answers the report. `pdf` answers `{ downloadUrl
              }`, the report rendered to a PDF. `both` answers `{ report,
              downloadUrl }`. A PDF waits for the report generator, so it takes
              longer.
          required: false
          description: >-
            `json` (default) answers the report. `pdf` answers `{ downloadUrl
            }`, the report rendered to a PDF. `both` answers `{ report,
            downloadUrl }`. A PDF waits for the report generator, so it takes
            longer.
          name: format
          in: query
      responses:
        '200':
          description: >-
            The usage report (`format=json`), `{ downloadUrl }` (`pdf`), or `{
            report, downloadUrl }` (`both`)
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/UsageReportV1'
                  - $ref: '#/components/schemas/UsageReportWithPdf'
                  - $ref: '#/components/schemas/UsageReportPdf'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Too many requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '502':
          description: The report generator could not render the PDF
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearerAuth: []
components:
  schemas:
    UsageReportV1:
      type: object
      properties:
        schemaVersion:
          type: number
          enum:
            - 1
        generatedAt:
          type: string
          format: date-time
        window:
          type: object
          properties:
            from:
              type: string
              format: date-time
            to:
              type: string
              format: date-time
            timeZone:
              type: string
          required:
            - from
            - to
            - timeZone
        scope:
          type: object
          properties:
            kind:
              type: string
              enum:
                - organization
                - all
            organizationId:
              type: string
          required:
            - kind
        peopleDetail:
          type: string
          enum:
            - aggregate
            - ids
            - names
        sources:
          type: object
          properties:
            db:
              $ref: '#/components/schemas/UsageReportSourceStatus'
            posthog:
              $ref: '#/components/schemas/UsageReportSourceStatus'
            loki:
              $ref: '#/components/schemas/UsageReportSourceStatus'
          required:
            - db
            - posthog
            - loki
        excluded:
          type: object
          properties:
            organizations:
              type: integer
              description: >-
                Organizations the internal pattern left out that were active in
                the window
            staffRows:
              type: integer
              description: >-
                Rows staff created in the window, left out of every organization
                and product count
          required:
            - organizations
            - staffRows
          description: Only for the `all` scope.
        organizations:
          type: array
          items:
            $ref: '#/components/schemas/UsageReportOrganization'
          description: >-
            The organization asked for, or every organization with external
            activity in the window (and every client), most active first, then
            those only the `posthog` or `loki` source saw, at most 1,000. Counts
            leave out soft-deleted rows, seed sessions, demo clones and rows
            staff created.
        truncated:
          type: object
          properties:
            organizations:
              type: boolean
            products:
              type: boolean
            people:
              type: boolean
            dashboard:
              type: boolean
              description: >-
                A `posthog` query answered its row limit, so some dashboard
                visits, or the evidence that names visitors, are missing.
            recordings:
              type: boolean
          required:
            - organizations
            - products
            - people
            - dashboard
            - recordings
      required:
        - schemaVersion
        - generatedAt
        - window
        - scope
        - peopleDetail
        - sources
        - organizations
        - truncated
    UsageReportWithPdf:
      type: object
      properties:
        report:
          $ref: '#/components/schemas/UsageReportV1'
        downloadUrl:
          type: string
          description: >-
            The stored PDF as a storage URI, not a link: exchange it for a
            short-lived link with `GET /storage/generate-get-presigned-url`.
            Only the caller's organization and cross-organization readers may.
          example: s3://galtea-files/reports/organization_abc/usage_0f1e2d.pdf
      required:
        - report
        - downloadUrl
    UsageReportPdf:
      type: object
      properties:
        downloadUrl:
          type: string
          description: >-
            The stored PDF as a storage URI, not a link: exchange it for a
            short-lived link with `GET /storage/generate-get-presigned-url`.
            Only the caller's organization and cross-organization readers may.
          example: s3://galtea-files/reports/organization_abc/usage_0f1e2d.pdf
      required:
        - downloadUrl
    Error:
      type: object
      properties:
        error:
          type: string
          example: Error type
        message:
          type: string
          example: Error message description
    UsageReportSourceStatus:
      type: object
      properties:
        status:
          type: string
          enum:
            - ok
            - unavailable
            - failed
        reason:
          type: string
          enum:
            - not_configured
            - not_requested
            - timeout
            - upstream_error
          description: >-
            Why the source is not `ok`. `unavailable`: `not_configured` or
            `not_requested`. `failed`: `timeout` or `upstream_error`.
      required:
        - status
    UsageReportOrganization:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        segment:
          type: string
          nullable: true
          enum:
            - client
            - self_serve
            - null
          description: >-
            Client or self-serve, where the deployment names its clients; null
            elsewhere.
        dataRegion:
          type: string
          description: Where the organization keeps its data, for example `EU`.
        lastActivityAt:
          type: string
          nullable: true
          format: date-time
          description: >-
            The latest external activity before the window end, looking back 180
            days.
        flags:
          type: array
          items:
            type: string
            enum:
              - first_evaluation
              - first_session_outside_run
              - back_after_quiet_week
              - quiet_14_days
          description: >-
            `first_evaluation` and `first_session_outside_run`: the first in 180
            days falls in the window. `back_after_quiet_week`: active in the
            window after 7 quiet days. `quiet_14_days`: no external activity in
            the 14 days before the window end.
        products:
          type: array
          items:
            $ref: '#/components/schemas/UsageReportProduct'
          description: >-
            Products with external activity in the window, most active first, at
            most 200.
        people:
          type: array
          items:
            $ref: '#/components/schemas/UsageReportPerson'
          description: >-
            Authors with activity in the window, staff included and marked, at
            most 200. Empty with `aggregate`.
        dashboard:
          allOf:
            - $ref: '#/components/schemas/UsageReportDashboard'
            - description: >-
                Only when the `posthog` source is `ok`. Visitors the attribution
                names as staff (identified or high) are left out of every count
                and list.
        recordings:
          type: array
          items:
            $ref: '#/components/schemas/UsageReportRecording'
          description: >-
            Only when the `posthog` source is `ok`. Recordings of staff visitors
            are left out.
      required:
        - id
        - name
        - segment
        - dataRegion
        - lastActivityAt
        - flags
        - products
        - people
    UsageReportProduct:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        lastActivityAt:
          type: string
          nullable: true
          format: date-time
          description: >-
            The latest external activity before the window end, looking back 180
            days.
        created:
          $ref: '#/components/schemas/UsageReportCreatedCounts'
        sessionsByUser:
          type: array
          items:
            $ref: '#/components/schemas/UsageReportUserCount'
          description: Empty with `peopleDetail` `aggregate`.
        evaluationsByUser:
          type: array
          items:
            $ref: '#/components/schemas/UsageReportUserCount'
          description: Empty with `peopleDetail` `aggregate`.
      required:
        - id
        - name
        - lastActivityAt
        - created
        - sessionsByUser
        - evaluationsByUser
    UsageReportPerson:
      type: object
      properties:
        user:
          $ref: '#/components/schemas/UsageReportUser'
        isStaff:
          type: boolean
          description: Platform staff, or a staff email domain the deployment names.
        created:
          $ref: '#/components/schemas/UsageReportCreatedCounts'
        lastActivityAt:
          type: string
          format: date-time
          nullable: true
        clientTypes:
          allOf:
            - $ref: '#/components/schemas/UsageReportClientTypes'
            - description: API requests per client, only when the `loki` source is `ok`.
      required:
        - user
        - isStaff
        - created
        - lastActivityAt
    UsageReportDashboard:
      type: object
      properties:
        visitors:
          type: integer
        sessions:
          type: integer
        pageviews:
          type: integer
        rageClicks:
          type: integer
        errors:
          type: integer
        visitorList:
          type: array
          items:
            $ref: '#/components/schemas/UsageReportVisitor'
          description: Empty with `peopleDetail` `aggregate`.
      required:
        - visitors
        - sessions
        - pageviews
        - rageClicks
        - errors
        - visitorList
    UsageReportRecording:
      type: object
      properties:
        url:
          type: string
        startedAt:
          type: string
          format: date-time
        activeSeconds:
          type: integer
        durationSeconds:
          type: integer
        user:
          $ref: '#/components/schemas/UsageReportUser'
        confidence:
          type: string
          enum:
            - identified
            - high
            - low
            - conflict
            - none
      required:
        - url
        - startedAt
        - activeSeconds
        - durationSeconds
        - confidence
    UsageReportCreatedCounts:
      type: object
      properties:
        versions:
          type: integer
          description: Versions created in the window
        tests:
          type: integer
          description: Tests created in the window
        testCases:
          type: integer
          description: Test cases created in the window
        specifications:
          type: integer
          description: Specifications created in the window
        runs:
          type: integer
          description: Runs created in the window
        sessions:
          type: integer
          description: Sessions created in the window, seed sessions left out
        evaluations:
          type: integer
          description: Evaluations created in the window
      required:
        - versions
        - tests
        - testCases
        - specifications
        - runs
        - sessions
        - evaluations
    UsageReportUserCount:
      type: object
      properties:
        user:
          $ref: '#/components/schemas/UsageReportUser'
        count:
          type: integer
      required:
        - user
        - count
    UsageReportUser:
      type: object
      properties:
        userId:
          type: string
        name:
          type: string
          description: Only with `peopleDetail` `names`. Never an email.
      required:
        - userId
    UsageReportClientTypes:
      type: object
      properties:
        dashboard:
          type: integer
        sdk:
          type: integer
        cli:
          type: integer
        api:
          type: integer
      required:
        - dashboard
        - sdk
        - cli
        - api
    UsageReportVisitor:
      type: object
      properties:
        visitorRef:
          type: string
        user:
          $ref: '#/components/schemas/UsageReportUser'
        confidence:
          type: string
          enum:
            - identified
            - high
            - low
            - conflict
            - none
        method:
          type: string
          enum:
            - posthog_identified
            - write_minutes
            - audit_minutes
        pageviews:
          type: integer
      required:
        - visitorRef
        - confidence
        - method
        - pageviews
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        API key authorization. Pass your API key in the Authorization header as
        a Bearer token. Both new (`gsk_*`) and legacy (`gsk-`) API keys are
        accepted, e.g. `Authorization: Bearer gsk_...` or `Authorization: Bearer
        gsk-...`.

````

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