Webhook-free integrations: polling /api/v1/usage for credit alerts
By Qrop Team ·
Qrop has no outbound webhook for usage events. (The PayFast payment notification that reconciles billing is an inbound webhook Qrop's own server receives, not one you can subscribe to.) Nothing fires to your server when your credits run low, and nothing fires when your carried credits run out. (Qrop does email the account owner once when your plan allowance drops to 20% and once when it is used up, but that email isn't a signal your code can act on.) The only way for your own systems to know where you stand is to ask, via GET /api/v1/usage.
That's a deliberate gap, not a missing feature you should wait on: usage numbers change on every generation call, and a webhook system for a value that mutates hundreds of times a minute at real volume is a lot of infrastructure for something a single polled endpoint already answers cheaply. This guide covers what that endpoint actually returns, how often to poll it without wasting requests, and how to turn the response into the low-credit alerts you'd otherwise expect a webhook to give you.
What GET /api/v1/usage actually returns
The endpoint is a single authenticated GET, same Bearer key as every other API call, and it returns a snapshot: current plan, the billing period's start and end, included credits and how many of them are used, carried-over credits from prior periods, and your purchased top-up balance (topUpCredits). It also echoes your plan's current rate limit, which is useful context if you're about to raise your polling frequency.
Two fields matter more than the rest for alerting: includedCreditsUsed against includedCredits tells you how close you are to exhausting this period's allocation, and carriedCredits plus topUpCredits tell you what is left after that. Carried credits are drawn down before included credits, so a low includedCreditsUsed number doesn't necessarily mean you're safe if your carried pool is the one actually being spent. Work out what you can still spend as carriedCredits + (includedCredits - includedCreditsUsed) + topUpCredits.
Running out is a hard stop, so a credit alert is a deadline
Your plan's credits are a hard limit. Once carried credits, included credits and any top-up balance are all used, POST /api/v1/generate and the batch endpoint return a 402 and consume nothing. Nothing is billed beyond your plan price, which means you can't run up a surprise invoice, but it also means a credit alert on the API side is a deadline: you want to know you're close while there is still time to buy a top-up pack or upgrade, not find out when your integration starts failing.
That reframes what you're polling for. You're racing the clock on a number that quietly decreases in the background, and deciding at what point it's worth acting, whether that's a runaway job, a traffic spike worth a plan upgrade, or just expected seasonal volume that a top-up pack covers.
Picking a polling interval
- Once per hour is enough for most integrations. Usage moves in proportion to your own generation volume, not in real time from something external, so there's no benefit to sub-minute polling unless your generation rate is high enough that an hour represents a meaningful chunk of your plan.
- High-volume plans (Growth, Enterprise) generating continuously can reasonably poll every 5 to 15 minutes, since a bad deploy or a runaway retry loop burns through more credits per hour at that volume and you'd rather catch it inside the same incident window than the next morning.
- Don't poll on every generation request, or even once per batch. The usage snapshot doesn't need to be that fresh to be useful, and it adds a second API call (against the same rate limit) for every generation call you make, which is pure overhead for a number that's informational, not something you branch your generation logic on per request.
- Whatever interval you pick, run it from a scheduled job (a cron, a queue worker, a serverless scheduled function) separate from your generation code path, not inline with request handling. Usage checking is a background concern; coupling it to the hot path just adds latency to every generation call for no benefit.
Building the alert yourself
There's no threshold field in the response, you decide what counts as "low" and compare it yourself. A common pattern: alert once when your remaining credits (carriedCredits + includedCredits - includedCreditsUsed + topUpCredits) drop below 20% of your monthly allocation, and alert again, separately, when they fall below roughly one day of your normal volume. Two distinct alerts, not one, because they mean different things: the first is a planning heads-up, the second means requests are about to start returning 402s and someone needs to act today.
Store the last value you alerted on (in whatever state store your polling job already has access to, a database row, a key-value cache) so you don't re-send the same alert every poll once a threshold is crossed. A simple pattern is to only fire when the current period's usage crosses a threshold that the previous poll's usage hadn't, then reset that flag when currentPeriodStart changes, which it will automatically at the start of each new billing period.
If your finance side wants a cost figure, translate it yourself: a top-up pack is priced per credit on the pricing page, so remaining credits multiplied by that rate gives the replacement cost of what you have left. Qrop doesn't report a ZAR figure for the balance because the plan allowance has no cash value.
What to do when the alert fires
A low-credit alert is a signal to check whether the increase is expected. If it's normal growth, that's a prompt to look at Starter, Pro, and Growth plan tiers and see whether the next one up covers your volume, since the included allocation is a hard limit. For a one-off heavy month, a prepaid top-up pack is cheaper than changing plan, and it never expires.
A final alert (almost out) is worth a quick check for anything unexpected first, a misconfigured retry loop hitting POST /api/v1/generate repeatedly on a failure path burns real credits fast and won't show up as a deliberate spike anywhere except this number. If the usage is legitimate, buy a top-up pack or upgrade from the billing dashboard before the balance reaches zero, because a request that finds no credits is refused rather than billed later.
Frequently asked questions
Does Qrop have any usage or billing webhooks I can subscribe to?
No. There is no usage or billing event you can register an endpoint against. The PayFast ITN is an inbound notification that Qrop's own server receives to reconcile payments, not something you can subscribe to. GET /api/v1/usage is the only way to check current usage.
Will polling GET /api/v1/usage frequently affect my rate limit?
It counts against the same per-second and per-minute rate limit as your generation calls, since it's authenticated with the same API key. For the polling intervals recommended here (5 minutes to hourly) this is a negligible fraction of any plan's limit, it only becomes a concern if you poll far more often than the usage number actually changes.
Does the API stop generating codes once I run out of credits?
Yes. Your plan's credits are a hard limit with no overage billing: once carried credits, included credits and any top-up balance are used up, generation requests return a 402 and consume nothing. Buy a prepaid API top-up pack or upgrade your plan from the billing dashboard to continue.
What's the difference between carriedCredits and includedCredits in the response?
includedCredits is this period's fresh allocation from your plan. carriedCredits are unused included credits rolled over from prior periods, capped at 3x the plan's monthly allocation, and they're drawn down before the current period's includedCredits when metering usage, so they appear as a separate field rather than inflating the current period's number.
Can I get near-real-time usage updates instead of polling on an interval?
Not currently, there's no streaming or push option for usage data. GET /api/v1/usage always reflects the latest committed usage at the moment you call it, so the only way to get more current data is to poll more frequently, within the rate-limit tradeoffs covered above.
Related guides
Ready to create your QR code?
Generate a free QR code in seconds: custom colours, logos, and PNG, SVG or PDF output.
Open the generator