Get consumption analytics
curl --request GET \
--url https://server.codeium.com/api/v2alpha/analytics/consumption \
--header 'Authorization: Bearer <token>'import requests
url = "https://server.codeium.com/api/v2alpha/analytics/consumption"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://server.codeium.com/api/v2alpha/analytics/consumption', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://server.codeium.com/api/v2alpha/analytics/consumption",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://server.codeium.com/api/v2alpha/analytics/consumption"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://server.codeium.com/api/v2alpha/analytics/consumption")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://server.codeium.com/api/v2alpha/analytics/consumption")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"data": [
{
"timestamp": "2026-06-15",
"user_id": "user_abc123",
"user_email": "alice@example.com",
"consumption": {
"prompt_credits": 1250,
"flex_credits": 340,
"message_count": 87,
"user_message_count": 31
}
},
{
"timestamp": "2026-06-15",
"user_id": "user_def456",
"user_email": "bob@example.com",
"consumption": {
"prompt_credits": 980,
"flex_credits": 150,
"message_count": 52,
"user_message_count": 19
}
}
],
"pagination": {
"next_page_cursor": null
},
"metadata": {
"billing_strategy": "CREDITS",
"data_freshness": "2026-06-16T03:00:00Z",
"query_time_ms": 1423,
"team_id": "team_abc123"
}
}Analytics API
Get Consumption
Query credit, ACU, or token consumption analytics with flexible filtering, grouping, and pagination.
GET
/
api
/
v2alpha
/
analytics
/
consumption
Get consumption analytics
curl --request GET \
--url https://server.codeium.com/api/v2alpha/analytics/consumption \
--header 'Authorization: Bearer <token>'import requests
url = "https://server.codeium.com/api/v2alpha/analytics/consumption"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://server.codeium.com/api/v2alpha/analytics/consumption', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://server.codeium.com/api/v2alpha/analytics/consumption",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://server.codeium.com/api/v2alpha/analytics/consumption"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://server.codeium.com/api/v2alpha/analytics/consumption")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://server.codeium.com/api/v2alpha/analytics/consumption")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"data": [
{
"timestamp": "2026-06-15",
"user_id": "user_abc123",
"user_email": "alice@example.com",
"consumption": {
"prompt_credits": 1250,
"flex_credits": 340,
"message_count": 87,
"user_message_count": 31
}
},
{
"timestamp": "2026-06-15",
"user_id": "user_def456",
"user_email": "bob@example.com",
"consumption": {
"prompt_credits": 980,
"flex_credits": 150,
"message_count": 52,
"user_message_count": 19
}
}
],
"pagination": {
"next_page_cursor": null
},
"metadata": {
"billing_strategy": "CREDITS",
"data_freshness": "2026-06-16T03:00:00Z",
"query_time_ms": 1423,
"team_id": "team_abc123"
}
}This is a v2 endpoint that uses Bearer token authentication and query parameters, unlike the v1 Analytics API which uses service keys in the request body. See Authentication below.
This endpoint is not intended for real-time usage monitoring. Data is hourly-aggregated and the
rate limit is low (10 requests per hour per team). Use it for periodic reporting and bulk export.
Authentication
This endpoint uses Bearer token authentication. Include your token in theAuthorization header:
Authorization: Bearer <your_token>
Billing Strategy
The response shape depends on your team’s billing strategy:| Strategy | Populated fields | Description |
|---|---|---|
ACU | billed_acus | Standard Devin enterprise billing, shared with Devin Cloud |
CREDITS | prompt_credits, flex_credits | Legacy Windsurf enterprises |
DOLLARS | tokens | Select teams with granular token billing enabled (see Token Usage) |
message_count and user_message_count fields (inside consumption) are returned regardless of
billing strategy. user_message_count counts only messages a user sent to the agent, from any client (Devin
Desktop, the JetBrains plugin, or the CLI); it is the same number as “messages sent” in the analytics UI.
message_count counts every billing event, including the follow-on model and tool requests within each turn. user_message_count is null for rows with no
user-message attribution (usage before 2026-04-11).
Token Usage
For teams with granular token billing enabled (DOLLARS), each row also includes a tokens object with the
token counts for the row. It uses the same granularity and group_by as consumption, so grouping by
session gives per-session token totals.
| Field | Description |
|---|---|
input_tokens | Uncached input tokens. Excludes cache reads and writes. |
cache_read_tokens | Input tokens read from the model provider’s prompt cache. |
cache_write_tokens | Input tokens written to the model provider’s prompt cache. |
output_tokens | Output tokens. |
input_tokens + cache_read_tokens + cache_write_tokens. Usage from before token counts
were recorded for this endpoint counts as 0. Teams not billed per token, and
requests authenticated with a Windsurf service key, don’t receive the tokens object; Windsurf service-key
requests report the team’s CREDITS or ACU strategy and fields instead of DOLLARS.
For these organizations, metadata.billing_strategy is DOLLARS and consumption contains only message_count and user_message_count: credit and ACU
fields (prompt_credits, flex_credits, billed_acus) are omitted.
Grouping and Granularity
Usegranularity and group_by to control the shape of returned data:
- No granularity or grouping — returns a single aggregated row for the entire date range
granularity=daily— each row includes atimestampinYYYY-MM-DDformatgranularity=monthly— each row includes atimestampinYYYY-MMformatgroup_by=user— each row includes auser_idanduser_emailgroup_by=session— each row includes asession_idgroup_by=user,model_uid— each row includesuser_id,user_email, andmodel_uidgroup_by=ide— each row includes anidegroup_by=ide,ide_version— each row includesideandide_version(grouping byide_versionrequiresideto also be included)group_by=os— each row includes anos, such asdarwin(macOS),windows, orlinux
To measure what the agent produced rather than what it consumed, use
Get Output (
metric=loc_inserted,loc_deleted), which returns
accepted lines of code with the same filters and grouping dimensions.Pagination
Results are paginated with a default page size of 1,000 rows (max 10,000). When more results are available, the response includes anext_page_cursor in the pagination object. Pass it as the page_cursor query
parameter to fetch the next page.
Page cursors expire after 24 hours. A follow-up page request does not count as a new query against your rate limit.
Rate Limits
This endpoint is rate-limited to 10 requests per hour per team. If you exceed this limit, the server returns429 Too Many Requests with a Retry-After header.
Paginating an earlier query (following a next_page_cursor) does not count against this limit —
only the initial query for each report does. The low limit reflects that this endpoint is for
periodic reporting, not real-time usage monitoring.Authorizations
A service key with Analytics Read permission, passed as a Bearer token in the Authorization header.
Create a service key in your team settings under the "Service Keys" section.
Query Parameters
Comma-separated list of dimensions to group results by. Supported dimensions:
user— includesuser_idanduser_emailin each rowmodel_uid— includesmodel_uidin each rowide— includesidein each rowide_version— includeside_versionin each row; requiresideto also be includedos— includesosin each row

