# Connect CircleCI

Costfluent reads your CircleCI spend from your organization's usage exports, through CircleCI's API,
with a personal API token of an organization admin. One connection is one CircleCI organization,
named by its organization ID, and the credits every job in it used.

## How Costfluent connects

Costfluent asks CircleCI for a usage export of the days it collects, waits until CircleCI has written
it, and reads the export's files: one row for each job run, with the credits it used by credit type,
such as compute, Docker layer caching, users, storage and network.

Costfluent stores the token encrypted and uses it on `circleci.com` for these calls only:

- reading the organization (`GET /api/v2/organization/{org-id}`), to check the token and the
  organization ID;
- creating a usage export (`POST /api/v2/organizations/{org_id}/usage_export_job`), one for each
  calendar month a sync reads;
- reading that export's status (`GET /api/v2/organizations/{org_id}/usage_export_job/{usage_export_job_id}`);
- downloading the export's files from the links CircleCI gives for them. These links carry their own
  signature, so the token is not sent with them, and a file over 100 MB, CircleCI's own result limit,
  is not read.

The organization ID is the connection's identity, and the token is only ever used for that
connection.

:::caution
CircleCI has no narrower token for usage exports. A personal API token created in the web app has
full read and write access to everything its user can reach, so the token Costfluent stores could
also change your CircleCI organization; Costfluent only makes the calls above. Create the token for
Costfluent alone, give it an expiry, and replace it before it expires
([Managing API tokens](https://circleci.com/docs/guides/toolkit/managing-api-tokens/), read
2026-11-30).
:::

## Prerequisites

1. The Owner or Integration owner organization role in Costfluent.
2. A CircleCI user who is an admin of the organization: CircleCI exports usage only to an
   organization admin's token.

## Connect

### Create the token in CircleCI

<Stepper>

1. Sign in to the CircleCI web app as an admin of the organization you want to connect, select “Org”
   in the sidebar to open the organization's settings, and copy its **Organization ID**, a UUID such
   as `3a1f9c2e-7b4d-4e8a-9c6f-0d2b5e8a1c47`.
2. Open “User Settings”, then “Personal API Tokens”, and select “Create New Token”.
3. Enter a “Token name” that names Costfluent and choose an expiration date, at most a year away.
4. Select “Add API Token” and copy the token. CircleCI shows it only once.

</Stepper>

### Connect in Costfluent

<Stepper>

1. Open **Settings**, then **Integrations**, select **CircleCI**, and open the **Connect** tab.
2. Select "Add API token", keep the suggested **Display name** or enter your own, and paste the
   **Organization ID** and the **Personal API token**.
3. Select "Test connection" to see each check, or "Connect" to save.

</Stepper>

Before storing anything, Costfluent checks that the organization ID is a UUID, so a token or an
organization slug pasted into that field is never sent, and then reads the organization with the
token, so a connection that saves can see it. The check creates no usage export, so that it spends
none of the organization's ten a day, and therefore cannot tell whether the token's user is an
organization admin: the first collection does, and fails saying so if the user is not. A second
connection of the same organization is refused. If CircleCI does not answer during that check,
nothing is saved: the organization is only the connection's once the token has read it, so connect
again later.

## Data and freshness

Connecting imports as far back as your plan's backfill reaches, and at most six months
([Manage connections](/connect/manage-connections#how-it-behaves)). CircleCI's usage export reaches
one year back, so older months collected on request reach the whole months of that year. Cost
arrives by UTC day, the day each job run began, in US dollars, the day after the job ran, and each
sync reads the running month again, and through the 15th the previous month too, so a day CircleCI
revises is replaced, not counted twice.

The export states credits, not money. Costfluent prices every credit at CircleCI's list price, USD
0.0006 a credit: the Performance plan's “$15 for every 25,000 credits”
([Pricing](https://circleci.com/pricing/), read 2026-11-26). The monthly free credits of the Free
and Performance plans and the network and storage your plan includes are priced too, so CircleCI's
cost in Costfluent can be higher than your CircleCI invoice. Plan fees, seats paid outside credits,
contract prices and tax are not in the export.

:::note
CircleCI allows 10 usage exports a day per organization, and each sync makes one export for each
calendar month it reads: one, or two through the 15th. So a CircleCI connection syncs at most every
8 hours: a faster schedule is refused with "CircleCI allows 10 usage exports a day per organization,
so it syncs at most every 8 hours (480 minutes).", a failed sync is retried 8 hours later, and a
sync selected by hand within 7 hours of the previous one is refused, saying how long to wait. When the day's exports are spent,
the months still to read wait for the next UTC day instead of failing, so a first import or a request
for older months can spread over several days.
:::

## Reporting dimensions

- **Service** is CircleCI and the credit type, such as CircleCI Compute, CircleCI Docker layer
  caching, CircleCI Users, CircleCI Storage or CircleCI Network, with the **Service category**
  Developer Tools. Credits of a job that no credit type states are CircleCI Other, so a job's rows
  add up to its total credits.
- **SKU** is the job's resource class, such as `medium` or `macos.m1.medium.gen1`.
- The sub-account is the CircleCI project, by its ID and name, and the resource is the job: its ID
  joins the project's ID, the workflow and the job's name, and its name is the job's name.
- The quantity is the credits; a compute row also carries the job's run time in seconds.
- Each day sums a job's runs, so cost is per job and day, not per pipeline, run or branch. A day
  keeps its 250 most expensive jobs by credits, and puts the rest, per credit type, under the
  resource “Other jobs”, so the day's total stays CircleCI's.
- `circleci:project`, `circleci:workflow` and `circleci:executor` name the project, the workflow and
  the executor, such as `docker`, `machine` or `macos`. They group and filter like any tag, but
  Costfluent adds them itself, so they do not make a line tagged for **Tagged**, tag coverage or a
  coverage alert ([Tags and tag coverage](/allocation/tags)).
- The billing account is the organization ID, CircleCI rows carry no region, and the billing period
  is the calendar month.

## Update or disconnect

### After connecting

The **Manage** tab lists the connection by its display name. Open the gear icon beside it to see
whether the organization is still readable, which workspaces the connection feeds, and which days
have been imported. **Run checks** runs the checks again on request.

### Rotating or removing access

CircleCI's personal API tokens expire and are not rotated for you. Before the token expires, create
a new one the same way, select **Update credentials** on the connection page and paste it with the
same organization ID. A token whose user cannot see that organization is refused. Once the
connection reads with the new token, delete the old one under “User Settings”, then “Personal API
Tokens”.

To retire the connection, remove it in Costfluent, then delete its token. Removing it erases the
cost it imported ([Remove a connection](/connect/manage-connections#remove-a-connection)).

## Troubleshooting

The check's messages say what CircleCI answered:

- **A CircleCI organization ID is written a UUID …** Copy the organization ID from the
  organization's settings, which “Org” in the sidebar of the CircleCI web app opens.
- **CircleCI refused this personal API token.** The token was deleted, expired or mistyped. Create a
  new one as an organization admin and paste it.
- **CircleCI answered that this token's user cannot see organization …** Check the organization ID,
  and create the token as an admin of that organization.
- **A sync that ends with "Reconnect it with a personal API token of an organization admin".**
  CircleCI refused to export the organization's usage with the stored token: its user is not an
  organization admin, or the token expired. Create a new token as an organization admin and select
  **Update credentials**.
- **A sync that waits with "CircleCI allows 10 usage exports a day per organization, and organization
  … has made today's".** The day's exports are spent, by Costfluent or by another tool reading the
  same organization. The months still to read are collected again on the day the message names.

## From your assistant

With the [Costfluent MCP server](/developers/mcp) connected, your assistant answers these with `query_costs`.

```text
Which CircleCI projects and jobs used the most credits over the last 30 days?
```

```text
How did our daily CircleCI compute cost change this month compared with last month?
```
