Access usage data programmatically
You can create a read-only API key in the web console and use it to call the Calico Cloud Usage API. The API returns the same vCPU usage and managed cluster data shown on the Usage Metrics page, so you can pull it into your own capacity planning, FinOps, and license-compliance workflows instead of exporting it by hand. API keys are read-only and scoped to your organization.
Prerequisites
- You are signed in to the web console as a user with the Admin and Usage Metrics roles, or with the Owner role.
Create an API key for usage metrics
-
In the web console, click the user icon > Settings.
-
Under the API Keys tab, click Generate new key.
-
Enter a description, choose a validity period, and then click Create.
-
Copy or download the generated key and store it in a secure location.
importantThe key is shown only once, at creation. You cannot retrieve it again after you close the dialog.
Call the Usage API
- On the API Keys tab, locate your key and click Actions > Generate commands.
- Select the command for the data you want:
- Summary — per-project vCPU totals and usage over time, across all projects.
- Managed clusters — per-cluster usage rows, with optional project filtering and CSV output.
- Contracts — your organization's contracts, including start and end dates, vCPU hours, package, and add-ons.
- Copy the generated command.
- In the command, replace
<your-secret>with your API key, and set any query parameters, such asstartTime,endTime, andgranularity, for your query. - Run the command. A successful call returns an HTTP
200response with your usage data in JSON.