Check the balance
getBalance reads the payer’s pools. They belong to the workspace owner, and all workspaces of one owner share them.
For the price of one action, call its estimate rather than doing the sum: it reports
eligible, total_minutes, balance_after and the key’s spend_limit. Top-ups and plan changes happen only in
the web app, at the manage_url from getPlan.
See what was spent
getUsage groups charges and refunds by up to two ofday, month, feature, project, token and member. period picks the current (default) or previous billing period (without a subscription: the last 30 days, or the 30 days
before); from and to pick a span of up to 400 days instead.
charged_minutes, refunded_minutes, net_minutes and operations (or the _projects fields). A refund counts in the bucket of the charge it reverses.
listUsageEvents lists single charges, newest first: one row per charge with its refund, its feature, project_id, job_id and, for v3 jobs, its credential_id, member_user_id and channel. It takes the
same filters and period as getUsage. Use it to reconcile a job.
unknown and no key or member. Usage across the payer’s other workspaces is only in the web app.
To see one key’s month: for the calling key, auth.spent_minutes_this_month and auth.spend_limit_minutes_per_month in getMe; for any key,
credential_id in the usage filters, with from at the start of the UTC month. The cap counts the UTC month and includes work
that is ordered but not charged yet (a pending auto-dub, the next stages of a localization run), so the two can differ.
Read the cost of a job
Job.cost shows what a job holds. It is null on a job that never costs anything, such as an export.
The rules are in Prices and refunds.
Handle errors
Every error isapplication/problem+json. Branch on code, follow recommendation, and retry as retry says. Errors lists every code.
The codes a spending client meets
Failures inside a job
A job that fails answers200 to getJob, with status: failed and a problem of the same shape in error. instance is then /v3/jobs/{id}, and retry is new_key or none, so a new attempt needs a new key. Dub and generation failures
also carry cause_code, and its class sets recommendation:
The whole program
spend_report.py