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

# Get SDK session usage

> Retrieve how many AI steps your organisation's SDK sessions used over the last `days` days, grouped by the test ID each session was started with. These are the numbers the **Usage by test** table on the usage dashboard shows.

Each session's steps are counted from its step log:

- An **AI step** is a step the AI model had to decide.
- A **cached step** was replayed from the cache instead.
- Steps your own code performed are free and count as neither.

The cache hit rate is `cachedSteps / (cachedSteps + aiSteps)`, as a percentage.

A test ID is the value your SDK passed when it started the session, returned exactly as it was recorded. Sessions started by a MobileBoost Platform test run carry that test's ID. Sessions started without a test ID share one row, with `testId` set to `null`.

By default, sessions started with any of your API keys are included. Pass `apiKeyId` to see only the sessions one key started.

Any API key of your organisation can call this endpoint, including read-only `audit` keys. The organisation is taken from the API key. Results can be up to one minute old.

These numbers won't add up to the monthly allowance on the usage dashboard, because the two measure different things:

- **Monthly allowance:** counts AI model calls from all your runs in the calendar month, including runs that don't go through an SDK session. Vision and non-vision calls are weighted by the step factors in your plan.
- **This endpoint:** counts AI steps of SDK sessions only, unweighted, over the last `days` days. A session counts in the window it started in.

An AI step usually takes one model call, but not always, so even for SDK sessions alone the two can differ.



## OpenAPI

````yaml /openapi.json get /usage/sdk-sessions
openapi: 3.0.2
info:
  title: MobileBoost API
  version: 1.0.0
servers:
  - url: https://api.mobileboost.io
security:
  - BearerAuth: []
paths:
  /usage/sdk-sessions:
    get:
      summary: Get SDK session usage
      description: >-
        Retrieve how many AI steps your organisation's SDK sessions used over
        the last `days` days, grouped by the test ID each session was started
        with. These are the numbers the **Usage by test** table on the usage
        dashboard shows.


        Each session's steps are counted from its step log:


        - An **AI step** is a step the AI model had to decide.

        - A **cached step** was replayed from the cache instead.

        - Steps your own code performed are free and count as neither.


        The cache hit rate is `cachedSteps / (cachedSteps + aiSteps)`, as a
        percentage.


        A test ID is the value your SDK passed when it started the session,
        returned exactly as it was recorded. Sessions started by a MobileBoost
        Platform test run carry that test's ID. Sessions started without a test
        ID share one row, with `testId` set to `null`.


        By default, sessions started with any of your API keys are included.
        Pass `apiKeyId` to see only the sessions one key started.


        Any API key of your organisation can call this endpoint, including
        read-only `audit` keys. The organisation is taken from the API key.
        Results can be up to one minute old.


        These numbers won't add up to the monthly allowance on the usage
        dashboard, because the two measure different things:


        - **Monthly allowance:** counts AI model calls from all your runs in the
        calendar month, including runs that don't go through an SDK session.
        Vision and non-vision calls are weighted by the step factors in your
        plan.

        - **This endpoint:** counts AI steps of SDK sessions only, unweighted,
        over the last `days` days. A session counts in the window it started in.


        An AI step usually takes one model call, but not always, so even for SDK
        sessions alone the two can differ.
      operationId: get_sdk_session_usage
      parameters:
        - required: false
          schema:
            title: Days
            type: integer
            default: 30
            minimum: 1
            maximum: 90
          name: days
          in: query
          description: How many days to look back from now (1-90).
        - required: false
          schema:
            title: API key ID
            type: string
            example: AbCdEfGhIjK
          name: apiKeyId
          in: query
          description: >-
            Only include sessions started with this API key. Use the key ID: the
            part of the key's prefix after `mb_live_`, for example `AbCdEfGhIjK`
            for a key starting `mb_live_AbCdEfGhIjK`. Use `legacy` for keys
            MobileBoost issued to you directly, or `unattributed` for sessions
            from before MobileBoost recorded which key started a session. Omit
            it to include every session.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SdkSessionUsage'
              example:
                window:
                  days: 30
                  start: '2026-08-24T09:00:00Z'
                  end: '2026-09-23T09:00:00Z'
                apiKeyId: null
                truncated: false
                totals:
                  runs: 47
                  failedRuns: 3
                  aiSteps: 1470
                  cachedSteps: 2940
                  cacheHitRate: 66.67
                byTestId:
                  - testId: checkout-flow
                    runs: 42
                    failedRuns: 3
                    aiSteps: 1260
                    cachedSteps: 2940
                    avgAiSteps: 30
                    cacheHitRate: 70
                    avgRuntimeSeconds: 184.6
                  - testId: null
                    runs: 5
                    failedRuns: 0
                    aiSteps: 210
                    cachedSteps: 0
                    avgAiSteps: 42
                    cacheHitRate: 0
                    avgRuntimeSeconds: 96.2
        '401':
          description: The API key is missing or invalid.
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
              example:
                detail: Invalid API key
        '422':
          description: A query parameter is invalid, for example `days` outside 1-90.
components:
  schemas:
    SdkSessionUsage:
      type: object
      properties:
        window:
          type: object
          description: The time window the numbers cover.
          properties:
            days:
              type: integer
              description: The `days` value used.
            start:
              type: string
              format: date-time
              description: Start of the window (UTC).
            end:
              type: string
              format: date-time
              description: End of the window (UTC).
        apiKeyId:
          type: string
          nullable: true
          description: >-
            The `apiKeyId` filter applied, or `null` when sessions from all keys
            are included.
        truncated:
          type: boolean
          description: >-
            `true` when more than 30,000 sessions fall in the window. Only the
            newest 30,000 are counted.
        totals:
          $ref: '#/components/schemas/SdkSessionUsageTotals'
        byTestId:
          type: array
          items:
            $ref: '#/components/schemas/SdkSessionUsageRow'
          description: One row per test ID, ordered by `aiSteps`, highest first.
    SdkSessionUsageTotals:
      type: object
      description: Totals across every session counted.
      properties:
        runs:
          type: integer
          description: Number of sessions.
        failedRuns:
          type: integer
          description: Number of sessions that failed.
        aiSteps:
          type: integer
          description: AI steps across all sessions.
        cachedSteps:
          type: integer
          description: Steps replayed from the cache across all sessions.
        cacheHitRate:
          type: number
          nullable: true
          description: >-
            Percentage (0-100) of cacheable steps served from the cache. `null`
            when no step was cacheable.
    SdkSessionUsageRow:
      type: object
      description: Usage of the sessions started with one test ID.
      properties:
        testId:
          type: string
          nullable: true
          description: >-
            The test ID the sessions were started with. `null` for sessions
            started without one.
        runs:
          type: integer
          description: Number of sessions with this test ID.
        failedRuns:
          type: integer
          description: Number of those sessions that failed.
        aiSteps:
          type: integer
          description: AI steps across those sessions.
        cachedSteps:
          type: integer
          description: >-
            Steps replayed from the cache. Use it with `aiSteps` to combine
            rows, since cache hit rates can't be averaged.
        avgAiSteps:
          type: number
          description: Average AI steps per session.
        cacheHitRate:
          type: number
          nullable: true
          description: >-
            Percentage (0-100) of cacheable steps served from the cache. `null`
            when no step was cacheable.
        avgRuntimeSeconds:
          type: number
          nullable: true
          description: >-
            Average session duration in seconds, ignoring durations of an hour
            or more. `null` when no session had a usable duration.
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer

````