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

# Space usage

> Conversations, tasks and events per period, and per source with group_by=source.



## OpenAPI

````yaml openapi/en/cell.json GET /v1/usage
openapi: 3.1.0
info:
  title: Niadra data API
  version: '1'
  description: >-
    Writing, context, history, objects, identity, privacy and governance of one
    space. Every space has a stable address, with the space and the region in
    its name.
servers:
  - url: https://{space}.{region}.api.niadra.com
    variables:
      space:
        default: acme-prod
        description: The space, which comes in the source key.
      region:
        default: us-east-1
        description: The region of the space, which also comes in the key.
security: []
paths:
  /v1/usage:
    get:
      tags:
        - usage
      summary: Space usage
      description: >-
        The usage of the space per hour or per day: billable sessions, context
        reads, history calls, ingested events and the other metrics, with their
        cost in micros. Pass `group_by=source` to split each metric by source,
        or `source_id` to see one source.


        **Authentication.** Console person token with the `analysis` role (or
        admin), or a source key with the `admin` scope.
      operationId: get_usage_v1_usage_get
      parameters:
        - in: query
          name: since
          required: true
          schema:
            format: date-time
            title: Since
            type: string
          example: '2026-09-22T00:00:00Z'
        - in: query
          name: until
          required: true
          schema:
            format: date-time
            title: Until
            type: string
          example: '2026-09-23T00:00:00Z'
        - in: query
          name: granularity
          required: false
          schema:
            $ref: '#/components/schemas/Granularity'
            default: hour
        - in: query
          name: metric
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                maxItems: 20
                type: array
              - type: 'null'
            title: Metric
          description: >-
            Only these metrics, such as `session_billable`, `context_read`,
            `history_call` or `event_ingested`. Up to 20.
        - in: query
          name: source_id
          required: false
          schema:
            anyOf:
              - format: uuid
                type: string
              - type: 'null'
            title: Source Id
        - in: query
          name: group_by
          required: false
          schema:
            anyOf:
              - const: source
                type: string
              - type: 'null'
            title: Group By
          description: '`source` splits every metric by source.'
          example: source
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsageResponse'
              example:
                since: '2026-09-22T00:00:00Z'
                until: '2026-09-23T00:00:00Z'
                granularity: day
                group_by: source
                source_id: null
                items:
                  - start: '2026-09-22T00:00:00Z'
                    metric: session_billable
                    source_id: 0192f79e-11aa-7b20-9f3e-6c1d2e4f5a60
                    quantity: 6120
                    cost_micros: 61200000
                  - start: '2026-09-22T00:00:00Z'
                    metric: session_billable
                    source_id: 0192f79e-11ab-7c31-8e4f-7d2e3f506b71
                    quantity: 1340
                    cost_micros: 13400000
          description: >-
            One item per metric and period, and per source with
            `group_by=source`.
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
          description: The request does not match the contract.
      security:
        - sourceKey: []
        - personToken: []
components:
  schemas:
    Granularity:
      enum:
        - hour
        - day
      title: Granularity
      type: string
    UsageResponse:
      additionalProperties: false
      properties:
        granularity:
          $ref: '#/components/schemas/Granularity'
        group_by:
          anyOf:
            - const: source
              type: string
            - type: 'null'
          title: Group By
        items:
          items:
            $ref: '#/components/schemas/UsageItem'
          title: Items
          type: array
        since:
          format: date-time
          title: Since
          type: string
        source_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Source Id
        until:
          format: date-time
          title: Until
          type: string
      required:
        - since
        - until
        - granularity
        - items
      title: UsageResponse
      type: object
    Problem:
      additionalProperties: false
      description: RFC 9457 problem details; `code` comes from the versioned error catalog.
      properties:
        code:
          title: Code
          type: string
        detail:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Detail
        request_id:
          anyOf:
            - type: string
            - type: 'null'
          default: null
          title: Request Id
        status:
          title: Status
          type: integer
        title:
          title: Title
          type: string
        type:
          default: about:blank
          title: Type
          type: string
      required:
        - title
        - status
        - code
      title: Problem
      type: object
    UsageItem:
      additionalProperties: false
      properties:
        cost_micros:
          description: Our cost in millionths of a US dollar, when the metric has one.
          title: Cost Micros
          type: integer
        metric:
          description: '`session_billable`, `context_read`, `event_ingested`, ...'
          title: Metric
          type: string
        quantity:
          title: Quantity
          type: integer
        source_id:
          anyOf:
            - type: string
            - type: 'null'
          description: >-
            With `group_by=source`: the agent or system; null for the space's
            own work (exports, triggers, webhooks) and for hours counted before
            usage was kept per source.
          title: Source Id
        start:
          description: Start of the hour or UTC day.
          format: date-time
          title: Start
          type: string
      required:
        - start
        - metric
        - quantity
        - cost_micros
      title: UsageItem
      type: object
  securitySchemes:
    sourceKey:
      type: http
      scheme: bearer
      description: nia_sk_...
    personToken:
      type: http
      scheme: bearer
      bearerFormat: JWT

````