Watch Now: Making your AI smarter and more accurate for real projects

Announcing Visual Copilot - Figma to production in half the time

Builder.io
Builder.io
Contact sales

Watch Now: Making your AI smarter and more accurate for real projects

Announcing Visual Copilot - Figma to production in half the time

enterprise plans

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:

  1. Go to your Space Account Settings.
  2. To the right of Private Keys, click the Edit button.
  3. 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:

ParameterRequired?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 day, week, month, or quarter. Default value is day.

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:

ParameterRequired?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 day, week, month, or quarter. Default value is day.

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.

StatusDescription

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 day exceeds 90 days.

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.

Was this article helpful?

Product

Visual CMS

Theme Studio for Shopify

Sign up

Login

Featured Integrations

React

Angular

Next.js

Gatsby

Get In Touch

Chat With Us

Twitter

Linkedin

Careers

© 2020 Builder.io, Inc.

Security

Privacy Policy

Terms of Service

Get the latest from Builder.io

By submitting, you agree to our Privacy Policy

  • Fusion

  • Publish

  • Product Updates

  • Figma to Code Guide

  • Headless CMS Guide

  • Headless Commerce Guide

  • Composable DXP Guide

Security

Privacy Policy

SaaS Terms

Compliance

Cookie Preferences

Gartner Cool Vendor 2024