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

# Get phone session metrics

> Returns your organization's ended phone sessions over a window as points: one per hour or day in time_zone (and per group with group_by), each with the sessions, their phone time in seconds and what it cost. A session counts in the bucket it was billed in, as it ended, dedicated phones' at no cost; sessions still going are not counted. The window defaults to the last 7 days and may start at most a year back; hour buckets need a window of 7 days or less.

Minimum role required: Viewer


## OpenAPI

````yaml /api-reference/openapi-backend.json get /sessions/metrics
openapi: 3.1.0
info:
  description: Axilio backend HTTP API.
  title: Axilio API
  version: 0.155.0
servers:
  - url: https://api.axilio.ai/api/v1
    description: Production
security: []
tags:
  - name: Agents
  - name: API Keys
  - name: Billing
  - name: Conversations
  - name: Files
  - name: Messages
  - name: Models
  - name: Organization
  - name: Phones
  - name: Runs
  - name: Sessions
  - name: Skill
  - name: Usage
  - name: Webhooks
paths:
  /sessions/metrics:
    get:
      tags:
        - Sessions
      summary: Get phone session metrics
      description: >-
        Returns your organization's ended phone sessions over a window as
        points: one per hour or day in time_zone (and per group with group_by),
        each with the sessions, their phone time in seconds and what it cost. A
        session counts in the bucket it was billed in, as it ended, dedicated
        phones' at no cost; sessions still going are not counted. The window
        defaults to the last 7 days and may start at most a year back; hour
        buckets need a window of 7 days or less.
      operationId: sessions_get_metrics
      parameters:
        - description: >-
            Start of the window (RFC 3339). Defaults to 7 days before
            period_end_at, and may be at most a year before now.
          explode: false
          in: query
          name: period_start_at
          schema:
            description: >-
              Start of the window (RFC 3339). Defaults to 7 days before
              period_end_at, and may be at most a year before now.
            format: date-time
            type: string
        - description: >-
            End of the window (RFC 3339). Defaults to now, and a later time is
            read as now.
          explode: false
          in: query
          name: period_end_at
          schema:
            description: >-
              End of the window (RFC 3339). Defaults to now, and a later time is
              read as now.
            format: date-time
            type: string
        - description: >-
            Bucket size: hour or day. hour is allowed for windows of 7 days or
            less.
          explode: false
          in: query
          name: granularity
          schema:
            default: day
            description: >-
              Bucket size: hour or day. hour is allowed for windows of 7 days or
              less.
            enum:
              - hour
              - day
            type: string
        - description: >-
            IANA time zone the buckets follow, such as America/Los_Angeles: a
            day starts at local midnight and an hour on the local hour. An
            unknown name is an error.
          explode: false
          in: query
          name: time_zone
          schema:
            default: UTC
            description: >-
              IANA time zone the buckets follow, such as America/Los_Angeles: a
              day starts at local midnight and an hour on the local hour. An
              unknown name is an error.
            type: string
        - description: >-
            Split each bucket by allocated_by, device_class or platform. Omit
            for one point per bucket.
          explode: false
          in: query
          name: group_by
          schema:
            description: >-
              Split each bucket by allocated_by, device_class or platform. Omit
              for one point per bucket.
            enum:
              - allocated_by
              - device_class
              - platform
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PhoneSessionMetricsResponse'
          description: OK
        '403':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/V2ErrorModel'
          description: Forbidden
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/V2ErrorModel'
          description: Unprocessable Entity
        '500':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/V2ErrorModel'
          description: Internal Server Error
      security:
        - apiKeyAuth: []
components:
  schemas:
    PhoneSessionMetricsResponse:
      additionalProperties: false
      description: >-
        Ended phone sessions over the window, one point per bucket (and per
        group with group_by).
      properties:
        points:
          description: >-
            One point per bucket, oldest first, and per group within a bucket
            when grouped. The first bucket starts at or before period_start_at.
          items:
            $ref: '#/components/schemas/PhoneSessionMetricsPoint'
          type:
            - array
            - 'null'
      required:
        - points
      type: object
    V2ErrorModel:
      additionalProperties: false
      description: >-
        Error response, following RFC 9457 (Problem Details for HTTP APIs).
        Returned with a application/problem+json content type.
      properties:
        detail:
          description: >-
            A human-readable explanation specific to this occurrence of the
            problem.
          examples:
            - Property foo is required but is missing.
          type: string
        errors:
          description: Optional list of individual error details
          items:
            $ref: '#/components/schemas/V2ErrorDetail'
          type:
            - array
            - 'null'
        instance:
          description: >-
            A URI reference that identifies the specific occurrence of the
            problem.
          examples:
            - https://example.com/error-log/abc123
          format: uri
          type: string
        status:
          description: HTTP status code
          examples:
            - 400
          format: int64
          type: integer
        title:
          description: >-
            A short, human-readable summary of the problem type. This value
            should not change between occurrences of the error.
          examples:
            - Bad Request
          type: string
        type:
          default: about:blank
          description: A URI reference to human-readable documentation for the error.
          examples:
            - https://example.com/errors/example
          format: uri
          type: string
      type: object
    PhoneSessionMetricsPoint:
      additionalProperties: false
      description: One bucket of ended phone sessions, and one group's when grouped.
      properties:
        allocated_by:
          description: How the sessions were started. Set only with group_by=allocated_by.
          enum:
            - dashboard_run
            - api_run
            - interactive
          type: string
        device_class:
          description: What the sessions drove. Set only with group_by=device_class.
          enum:
            - phone
          type: string
        period_start_at:
          description: >-
            Start of the bucket (RFC 3339, UTC): a local hour or a local
            midnight in time_zone. A session counts in the bucket it was billed
            in, as it ended.
          format: date-time
          type: string
        platform:
          description: The phones' platform. Set only with group_by=platform.
          enum:
            - android
          type: string
        session_cost_microdollars:
          description: >-
            What their phone time cost, in microdollars. A dedicated phone's
            sessions cost nothing.
          format: int64
          type: integer
        session_seconds:
          description: Their phone time, in seconds, dedicated phones' included.
          format: int64
          type: integer
        sessions:
          description: Sessions that ended in the bucket.
          format: int64
          type: integer
      required:
        - period_start_at
        - sessions
        - session_seconds
        - session_cost_microdollars
      type: object
    V2ErrorDetail:
      additionalProperties: false
      description: >-
        One specific problem within an error response, locating the offending
        part of the request.
      properties:
        location:
          description: >-
            Where the error occurred, e.g. 'body.items[3].tags' or
            'path.thing-id'
          type: string
        message:
          description: Error message text
          type: string
        value:
          description: The value at the given location
      type: object
  securitySchemes:
    apiKeyAuth:
      description: Customer API key (axl_ prefix).
      in: header
      name: X-Axilio-Api-Key
      type: apiKey

````

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