Skip to main content
Most integrations bring cost data into CostGraph. Chargebee is the opposite direction: CostGraph records each of your customers’ attributed cloud spend against their subscription in your Chargebee account every night, and Chargebee invoices it at the end of the billing term. You resell or charge back cloud infrastructure; CostGraph decides who spent what, Chargebee bills them for it.

How it fits together

  1. A virtual tag decides which subscription each charge belongs to. You write the rules; every value the tag produces is a Chargebee subscription id.
  2. A meter binds that tag key to one metered item price in your Chargebee account. Each night CostGraph records every customer’s attributed spend for each settled day against that item price.
  3. Chargebee prices and invoices. Metered items are charged in arrears, so the usage recorded during a term lands on that term’s invoice.
Spend is recorded in integer cents. Price the item price per cent, because Chargebee does not know what unit the usage carries and nothing on its side will catch a price set as if the values were dollars.

Subscriptions, not customers

Chargebee attaches usage to a subscription and an item price, not to a customer. That shapes both ends of the setup:
  • The tag values are subscription ids, so a customer with two subscriptions needs the tag to name whichever one should carry the cloud spend.
  • The item price must belong to a metered item, and must already be part of that subscription - or have been part of it historically. CostGraph only offers item prices whose item is marked metered.
Automated Metered Billing must be enabled on your Chargebee site for the usage API to accept anything.

Connect

1

Create a metered item price

In Chargebee, create an item with metered enabled, give it a price, and add that item price to the subscriptions you intend to bill.
2

Copy an API key

Open Settings -> Configure Chargebee -> API keys and copy a key.
3

Connect in CostGraph

Open Integrations, choose Chargebee, paste the key, and enter your site name - the subdomain of your Chargebee site, so acme-test for acme-test.chargebee.com. CostGraph verifies the key against Chargebee before saving anything, and stores it encrypted.
4

Bind an item price

Bind a virtual tag key to one of your metered item prices.

Choose who gets billed

Create a virtual tag key named with a chargebee_ prefix, such as chargebee_subscription. The prefix is required: it marks the key as billing-bound, and only prefixed keys can be bound to a meter. The value a rule assigns is the subscription id the spend is recorded against: Any field works as the match: a linked account per customer, a resource name prefix, a project, or an existing tag. See Virtual tags for the rule builder and how overlapping rules resolve. Spend the tag does not match is never recorded.
Usage naming a subscription that does not exist, or an item price that is not part of it, is rejected and the day is recorded with the rejection rather than billed. Check the tag’s values against your Chargebee subscriptions before binding it to an item price.
Because a bound tag key drives invoices, CostGraph protects days that were already recorded: rules on that key cannot be reordered, and new or edited rules must start from a date that has not been recorded yet. Close an old rule with an end date instead of editing it in place.

What lands in Chargebee

Chargebee keeps at most one usage record per subscription, item price and day. So unlike every other billing platform CostGraph exports to, it does not receive a stream of increments: each night CostGraph writes the day’s absolute total, replacing the record it wrote before. That makes corrections straightforward. A day revised downwards simply replaces the earlier record with the lower figure, as long as the term has not been invoiced yet, and no credit note is needed.
Cloud providers restate recent spend, so CostGraph holds each day for two days before recording it, then keeps reconciling the last 35 days. A day belonging to a term that Chargebee has already invoiced can no longer be replaced, so late restatements to a closed term need a manual adjustment in Chargebee.
Chargebee only accepts a usage date that falls inside the period the item price was active on the subscription. A meter bound to an item price you have just added therefore reports nothing for the days before it was added: those days are rejected and recorded with the rejection, not billed. Add the item price to the subscription from the date you want billing to start, and expect the first run to report only from that date onwards.

Day to day

  • The nightly run writes only what changed, so an unchanged day sends nothing.
  • A day is held back rather than recorded wrong when its spend mixes currencies, or a quantity meter meets an unexpected unit. Each held day is recorded with its reason.
  • Deactivating a meter stops recording but keeps its history, so reactivating resumes from what was already written instead of double-billing the window.

Next steps

Virtual tags

Write the rules that decide which subscription each charge belongs to.