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

# Get app metered usage

> Returns billing usage records from ClickHouse. Defaults to 7-day window if dates not specified.



## OpenAPI

````yaml /openapi.json get /api/v1/apps/{app_id}/usage
openapi: 3.1.0
info:
  title: Phala Cloud API
  version: 0.1.0
servers:
  - url: https://cloud-api.phala.com
security: []
tags:
  - name: CVMs
    description: Confidential Virtual Machine (CVM) lifecycle management on Phala Network
  - name: Apps
    description: App template management and CVM deployment from app blueprints
  - name: Webhooks
    description: Manage webhook endpoints and monitor delivery history
  - name: SSH Keys
    description: SSH public key management for CVM access
  - name: KMS
    description: >-
      Key Management Service — key derivation, on-chain anchoring, and
      inspection
  - name: Instance Types
    description: Available hardware configurations for CVM deployment
  - name: Attestations
    description: Remote attestation and TEE verification endpoints
paths:
  /api/v1/apps/{app_id}/usage:
    get:
      tags:
        - Apps
      summary: Get app metered usage
      description: >-
        Returns billing usage records from ClickHouse. Defaults to 7-day window
        if dates not specified.
      operationId: get_app_usage_api_v1_apps__app_id__usage_get
      parameters:
        - name: app_id
          in: path
          required: true
          schema:
            type: string
            title: App Id
            description: Hex app identifier
          description: Hex app identifier
        - name: start_date
          in: query
          required: false
          schema:
            anyOf:
              - type: string
                format: date-time
                examples:
                  - '2024-01-01T00:00:00Z'
              - type: 'null'
            description: Start date (ISO 8601)
            title: Start Date
          description: Start date (ISO 8601)
        - name: end_date
          in: query
          required: false
          schema:
            anyOf:
              - type: string
                format: date-time
                examples:
                  - '2024-01-01T00:00:00Z'
              - type: 'null'
            description: End date (ISO 8601)
            title: End Date
          description: End date (ISO 8601)
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            maximum: 5000
            minimum: 1
            description: Max records to return
            default: 500
            title: Limit
          description: Max records to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            description: Records to skip
            default: 0
            title: Offset
          description: Records to skip
      responses:
        '200':
          description: Usage records with cost breakdown
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AppUsageResponse'
        '400':
          description: end_date before start_date
        '401':
          description: Not authenticated
        '403':
          description: No workspace access
        '404':
          description: App not found
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    AppUsageResponse:
      properties:
        usage:
          items:
            $ref: '#/components/schemas/MeteredUsageResponse'
          type: array
          title: Usage
          description: Usage records
        total:
          type: integer
          title: Total
          description: Number of records returned
        total_cost:
          type: number
          title: Total Cost
          description: Sum of costs in USD
      type: object
      required:
        - usage
        - total
        - total_cost
      title: AppUsageResponse
      description: App usage response with cost summary.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    MeteredUsageResponse:
      properties:
        instance_id:
          type: string
          title: Instance Id
          description: CVM instance UUID
        project_id:
          type: integer
          title: Project Id
          description: Project database ID
        team_id:
          type: integer
          title: Team Id
          description: Team database ID
        timestamp:
          type: string
          title: Timestamp
          description: Record timestamp (ISO 8601)
        event_type:
          type: string
          title: Event Type
          description: Usage event type
        cost:
          type: number
          title: Cost
          description: Cost in USD
        details:
          anyOf:
            - type: string
            - type: 'null'
          title: Details
          description: JSON usage details
        usage_type:
          type: string
          title: Usage Type
          description: 'Billing category: compute, storage, etc.'
        billing_start:
          type: string
          title: Billing Start
          description: Billing period start (date)
        billing_end:
          type: string
          title: Billing End
          description: Billing period end (date)
        duration_minutes:
          type: number
          title: Duration Minutes
          description: Usage duration in minutes
        billing_key:
          type: string
          title: Billing Key
          description: Unique billing record key
        billing_hour:
          type: string
          title: Billing Hour
          description: Billing hour bucket
        billing_day:
          type: string
          title: Billing Day
          description: Billing day bucket
      type: object
      required:
        - instance_id
        - project_id
        - team_id
        - timestamp
        - event_type
        - cost
        - details
        - usage_type
        - billing_start
        - billing_end
        - duration_minutes
        - billing_key
        - billing_hour
        - billing_day
      title: MeteredUsageResponse
      description: Single metered usage record.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````