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

# List an organization's usage history

> Returns the organization's billed inference requests, newest first, one page at a time. Filter by time range, workspace, API key or credit type. Costs are integers in nano-USD (10^-9 USD).



## OpenAPI

````yaml /api-reference/cloud-platform-openapi.json get /v1/organizations/{org_id}/usage/history
openapi: 3.1.0
info:
  description: Account, organization, workspace and billing routes of NEAR AI Cloud.
  title: NEAR AI Cloud Platform API
  version: '5'
servers:
  - url: https://cloud-platform.near.ai
    description: NEAR AI Cloud Platform
security: []
paths:
  /v1/organizations/{org_id}/usage/history:
    get:
      tags:
        - Usage
      summary: List an organization's usage history
      description: >-
        Returns the organization's billed inference requests, newest first, one
        page at a time. Filter by time range, workspace, API key or credit type.
        Costs are integers in nano-USD (10^-9 USD).
      operationId: get_organization_usage_history
      parameters:
        - description: The organization id (a UUID).
          in: path
          name: org_id
          required: true
          schema:
            type: string
        - description: Page size, 1 to 1000. Defaults to 100.
          in: query
          name: limit
          required: false
          schema:
            format: int64
            type: integer
        - description: Number of entries to skip. Defaults to 0.
          in: query
          name: offset
          required: false
          schema:
            format: int64
            type: integer
        - description: >-
            Only entries on or after this day (`YYYY-MM-DD`, start of day UTC)
            or instant (ISO 8601).
          in: query
          name: start_date
          required: false
          schema:
            type: string
        - description: >-
            Only entries on or before this day (`YYYY-MM-DD`, end of day UTC) or
            instant (ISO 8601).
          in: query
          name: end_date
          required: false
          schema:
            type: string
        - description: >-
            Only entries at or after this instant (ISO 8601). Takes precedence
            over `start_date`.
          in: query
          name: start_time
          required: false
          schema:
            type: string
        - description: >-
            Only entries before this instant (ISO 8601). Takes precedence over
            `end_date`.
          in: query
          name: end_time
          required: false
          schema:
            type: string
        - description: Only entries of this workspace.
          in: query
          name: workspace_id
          required: false
          schema:
            format: uuid
            type: string
        - description: Only entries of this API key.
          in: query
          name: api_key_id
          required: false
          schema:
            format: uuid
            type: string
        - description: >-
            Only entries funded by this credit type, for example `grant` or
            `payment`.
          in: query
          name: credit_type
          required: false
          schema:
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsageHistoryResponse'
          description: A page of usage history.
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: A parameter is invalid.
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Missing or invalid credential.
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: The user is not a member of this organization.
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: The organization does not exist.
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Internal error.
        '504':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: The query took too long; narrow the time range.
      security:
        - session: []
components:
  schemas:
    UsageHistoryResponse:
      description: Usage history response
      properties:
        data:
          items:
            $ref: '#/components/schemas/UsageHistoryEntryResponse'
          type: array
        limit:
          format: int64
          type: integer
        offset:
          format: int64
          type: integer
        total:
          description: >-
            Number of matching records. Without filters this is the
            organization's

            recorded request count (`total_requests` in the balance), which can
            exceed

            the rows still stored, so a final page may come back short or empty.
          minimum: 0
          type: integer
      required:
        - data
        - total
        - limit
        - offset
      type: object
    ErrorResponse:
      description: The body of every error answer on the user routes.
      properties:
        error:
          $ref: '#/components/schemas/ErrorDetail'
      required:
        - error
      type: object
    UsageHistoryEntryResponse:
      description: >-
        One inference request billed to an organization. Costs are integers in
        nano-USD (10^-9 USD).
      properties:
        allocation_policy_version:
          type:
            - string
            - 'null'
        api_key_id:
          type: string
        billingDetails:
          type:
            - object
            - 'null'
        cache_read_tokens:
          description: Number of prompt tokens that were cache hits
          format: int32
          type: integer
        cache_write_tokens:
          description: Number of prompt tokens written to provider cache
          format: int32
          type: integer
        contextBand:
          type:
            - string
            - 'null'
        created_at:
          format: date-time
          type: string
        credit_allocations:
          description: Absent for older usage whose funding was not recorded.
          items:
            $ref: '#/components/schemas/CreditAllocationSchema'
          type:
            - array
            - 'null'
        funded_amount:
          format: int64
          type:
            - integer
            - 'null'
        id:
          type: string
        image_count:
          description: Number of images generated (for image generation requests)
          format: int32
          type:
            - integer
            - 'null'
        inference_id:
          description: >-
            The request's inference id (a UUID), the value to send as a
            `requestIds` entry to

            `POST /v1/billing/costs`.
          type:
            - string
            - 'null'
        inference_type:
          type: string
        input_tokens:
          format: int32
          type: integer
        model:
          description: Model name.
          type: string
        output_tokens:
          format: int32
          type: integer
        provider_request_id:
          description: The request id reported by the model provider.
          type:
            - string
            - 'null'
        response_id:
          description: Response ID when called from Responses API
          type:
            - string
            - 'null'
        serviceTier:
          type:
            - string
            - 'null'
        stop_reason:
          description: >-
            Why the inference ended (e.g., "completed", "length",
            "client_disconnect")
          type:
            - string
            - 'null'
        total_cost:
          format: int64
          type: integer
        total_cost_display:
          type: string
        total_tokens:
          format: int32
          type: integer
        unfunded_amount:
          format: int64
          type:
            - integer
            - 'null'
        workspace_id:
          type: string
      required:
        - id
        - workspace_id
        - api_key_id
        - model
        - input_tokens
        - output_tokens
        - cache_read_tokens
        - cache_write_tokens
        - total_tokens
        - total_cost
        - total_cost_display
        - inference_type
        - created_at
      type: object
    ErrorDetail:
      properties:
        code:
          type:
            - string
            - 'null'
        message:
          type: string
        param:
          type:
            - string
            - 'null'
        type:
          type: string
      required:
        - message
        - type
      type: object
    CreditAllocationSchema:
      description: The part of a charge paid by one credit type.
      properties:
        amount:
          description: The amount paid, in nano-USD.
          format: int64
          type: integer
        organization_limit_id:
          description: The credit limit the amount was drawn from.
          format: uuid
          type:
            - string
            - 'null'
        policy_version:
          description: The version of the allocation rules applied.
          type: string
        source:
          description: The credit source, when the credit type has several.
          type:
            - string
            - 'null'
        type:
          description: The credit type that paid this part.
          type: string
      required:
        - type
        - amount
        - policy_version
      type: object
  securitySchemes:
    session:
      bearerFormat: Session token
      description: 'Session token from signing in, sent as `Authorization: Bearer <token>`.'
      scheme: bearer
      type: http

````

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