Core concepts
Wallet and billing
How jobs are paid, refunded and recorded.
API jobs are paid from a USD wallet. It is separate from the credits and subscription you use in the Astorie app: app credits can't pay for API jobs, and wallet funds can't be spent in the app.
Adding funds
Top up in the console under Billing. You can add between $5 and $1,000 at a time. Funds appear once the payment is confirmed.
How a job is paid
- Accepted. The job's price is moved from
available_amounttoreserved_amount. Other jobs can't spend it. - Succeeded. The price is charged. If the final cost is lower, the difference goes back to available.
- Failed, or canceled before it started. The whole amount goes back to available.
An example, starting with $10.00 and a job priced at $1.00:
| After | Available | Reserved | Charged |
|---|---|---|---|
| The job is accepted | $9.00 | $1.00 | $0.00 |
| It succeeds | $9.00 | $0.00 | $1.00 |
| Or it fails | $10.00 | $0.00 | $0.00 |
| Or it is canceled after the provider accepted it | $9.00 | $0.00 | $1.00 |
Checking your balance
import { Astorie } from "@astorie/client";
const client = new Astorie();
const balance = await client.getBalance();
console.log(balance.available_amount, balance.reserved_amount);| Field | Meaning |
|---|---|
available_amount | What new jobs can spend. The only spendable number. |
reserved_amount | Set aside for jobs that haven't settled yet. |
total_usable_amount | Available plus reserved. Don't show this as spendable. |
debt_amount | Money owed. While it is above zero, new jobs get 402 account_in_debt. |
Needs the wallet:read scope.
Billing on a job
Each job has a billing object:
| Field | Meaning |
|---|---|
state | reserved while running, then settled (charged) or released (refunded). |
accepted_max_charge_amount | The price set aside when the job was accepted. |
reserved_amount | How much of that is still set aside. |
charged_amount | What you paid. Zero until the job settles. |
released_amount | What went back to your wallet. |
quote_id | The quote used, or null. |
Your max_charge_amount ceiling isn't stored in billing. It only decides whether the job is accepted.
The ledger
GET /v1/ledger lists every movement of money in order: top-ups (fund), money set aside for a job (reserve), charges (capture) and refunds (release). Use it to reconcile your own records. See List ledger entries.