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

# Get Credit Usage Report

> Returns a daily credit usage report for an enterprise organization.

`Unary` · [`Billing`](/docs/api-reference/generated/billing/overview)

Returns a daily credit usage report for an enterprise organization.

Each day reports org-wide credits by usage type, plus per-user, per-team,
per-environment, and per-conversation breakdowns (top consumers with the
remainder aggregated into an "Others" bucket) and a per-model breakdown
of intelligence usage.

Use this method to:

* Chart daily credit consumption over a date range
* Attribute credit usage to users, teams, environments, and conversations
* Restrict the report to a single user or service account

### Examples

* Get the report for January:

  Both dates are inclusive and the range must not exceed 31 days.

  ```yaml theme={null}
  organizationId: "b0e12f6c-4c67-429d-a4a6-d9838b5da047"
  dateRange:
    startTime: "2024-01-01T00:00:00Z"
    endTime: "2024-01-31T00:00:00Z"
  ```

### Authorization

Requires `billing:read_usage` permission on the organization. A user
without it can read their own usage by setting filter.subject to their
own user identity; this self-access path is not available to service
accounts.

## Endpoint

```text theme={null}
POST /api/gitpod.v1.BillingService/GetCreditUsageReport
```

Send a Bearer token as described in [Authentication](/docs/api-reference#authenticate-requests). If your organization uses a custom management-plane domain, replace `https://app.ona.com` with that domain.

## Request example

<CodeGroup>
  ```bash cURL theme={null}
  export ONA_HOST=https://app.ona.com
  export ONA_API_KEY=<your-token>

  curl --request POST \
    --url "$ONA_HOST/api/gitpod.v1.BillingService/GetCreditUsageReport" \
    --header "Authorization: Bearer $ONA_API_KEY" \
    --header "Content-Type: application/json" \
    --data '{
    "dateRange": {
      "endTime": "2026-01-01T00:00:00Z",
      "startTime": "2026-01-01T00:00:00Z"
    },
    "organizationId": "<organization-id>"
  }'
  ```

  ```python Python theme={null}
  import gitpod.v1.billing_pb2 as billing_pb2
  import gitpod.v1.usage_pb2 as usage_pb2
  import google.protobuf.timestamp_pb2 as timestamp_pb2
  from ona_sdk import create_client_from_env

  ona = create_client_from_env()
  request = billing_pb2.GetCreditUsageReportRequest(
      organization_id="<organization-id>",
      date_range=usage_pb2.DateRange(
          start_time=timestamp_pb2.Timestamp(seconds=1767225600),
          end_time=timestamp_pb2.Timestamp(seconds=1767225600),
      ),
  )
  response = ona.services.billing.get_credit_usage_report(request)
  print(response)
  ```

  ```typescript TypeScript theme={null}
  import { create } from "@bufbuild/protobuf";
  import { createClientFromEnv } from "@gitpod/sdk";
  import { GetCreditUsageReportRequestSchema } from "@gitpod/sdk/gitpod/v1/billing_pb";
  import { timestampFromDate } from "@bufbuild/protobuf/wkt";

  async function main() {
    const ona = createClientFromEnv();
    const request = create(GetCreditUsageReportRequestSchema, {
      organizationId: "<organization-id>",
      dateRange: {
        startTime: timestampFromDate(new Date("2026-01-01T00:00:00Z")),
        endTime: timestampFromDate(new Date("2026-01-01T00:00:00Z")),
      },
    });
    const response = await ona.services.billing.getCreditUsageReport(request);
    console.log(response);
  }

  main().catch(console.error);
  ```

  ```go Go theme={null}
  package main

  import (
  	"context"
  	"fmt"
  	"log"

  	"connectrpc.com/connect"
  	"github.com/gitpod-io/gitpod-sdk-go/sdk"
  	gitpodpb "github.com/gitpod-io/gitpod-sdk-go/v1"
  	timestamppb "google.golang.org/protobuf/types/known/timestamppb"
  )

  func main() {
  	ona, err := sdk.NewFromEnv()
  	if err != nil {
  		log.Fatal(err)
  	}

  	request := connect.NewRequest(&gitpodpb.GetCreditUsageReportRequest{
  		OrganizationId: "<organization-id>",
  		DateRange: &gitpodpb.DateRange{
  			StartTime: &timestamppb.Timestamp{Seconds: 1767225600},
  			EndTime: &timestamppb.Timestamp{Seconds: 1767225600},
  		},
  	})
  	response, err := ona.Services.Billing.GetCreditUsageReport(context.Background(), request)
  	if err != nil {
  		log.Fatal(err)
  	}
  	fmt.Println(response.Msg)
  }
  ```

  ```json Request body theme={null}
  {
    "dateRange": {
      "endTime": "2026-01-01T00:00:00Z",
      "startTime": "2026-01-01T00:00:00Z"
    },
    "organizationId": "<organization-id>"
  }
  ```
</CodeGroup>

## Request

`gitpod.v1.GetCreditUsageReportRequest`

| Field            | Type                                                                  | Required | Description                                                                                                                                                                                                            |
| ---------------- | --------------------------------------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `organizationId` | string                                                                | Yes      | Constraints: `required=true, string.uuid=true`.                                                                                                                                                                        |
| `dateRange`      | [DateRange](#type-gitpod-v1-date-range)                               | Yes      | Date range for the report. Both start and end dates are inclusive. Time-of-day is ignored; dates are truncated to midnight in the specified timezone. The range must not exceed 31 days. Constraints: `required=true`. |
| `timezone`       | string                                                                | No       | IANA timezone name (e.g. "America/New\_York", "Europe/Berlin") used to bucket daily usage. When empty, defaults to "UTC".                                                                                              |
| `filter`         | [CreditUsageReportFilter](#type-gitpod-v1-credit-usage-report-filter) | No       | Optional filter narrowing the returned data. When unset or empty, the response preserves the default behavior (top-N users + "Others"). See CreditUsageReportFilter for per-field response-scoping semantics.          |

## Response

`gitpod.v1.GetCreditUsageReportResponse`

| Field         | Type                                                            | Required | Description                                                                                                               |
| ------------- | --------------------------------------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------- |
| `updatedAt`   | RFC 3339 timestamp                                              | No       | When the report data was last computed.                                                                                   |
| `dailyUsage`  | array of [DailyCreditUsage](#type-gitpod-v1-daily-credit-usage) | No       | One entry per day in the requested date range.                                                                            |
| `periodStart` | RFC 3339 timestamp                                              | No       | Start of the billing period for this organization. Used by the frontend to filter out months before usage tracking began. |

## Related types

<a id="type-gitpod-v1-agent-execution-credit-usage" />

<Accordion title="AgentExecutionCreditUsage">
  AgentExecutionCreditUsage contains a single agent execution's credit usage for a day, broken down by type.

  `gitpod.v1.AgentExecutionCreditUsage`

  | Field              | Type                   | Required | Description                                              |
  | ------------------ | ---------------------- | -------- | -------------------------------------------------------- |
  | `agentExecutionId` | string                 | No       | Empty when representing the "Others" aggregation bucket. |
  | `displayName`      | string                 | No       |                                                          |
  | `usage`            | array of CreditsByType | No       |                                                          |
</Accordion>

<a id="type-gitpod-v1-credit-usage-report-filter" />

<Accordion title="CreditUsageReportFilter">
  CreditUsageReportFilter narrows the data returned by GetCreditUsageReport.
  Wrapping filters in a message (rather than adding bare fields) lets future
  filters (team, environment, resource kind) be added without further breaking
  changes.

  `gitpod.v1.CreditUsageReportFilter`

  | Field     | Type                               | Required | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
  | --------- | ---------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
  | `subject` | [Subject](#type-gitpod-v1-subject) | No       | Restrict the per-user breakdown to a single subject. The subject must be PRINCIPAL\_USER or PRINCIPAL\_SERVICE\_ACCOUNT and belong to the request's organization. When unset, the report returns the default top-N users + "Others" breakdown. When this field is set: - daily\_usage\[*].user\_usage contains rows only for the requested subject; no "Others" aggregation bucket is produced. - daily\_usage\[*].org\_usage, team\_usage, environment\_usage, and conversation\_usage are omitted (empty). Callers that need those sections should issue an unfiltered call. - period\_start and updated\_at remain populated. |
</Accordion>

<a id="type-gitpod-v1-credits-by-type" />

<Accordion title="CreditsByType">
  CreditsByType contains credits consumed for a single usage type.

  `gitpod.v1.CreditsByType`

  | Field       | Type                                    | Required | Description |
  | ----------- | --------------------------------------- | -------- | ----------- |
  | `usageType` | [UsageType](#enum-gitpod-v1-usage-type) | No       |             |
  | `credits`   | number                                  | No       |             |
</Accordion>

<a id="type-gitpod-v1-daily-credit-usage" />

<Accordion title="DailyCreditUsage">
  DailyCreditUsage contains credit usage for a single day.

  `gitpod.v1.DailyCreditUsage`

  | Field               | Type                                                                               | Required | Description                                                                                                                                   |
  | ------------------- | ---------------------------------------------------------------------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
  | `date`              | RFC 3339 timestamp                                                                 | No       | Start of the day (midnight in the requested timezone).                                                                                        |
  | `orgUsage`          | array of [CreditsByType](#type-gitpod-v1-credits-by-type)                          | No       | Org-wide usage broken down by type.                                                                                                           |
  | `userUsage`         | array of [UserCreditUsage](#type-gitpod-v1-user-credit-usage)                      | No       | Per-user usage for this day (top users + "Others").                                                                                           |
  | `teamUsage`         | array of [TeamCreditUsage](#type-gitpod-v1-team-credit-usage)                      | No       | Per-team usage for this day (top teams + "Others"). Empty team\_id represents the "Others" aggregation bucket.                                |
  | `environmentUsage`  | array of [EnvironmentCreditUsage](#type-gitpod-v1-environment-credit-usage)        | No       | Per-environment usage for this day (top environments + "Others"). Empty environment\_id represents the "Others" aggregation bucket.           |
  | `conversationUsage` | array of [AgentExecutionCreditUsage](#type-gitpod-v1-agent-execution-credit-usage) | No       | Per-agent-execution usage for this day (top conversations + "Others"). Empty agent\_execution\_id represents the "Others" aggregation bucket. |
  | `usageByModel`      | array of [EnterpriseAIUsageByModel](#type-gitpod-v1-enterprise-ai-usage-by-model)  | No       | Org-wide intelligence usage broken down by model.                                                                                             |
</Accordion>

<a id="type-gitpod-v1-date-range" />

<Accordion title="DateRange">
  DateRange specifies a time period for queries.

  `gitpod.v1.DateRange`

  | Field       | Type               | Required | Description                                                             |
  | ----------- | ------------------ | -------- | ----------------------------------------------------------------------- |
  | `startTime` | RFC 3339 timestamp | Yes      | Start time of the date range (inclusive). Constraints: `required=true`. |
  | `endTime`   | RFC 3339 timestamp | Yes      | End time of the date range (exclusive). Constraints: `required=true`.   |
</Accordion>

<a id="type-gitpod-v1-enterprise-ai-usage-by-model" />

<Accordion title="EnterpriseAIUsageByModel">
  `gitpod.v1.EnterpriseAIUsageByModel`

  | Field                      | Type                                  | Required | Description                                                             |
  | -------------------------- | ------------------------------------- | -------- | ----------------------------------------------------------------------- |
  | `model`                    | string                                | No       |                                                                         |
  | `usage`                    | EnterpriseAIUsage                     | No       |                                                                         |
  | `usageByTokenType`         | array of EnterpriseAIUsageByTokenType | No       |                                                                         |
  | `unpricedUsage`            | EnterpriseAIUsage                     | No       | Usage excluded from spend because no matching BYOK rate was configured. |
  | `unpricedUsageByTokenType` | array of EnterpriseAIUsageByTokenType | No       |                                                                         |
</Accordion>

<a id="type-gitpod-v1-environment-credit-usage" />

<Accordion title="EnvironmentCreditUsage">
  EnvironmentCreditUsage contains a single environment's credit usage for a day, broken down by type.

  `gitpod.v1.EnvironmentCreditUsage`

  | Field           | Type                   | Required | Description                                              |
  | --------------- | ---------------------- | -------- | -------------------------------------------------------- |
  | `environmentId` | string                 | No       | Empty when representing the "Others" aggregation bucket. |
  | `displayName`   | string                 | No       |                                                          |
  | `usage`         | array of CreditsByType | No       |                                                          |
</Accordion>

<a id="type-gitpod-v1-subject" />

<Accordion title="Subject">
  `gitpod.v1.Subject`

  | Field       | Type                                   | Required | Description                                                                      |
  | ----------- | -------------------------------------- | -------- | -------------------------------------------------------------------------------- |
  | `id`        | string                                 | No       | id is the UUID of the subject Constraints: `ignore=1, string.uuid=true`.         |
  | `principal` | [Principal](#enum-gitpod-v1-principal) | No       | Principal is the principal of the subject Constraints: `enum.defined_only=true`. |
</Accordion>

<a id="type-gitpod-v1-team-credit-usage" />

<Accordion title="TeamCreditUsage">
  TeamCreditUsage contains a single team's credit usage for a day, broken down by type.

  `gitpod.v1.TeamCreditUsage`

  | Field         | Type                   | Required | Description                                              |
  | ------------- | ---------------------- | -------- | -------------------------------------------------------- |
  | `teamId`      | string                 | No       | Empty when representing the "Others" aggregation bucket. |
  | `displayName` | string                 | No       |                                                          |
  | `usage`       | array of CreditsByType | No       |                                                          |
</Accordion>

<a id="type-gitpod-v1-user-credit-usage" />

<Accordion title="UserCreditUsage">
  UserCreditUsage contains a single user's credit usage, broken down by type.

  `gitpod.v1.UserCreditUsage`

  | Field          | Type                              | Required | Description                                              |
  | -------------- | --------------------------------- | -------- | -------------------------------------------------------- |
  | `userId`       | string                            | No       | Empty when representing the "Others" aggregation bucket. |
  | `displayName`  | string                            | No       |                                                          |
  | `usage`        | array of CreditsByType            | No       |                                                          |
  | `usageByModel` | array of EnterpriseAIUsageByModel | No       | Intelligence usage broken down by model.                 |
</Accordion>

<a id="enum-gitpod-v1-principal" />

<Accordion title="Principal">
  | Value                       | Number | Description |
  | --------------------------- | -----: | ----------- |
  | `PRINCIPAL_UNSPECIFIED`     |      0 |             |
  | `PRINCIPAL_ACCOUNT`         |      1 |             |
  | `PRINCIPAL_USER`            |      2 |             |
  | `PRINCIPAL_RUNNER`          |      3 |             |
  | `PRINCIPAL_ENVIRONMENT`     |      4 |             |
  | `PRINCIPAL_SERVICE_ACCOUNT` |      5 |             |
  | `PRINCIPAL_RUNNER_MANAGER`  |      6 |             |
</Accordion>

<a id="enum-gitpod-v1-usage-type" />

<Accordion title="UsageType">
  UsageType identifies the category of usage.

  | Value                    | Number | Description |
  | ------------------------ | -----: | ----------- |
  | `USAGE_TYPE_UNSPECIFIED` |      0 |             |
  | `USAGE_TYPE_ENVIRONMENT` |      1 |             |
  | `USAGE_TYPE_AGENTIC`     |      2 |             |
</Accordion>
