[go: up one dir, main page]

10/16 demo: Build apps faster with AI and your design stack

Announcing Visual Copilot - Figma to production in half the time

Builder.io
Builder.io
Contact sales

10/16 demo: Build apps faster with AI and your design stack

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 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 particular events that occurred, such as code generation, at the organization level.

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. Keep in mind that the response is paginated if there are hundreds of events.

{
  "data": [
    {
      "eventId": "EVENT_ID",
      "timestamp": "2025-07-29T21:33:57.331Z",
      "feature": "fusion",
      "userId": "USER_ID",
      "userEmail": "USER_EMAIL",
      "spaceId": "SPACE_ID",
      "spaceName": "My Fusion Space",
      "metadata": { "tokensUsed": 57842 },
    },
    // ...
  ],
  "pagination": {
    "page": 1,
    "limit": 100,
    "total": 8039,
    "totalPages": 81,
    "hasNext": true,
    "hasPrevious": false,
  }
}

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
  }
}

Retrieves usage data for a specific Space by user.

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.

A sample response is included below:

{
  "data": [
    {
      "userId": "USER_ID",
      "lastActive": "2025-07-29T21:32:36.650Z",
      "metrics": {
        "linesAdded": 0,
        "linesRemoved": 0,
        "linesAccepted": 0,
        "totalLines": 162829,
        "events": 991,
        "userPrompts": 218,
        "creditsUsed": "210",
        "tokens": {
          "total": 69489123,
          "input": 2627914,
          "output": 361338,
          "cacheWrite": 15878681,
          "cacheInput": 50621190
        }
      }
    },
    // ...
  ]
}

Retrieves particular events that occurred, such as code generation, at the Space level.

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.

feature

No

Comma-separated list of features to filter by.

framework

No

Filter by specific framework.

userId

No

Filter by specific user ID.

projectId

No

Filter by specific Project ID.

A sample response is included below. Keep in mind that the response is paginated if there are hundreds of events.

{
  "data": [
    {
      "eventId": "EVENT_ID",
      "timestamp": "2025-07-29T21:33:57.331Z",
      "feature": "fusion",
      "userId": "USER_ID",
      "userEmail": "USER_EMAIL",
      "spaceId": "SPACE_ID",
      "spaceName": "My Fusion Space",
      "metadata": { "tokensUsed": 57842 },
    },
    // ..
  ],
  "pagination": {
    "page": 1,
    "limit": 100,
    "total": 3825,
    "totalPages": 39,
    "hasNext": true,
    "hasPrevious": false,
  }
}

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