# Connect Confluent Cloud

Costfluent reads your Confluent Cloud spend from the organization's costs API, with a Cloud API key
of a service account you create for it. One connection is one Confluent Cloud organization, and the
cost of every environment, cluster, connector and compute pool in it.

## How Costfluent connects

Costfluent stores the API key and its secret encrypted and uses them for two calls: the organization
the key belongs to, and that organization's daily costs. The organization is the connection's
identity, so you do not enter it. The key is only ever used for that connection.

:::caution
Confluent Cloud's costs need the **BillingAdmin** role on the organization, and that role can also
update the organization's payment details and promotion codes. Give it to a service account created
for Costfluent alone, and give that account no other role, so you can revoke it without touching
anything else.
:::

## Prerequisites

1. The Owner or Integration owner organization role in Costfluent.
2. A service account for Costfluent in the Confluent Cloud console, under **Administration**, then
   **Accounts and access**, holding the **BillingAdmin** role on the organization.
3. A Cloud API key owned by that service account, created under **Administration**, then
   **API keys**, with the resource scope **Cloud resource management**. A cluster's API key cannot
   read costs. Copy the key and its secret before you leave that screen: Confluent Cloud does not
   show the secret again.

## Connect

<Stepper>

1. Open **Settings**, then **Integrations**, select **Confluent Cloud**, and open the **Connect**
   tab.
2. Select "Add API key", keep the suggested **Display name** or enter your own, and paste the key
   into **API key** and its secret into **API secret**.
3. Select "Test connection" to see each check, or "Connect" to save.

</Stepper>

Costfluent reads the key's organization and one day of its costs before storing anything, so a
connection that saves can read your cost. A second connection of the same organization is refused.
If Confluent Cloud does not answer during that check, the connection is saved anyway and checked
again automatically.

## 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)). Confluent Cloud serves costs
one year back, so older months collected on request reach the whole months of that year. Cost
arrives by UTC day, in US dollars, net of discounts and promotional credits.

:::note
Confluent Cloud publishes a day's costs up to 72 hours after the day ends, so the newest days
arrive about three days late, and a connection is not reported as late until then.
:::

:::caution
If you pay for Confluent Cloud through AWS Marketplace, Azure Marketplace or Google Cloud
Marketplace, its charges are also on that cloud's bill. Connecting both counts them twice.
:::

## Reporting dimensions

- **Account** is the environment, by its ID; a cost that belongs to no environment is on the
  organization.
- **Resource** is the cluster, connector, compute pool or other resource, by its name and ID.
- **Service** is the product as Confluent Cloud names it, such as `KAFKA`, `CONNECT` or `FLINK`,
  and its **Service category** is `Analytics`, or `Other` for a support plan.
- **SKU** is the product and the line type, such as `KAFKA/KAFKA_NUM_CKUS`.
- A promotional credit (line type `PROMO_CREDIT`) is a negative cost with the charge type `Credit`.
- The billing account is the organization, and the billing period is the calendar month.

## Update or disconnect

### After connecting

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

### Rotating or removing access

Select **Update credentials** on the connection page and paste a new Cloud API key of the same
service account and its secret; then delete the old key in the Confluent Cloud console.

To retire the connection, remove it in Costfluent, then delete its key and its service account in
the Confluent Cloud console. Removing it erases the cost it imported
([Remove a connection](/connect/manage-connections#remove-a-connection)).

## Troubleshooting

- **A Confluent Cloud API key and its secret are required.** One of the two fields is empty. Paste
  both.
- **A Confluent Cloud API key cannot contain a colon or whitespace. Paste the key and its secret as
  Confluent Cloud showed them.** The key field holds more than the key. Paste the key alone into **API key**
  and the secret into **API secret**.
- **Confluent Cloud refused this key. Use a Cloud API key (resource scope Cloud resource
  management) and its secret, not a cluster's API key.** The key or secret is wrong, the key was
  deleted, or it is a cluster's key. Create a Cloud API key for the service account and paste both
  values.
- **This key can see no Confluent Cloud organization. Use a Cloud API key of a service account in
  the organization to connect.** The key's owner belongs to no organization the key may read.
  Create the key for the service account in the organization you want to connect.
- **This key can see more than one Confluent Cloud organization. Use a Cloud API key of a service
  account in the organization to connect.** A user's key can reach several organizations. Use a
  key owned by a service account, which belongs to one.
- **Confluent Cloud refused the costs for this key. Give the key's service account the BillingAdmin
  role on the organization.** The service account lacks the role. Grant **BillingAdmin** on the
  organization, then select **Run checks**.
- **This key belongs to another organization.** Shown when updating credentials. Connect that
  organization as a new connection.
