## GetCreditUsageExport `client.Billing.GetCreditUsageExport(ctx, body) (*BillingGetCreditUsageExportResponse, error)` **post** `/gitpod.v1.BillingService/GetCreditUsageExport` Returns a signed download URL for a CSV export of credit usage. The URL points to an HTTP endpoint that streams gzip-compressed CSV and is valid for five minutes. The download must be made by the same principal that requested it, carrying its own bearer token. The export range may cover up to a year. For organizations without enterprise credit usage enabled (no billing contract start date), the export instead contains BYOK cost usage with a different column set, and groupBy=RESOURCE is rejected. Use this method to: - Export per-user daily credit usage for external reporting - Export a per-environment and per-conversation resource breakdown ### Examples - Export January's daily summary: ```yaml organizationId: "b0e12f6c-4c67-429d-a4a6-d9838b5da047" dateRange: startTime: "2024-01-01T00:00:00Z" endTime: "2024-01-31T00:00:00Z" groupBy: CREDIT_USAGE_EXPORT_GROUP_BY_DAILY_SUMMARY ``` ### Authorization Requires `billing:read_usage` permission on the organization. ### Parameters - `body BillingGetCreditUsageExportParams` - `DateRange param.Field[DateRange]` Date range to export. Both start and end dates are inclusive; time-of-day is ignored. Unlike GetCreditUsageReport, the range may cover up to a year. - `OrganizationID param.Field[string]` - `GroupBy param.Field[CreditUsageExportGroupBy]` How to group the export data. Defaults to DAILY_SUMMARY. ### Returns - `type BillingGetCreditUsageExportResponse struct{…}` - `DownloadURL string` Signed download URL for the CSV export. Valid for five minutes, and only for the principal that requested it. ### Example ```go package main import ( "context" "fmt" "time" "github.com/gitpod-io/gitpod-sdk-go" "github.com/gitpod-io/gitpod-sdk-go/option" "github.com/gitpod-io/gitpod-sdk-go/shared" ) func main() { client := gitpod.NewClient( option.WithBearerToken("My Bearer Token"), ) response, err := client.Billing.GetCreditUsageExport(context.TODO(), gitpod.BillingGetCreditUsageExportParams{ DateRange: gitpod.F(shared.DateRangeParam{ EndTime: gitpod.F(time.Now()), StartTime: gitpod.F(time.Now()), }), OrganizationID: gitpod.F("b0e12f6c-4c67-429d-a4a6-d9838b5da047"), GroupBy: gitpod.F(gitpod.CreditUsageExportGroupByDailySummary), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.DownloadURL) } ``` #### Response ```json { "downloadUrl": "downloadUrl" } ```