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

# Cost per customer

> Spend per customer for a period, where a customer is a value of the tenant's customer dimension (or of the dimension query parameter, to preview another one). Each customer carries direct spend, the shared spend it receives when the dimension is a tag key with split rules (sharedSplit says whether any applied), its total, the previous period's total, its change, share and a daily sparkline. Totals give the customer count, average and median cost per customer and the spend no customer accounts for (unallocated), so customers plus unallocated add up to the total. trend gives cost per customer per day or month. Amounts are gross (credits left out), in the reporting currency; spend with no exchange rate is left out and listed under unconverted. Layers are never mixed. dimension is null and every list empty when no customer dimension is set. With format=csv or format=xlsx the response is a file with one row per customer, the unallocated row and a total row.



## OpenAPI

````yaml /api-reference/costgraph/openapi.json get /api/v1/tenant/cost/customers
openapi: 3.0.0
info:
  description: Read and manage your CostGraph organization, spend, alerts, and settings.
  title: CostGraph API
  contact: {}
  version: '1.0'
servers:
  - url: https://api.costgraph.ai
security: []
tags:
  - name: ai
    x-group: AI
  - name: ai-serving
    x-group: AI serving
  - name: anomalies
    x-group: Anomalies
  - name: auth
    x-group: Auth
  - name: billing
    x-group: Billing
  - name: billing-export
    x-group: Billing export
  - name: budgets
    x-group: Budgets
  - name: ci
    x-group: CI
  - name: compute-recommendations
    x-group: Compute recommendations
  - name: config
    x-group: Config
  - name: context-graph
    x-group: Context graph
  - name: cost
    x-group: Cost
  - name: gpus
    x-group: GPUs
  - name: graphai
    x-group: Graph AI
  - name: integrations
    x-group: Integrations
  - name: invitations
    x-group: Invitations
  - name: kubernetes-clusters
    x-group: Kubernetes clusters
  - name: marketplace
    x-group: Marketplace
  - name: network-requests
    x-group: Network requests
  - name: notifications
    x-group: Notifications
  - name: oauth
    x-group: OAuth
  - name: oauth-clients
    x-group: OAuth clients
  - name: opencost
    x-group: OpenCost
  - name: organization
    x-group: Audit log
  - name: organizations
    x-group: Organizations
  - name: placement-alternatives
    x-group: Placement alternatives
  - name: reports
    x-group: Reports
  - name: service-map
    x-group: Service map
  - name: settings
    x-group: Settings
  - name: sso
    x-group: Single sign-on
  - name: tenants
    x-group: Tenants
  - name: ticketing
    x-group: Ticketing
  - name: user
    x-group: Users
  - name: virtual-machines
    x-group: Virtual machines
  - name: virtual-tags
    x-group: Virtual tags
  - name: workflows
    x-group: Workflows
paths:
  /api/v1/tenant/cost/customers:
    get:
      tags:
        - cost
      summary: Cost per customer
      description: >-
        Spend per customer for a period, where a customer is a value of the
        tenant's customer dimension (or of the dimension query parameter, to
        preview another one). Each customer carries direct spend, the shared
        spend it receives when the dimension is a tag key with split rules
        (sharedSplit says whether any applied), its total, the previous period's
        total, its change, share and a daily sparkline. Totals give the customer
        count, average and median cost per customer and the spend no customer
        accounts for (unallocated), so customers plus unallocated add up to the
        total. trend gives cost per customer per day or month. Amounts are gross
        (credits left out), in the reporting currency; spend with no exchange
        rate is left out and listed under unconverted. Layers are never mixed.
        dimension is null and every list empty when no customer dimension is
        set. With format=csv or format=xlsx the response is a file with one row
        per customer, the unallocated row and a total row.
      parameters:
        - description: Tenant ID
          name: X-CostGraph-Tenant-ID
          in: header
          required: true
          schema:
            type: string
        - description: >-
            sub_account, tag:<key> or extension:<key>; defaults to the tenant's
            customer dimension
          name: dimension
          in: query
          schema:
            type: string
        - description: Cost layer; defaults to billed
          name: layer
          in: query
          schema:
            type: string
            enum:
              - billed
              - allocation
        - description: Trend bucket; defaults to day
          name: granularity
          in: query
          schema:
            type: string
            enum:
              - day
              - month
        - description: Maximum customers listed, largest spend first; defaults to 100
          name: limit
          in: query
          schema:
            type: integer
        - description: Cost period; defaults to month_to_date
          name: period
          in: query
          schema:
            type: string
            enum:
              - month_to_date
              - last_7d
              - last_30d
              - calendar_month
              - custom
        - description: >-
            Closed calendar month in YYYY-MM format; required when
            period=calendar_month
          name: month
          in: query
          schema:
            type: string
        - description: Window start in RFC3339 format; required when period=custom
          name: start
          in: query
          schema:
            type: string
        - description: Window end in RFC3339 format; required when period=custom
          name: end
          in: query
          schema:
            type: string
        - description: >-
            ISO 4217 code to express every amount in; defaults to the currency
            most of the period's spend was billed in
          name: reporting_currency
          in: query
          schema:
            type: string
        - description: >-
            Repeated key:value dimension filter, same keys and modifiers as
            /cost/query
          name: filter
          in: query
          style: form
          explode: false
          schema:
            type: array
            items:
              type: string
        - description: Response format; defaults to json
          name: format
          in: query
          schema:
            type: string
            enum:
              - json
              - csv
              - xlsx
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/responses.SuccessResponse'
                  - type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/cost.Customers'
            text/csv:
              schema:
                allOf:
                  - $ref: '#/components/schemas/responses.SuccessResponse'
                  - type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/cost.Customers'
            application/vnd.openxmlformats-officedocument.spreadsheetml.sheet:
              schema:
                allOf:
                  - $ref: '#/components/schemas/responses.SuccessResponse'
                  - type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/cost.Customers'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/responses.ErrorResponse'
            text/csv:
              schema:
                $ref: '#/components/schemas/responses.ErrorResponse'
            application/vnd.openxmlformats-officedocument.spreadsheetml.sheet:
              schema:
                $ref: '#/components/schemas/responses.ErrorResponse'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/responses.ErrorResponse'
            text/csv:
              schema:
                $ref: '#/components/schemas/responses.ErrorResponse'
            application/vnd.openxmlformats-officedocument.spreadsheetml.sheet:
              schema:
                $ref: '#/components/schemas/responses.ErrorResponse'
      security:
        - BearerAuth: []
components:
  schemas:
    responses.SuccessResponse:
      type: object
      required:
        - message
        - status
      properties:
        data: {}
        message:
          type: string
          example: some message
        status:
          type: string
          example: success
    cost.Customers:
      type: object
      properties:
        customers:
          type: array
          items:
            $ref: '#/components/schemas/cost.Customer'
        days:
          type: array
          items:
            type: string
        dimension:
          type: string
          nullable: true
        granularity:
          type: string
        layer:
          type: string
        previousComparable:
          type: boolean
        reportingCurrency:
          type: string
        sharedSplit:
          type: boolean
        totals:
          $ref: '#/components/schemas/cost.CustomerTotals'
        trend:
          type: array
          items:
            $ref: '#/components/schemas/cost.CustomerTrendPoint'
        unconverted:
          type: array
          items:
            $ref: '#/components/schemas/cost.UnconvertedTotal'
    responses.ErrorResponse:
      type: object
      required:
        - message
        - status
      properties:
        message:
          type: string
          example: some message
        status:
          type: string
          example: error
    cost.Customer:
      type: object
      properties:
        changeAmount:
          type: number
          x-semantic: costAmount
        changePct:
          type: number
          x-semantic: percentage
          nullable: true
        current:
          type: number
          x-semantic: costAmount
        direct:
          type: number
          x-semantic: costAmount
        key:
          type: string
        label:
          type: string
          nullable: true
        previous:
          type: number
          x-semantic: costAmount
        share:
          type: number
          x-semantic: percentage
        shared:
          type: number
          x-semantic: costAmount
        sparkline:
          type: array
          items:
            $ref: '#/components/schemas/cost.CustomerPoint'
    cost.CustomerTotals:
      type: object
      properties:
        averageCostPerCustomer:
          type: number
          x-semantic: costAmount
          nullable: true
        customers:
          type: integer
        medianCostPerCustomer:
          type: number
          x-semantic: costAmount
          nullable: true
        previous:
          type: number
          x-semantic: costAmount
        previousAverageCostPerCustomer:
          type: number
          x-semantic: costAmount
          nullable: true
        previousCustomers:
          type: integer
        previousUnallocated:
          type: number
          x-semantic: costAmount
        total:
          type: number
          x-semantic: costAmount
        unallocated:
          type: number
          x-semantic: costAmount
        unallocatedShare:
          type: number
          x-semantic: percentage
          nullable: true
    cost.CustomerTrendPoint:
      type: object
      properties:
        bucket:
          type: string
        costPerCustomer:
          type: number
          x-semantic: costAmount
          nullable: true
        customerCost:
          type: number
          x-semantic: costAmount
        customers:
          type: integer
        unallocated:
          type: number
          x-semantic: costAmount
    cost.UnconvertedTotal:
      type: object
      properties:
        currency:
          description: ISO 4217 code of spend that has no exchange rate on record.
          type: string
        nativeTotal:
          description: >-
            Spend in the selected period left out of every converted total, in
            Currency.
          type: number
          x-semantic: costAmount
    cost.CustomerPoint:
      type: object
      properties:
        cost:
          type: number
          x-semantic: costAmount
        day:
          type: string
  securitySchemes:
    BearerAuth:
      description: Enter "Bearer {token}"
      type: apiKey
      name: Authorization
      in: header

````

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