Access Builder's Fusion/Codgen Metrics API for programmatic access to Fusion Space usage metrics.
- Generate a Private Key on your Space's Settings page to gain access to metrics data.
- Request Organization-level or Space-level metrics programmatically.
Use Private Keys when you want to create a server-side only key for writing to your Builder account or to pull content that you want to keep private.
To view or use Private API Keys, you must have Admin permissions.
Tip: Keep your Private API Key secret. It allows anyone to have write access to your content in Builder. Only use it in API calls from your server, not calls from public client applications.
To manage the Private Keys for your Space:
- Go to your Space Account Settings.
- To the right of Private Keys, click the Edit button.
- Create or revoke as many keys as you need.
For more information on how to use Private Keys with models, visit Create a Private Model.
In rare situations, you may need to create a Private Key for your Organization. Follow the same process, but on your Organization's Settings page. For more details on this page, visit Manage your Organization.
Retrieves usage data for an entire Organization.
Include your Organization's Private Key within the Authorization header. Augment your request with the following query parameters:
Parameter | Required? | Description |
---|---|---|
startDate | Yes | Date in YYYY-MM-DD format. This date value is inclusive. |
endDate | Yes | Date in YYYY-MM-DD format. This date value is inclusive. |
granularity | No | Value must be one of |
A sample response is included below:
{
"data": [
{
"period": "2025-07-01",
"metrics": {
"linesAdded": 0,
"linesRemoved": 0,
"totalLines": 1221754,
"linesAccepted": 641,
"events": 8039,
"users": 2,
"userPrompts": 233,
"spaces": [
{
"spaceId": "your-space-id",
"spaceName": "Your Space Name",
"linesAdded": 0,
"linesRemoved": 0,
"totalLines": 1106096,
"linesAccepted": 0
},
...
]
}
}
],
"summary": {
"totalLinesGenerated": 1221754,
"totalLinesAccepted": 641,
"users": 2,
"totalUserPrompts": 233
}
}
Retrieves usage data for a specific Space.
Include your Space's Private Key within the Authorization header. Augment your request with the following query parameters:
Parameter | Required? | Description |
---|---|---|
startDate | Yes | Date in YYYY-MM-DD format. This date value is inclusive. |
endDate | Yes | Date in YYYY-MM-DD format. This date value is inclusive. |
granularity | No | Value must be one of |
A sample response is included below:
{
"data": [
{
"period": "2025-07-01",
"metrics": {
"linesAdded": 0,
"linesRemoved": 0,
"linesAccepted": 0,
"totalLines": 1106096,
"events": 3825,
"users": 2,
"userPrompts": 233,
"tokens": {
"total": 336275030,
"input": 2716702,
"output": 1359459,
"cacheWrite": 24997783,
"cacheInput": 307201086
}
}
}
],
"summary": {
"totalLinesGenerated": 1106096,
"totalLinesAccepted": 0,
"totalUsers": 2,
"totalUserPrompts": 233
}
}
The following errors may occur when making requests to this API endpoint.
Status | Description |
---|---|
400 | The date or granularity format is invalid, or a required parameter is missing. This error is also returned when the date range for a request with a granularity of |
404 | The Organization or Space is not found or the request is not authorized. |
500 | An internal server error has occurred. |
Visit documentation for other Builder APIs, or learn more about how Agent Credits work within Fusion.