diff --git a/docs/analytics/api.mdx b/docs/analytics/api.mdx index cd886d311..ae19db78b 100644 --- a/docs/analytics/api.mdx +++ b/docs/analytics/api.mdx @@ -56,3 +56,27 @@ export END_DATE="2025-12-31" curl -X GET "https://analytics.sourcegraph.com/api/reports/by-user-client-date?instanceURL=$INSTANCE_URL&startDate=$START_DATE&endDate=$END_DATE" \ -H "Authorization: Bearer $ACCESS_TOKEN" ``` + +### Credit buckets + +The credits API endpoint provides access to credit bucket allocations and consumption for your instance. To retrieve this data, run the following commands: + +```sh +export INSTANCE_URL="" # e.g. example.sourcegraphcloud.com + +curl -X GET "https://analytics.sourcegraph.com/api/credits?instanceURL=$INSTANCE_URL" \ + -H "Authorization: Bearer $ACCESS_TOKEN" +``` + +Optional `startDate` and `endDate` values (formatted as `YYYY-MM-DD`) can be specified to filter buckets by their active period. Both parameters are optional. If neither is specified, all buckets are returned. + +Example: + +```sh +export INSTANCE_URL="" # e.g. example.sourcegraphcloud.com +export START_DATE="2026-05-01" +export END_DATE="2026-12-31" + +curl -X GET "https://analytics.sourcegraph.com/api/credits?instanceURL=$INSTANCE_URL&startDate=$START_DATE&endDate=$END_DATE" \ + -H "Authorization: Bearer $ACCESS_TOKEN" +```