Introduction
Starleads bills your usage in credits. Every billing period comes with a pool of included credits; each voice call, SMS or other billable action draws it down. When the pool runs low your agents stop working, so you want to know before it happens — not after. This guide shows you how to build a complete balance-monitoring loop on top of the public API using a single API key:- Read your current balance with
GET /Consumption. - Decide whether to alert based on the remaining credits, the usage percentage, and the subscription status.
- When usage is high, drill down with
GET /Consumption/breakdownto see which channels, months and agents consumed the credits.
X-Api-Key header. The company is derived from the key — you never pass a company identifier. Figures are reported as-is: a negative remaining balance or a usage above 100% is published verbatim, so your monitoring can react to overage instead of seeing a clamped 0.
These billing endpoints expose company-wide data (balance, breakdown, contract and ledger). Any holder of your API key can read them. See the Authentication guide before sharing keys.
Getting Started
Read the current balance
Call Endpoint:
GET /Consumption to get the balance for the current billing period. The response tells you how many credits were included, how many were consumed, how many remain, and when the period ends — the end date is when your credits recharge.Read these fields:If the company has no active subscription, this endpoint returns 404, not a zeroed balance. Treat 404 as “no subscription to monitor”, not as “zero credits left”.
GET /ConsumptionDecide whether to alert
With the balance in hand, apply your own alerting rules. A robust monitor checks three things, in order:
- Status first. If
statusis notActive(e.g.PastDue,Paused,Cancelled), alert regardless of the numbers — billing may already be interrupted. - Threshold on the balance. Alert when
remainingCreditsdrops below a floor you choose (for example 500 credits), or whenusagePercentcrosses a ceiling (for example 80%). Use whichever expresses your budget best;usagePercentis convenient because it is normalised across plans. - Overage. A negative
remainingCredits(orusagePercent > 100) means you are already over the included pool. Escalate this separately from a simple “running low” warning.
periodEnd is the recharge date, you can also tell the difference between “low but the period resets tomorrow” and “low with two weeks to go”.No new endpoint here — this step is pure logic on the response from step 1.Drill into the breakdown
When an alert fires (or on a schedule, e.g. weekly), call
GET /Consumption/breakdown over a date range to understand where the credits went. The response splits the total three ways — by channel, by month, and by agent (each agent with its own per-campaign breakdown).The range is passed as from and to query parameters (both inclusive, UTC). It is mandatory, must be ordered (to after from), and may span at most 366 days. A range with no consumption returns a total of 0, not an error.Each of the three axes sums exactly to totalCredits. If the upstream total ever exceeds the sum of the itemised entries, a residual entry is added on each axis so nothing disappears: channel "unattributed", month "unattributed", or an agent with agentId: null and nameStatus: "Unattributed". A deleted agent is still reported, with nameStatus: "Deleted", so its credits are never silently dropped.Read these fields:Endpoint:
GET /Consumption/breakdown?from=...&to=...Code Examples
The examples below assemble the three steps into one runnable monitor. SetTHRESHOLD_CREDITS and THRESHOLD_PERCENT to match your budget.
Read the current balance
Decide whether to alert
Drill into the breakdown
Putting it together
Going Further
- Audit the ledger. To see the individual credit movements behind the totals — one line per debit, credit, adjustment or refund — use
GET /Consumption/transactions. It is paginated with the standardpageNumber/pageSizeconvention. - Inspect your plan and limits.
GET /Subscriptionreturns your plan name, subscription status, active features and effective limits, so a monitor can also flag when you are close to a contractual limit. No pricing information is exposed.
API Reference
Explore all consumption and subscription endpoints:Current consumption
Read the credit balance for the current billing period.
Consumption breakdown
Split consumption by channel, month and agent over a date range.
Consumption transactions
List the individual credit ledger entries, paginated.
Subscription contract
Read your plan, status, active features and effective limits.

