Open in
Billing
Inspect your prepaid balance, top up by card, configure auto-reload thresholds and amounts, and list every transaction behind your organization
ThunderPhone is prepaid. Each organization carries a USD balance that
decrements as calls are placed. A new account's first organization also
starts with free call credit (test_call_budget_cents),
which every call uses before the cash balance. It can also pay the first
month of one ThunderPhone number, released after 7 days unless you add
funds; other number fees and voice samples need cash. Once the free credit is used up,
if the balance reaches $0.00, inbound calls are rejected and outbound calls
return 402 Payment Required. A monthly spending limit can
also stop new calls. These endpoints let you query balance state, top up
via Stripe, and configure automatic reloads.
Endpoints
| Method | Path | Description |
|---|---|---|
GET | /v1/billing | Get billing account state |
PATCH | /v1/billing | Update auto-reload settings |
POST | /v1/billing/top-up | Create a top-up payment intent (one-time charge) |
POST | /v1/billing/setup-intent | Create a Stripe SetupIntent for saving a card |
POST | /v1/billing/default-payment-method | Set the default payment method |
GET | /v1/billing/payment-methods | List saved cards |
DELETE | /v1/billing/payment-methods/{payment_method_id} | Remove a saved card |
GET | /v1/billing/transactions | List balance transactions |
GET | /v1/billing/transactions/{transaction_id}/receipt | Get the receipt link for a top-up |
Billing account object
{
"balance_cents": 125000,
"available_cash_cents": 124820,
"balance_usd": "1250.00",
"currency": "usd",
"test_call_budget_cents": 1000,
"test_call_budget_remaining_cents": 0,
"auto_reload_enabled": true,
"auto_reload_minimum_cents": 1000,
"auto_reload_amount_cents": 5000,
"auto_reload_monthly_limit_cents": null,
"monthly_spending_limit_cents": null,
"current_month_usage_spend_cents": 1170,
"spending_limit_reached": false,
"auto_reload_status": "ok",
"auto_reload_failure_code": null,
"auto_reload_next_retry_at": null,
"auto_reload_failed_amount_cents": null,
"auto_reload_failed_at": null,
"auto_reload_consecutive_declines": null,
"last_auto_reload": {
"amount_cents": 5000,
"created_at": "2026-09-20T14:02:11.482Z"
},
"auto_reload_month_spend_cents": 5000,
"month_spend_cents": 1170,
"average_daily_spend_cents_7d": 390,
"balance_runway_days": 320,
"last_top_up": {
"amount_cents": 5000,
"created_at": "2026-09-20T14:02:11.482Z",
"kind": "auto"
},
"has_payment_method": true,
"has_ever_topped_up": true,
"pricing": {
"model": "grandfathered",
"moves_on": "2026-12-01"
}
}| Field | Type | Description |
|---|---|---|
balance_cents | integer | Current cash balance in USD cents. The free call credit is not included |
available_cash_cents | integer | Read-only. balance_cents minus amounts held for calls in progress and for phone-number purchases being completed |
balance_usd | string | Formatted, e.g. "1250.00" |
currency | string | Always usd |
test_call_budget_cents | integer | Read-only. The free call credit the organization started with, in cents: 1000 for a new account's first organization, 0 for organizations the same person adds later |
test_call_budget_remaining_cents | integer | Read-only. Free call credit left. Calls draw from it before the cash balance |
auto_reload_enabled | boolean | Whether automatic top-ups are on. Turned off automatically when a top-up is refunded or disputed; set it back to true to resume |
auto_reload_minimum_cents | integer | Balance threshold that triggers a reload |
auto_reload_amount_cents | integer | Amount to charge on reload |
auto_reload_monthly_limit_cents | integer | null | The monthly spending limit: new calls and usage stop once this calendar month's usage (UTC) reaches it, and auto-reloads stop once they would pass it. null = no limit. Sending 0 is treated as null |
monthly_spending_limit_cents | integer | null | Read-only. The same limit as auto_reload_monthly_limit_cents |
current_month_usage_spend_cents | integer | Read-only. Usage charges this calendar month in UTC, as the spending limit counts them |
spending_limit_reached | boolean | Read-only. true while this month's usage has reached the spending limit, so new calls are refused |
auto_reload_status | string | Read-only. off (auto-reload disabled), ok, retrying (the default card was declined, or Stripe could not charge it at all, in which case auto_reload_failure_code is payment_method_unusable; the next attempt waits out a 1h / 6h / 24h backoff), stopped (the bank refused the default card outright, or the card was declined 5 times in a row, in which case auto_reload_failure_code is repeated_declines; it is not retried until you set another default card, the card's details are updated, or a manual top-up succeeds), or capped (this month's auto-reloads plus auto_reload_amount_cents would exceed auto_reload_monthly_limit_cents, so no auto-reload runs until the next calendar month in UTC or a higher limit) |
auto_reload_failure_code | string | null | Read-only. Why the latest auto-reload failed while retrying or stopped, such as card_declined, payment_method_unusable or repeated_declines; null otherwise |
auto_reload_next_retry_at | string | null | Read-only. ISO 8601 end of the current backoff while retrying. Can be in the past: the retry runs on the next call after it, including a call attempt that is rejected because the balance is below zero |
auto_reload_failed_amount_cents | integer | null | Read-only. Amount the declined auto-reload tried to charge, while retrying or stopped |
auto_reload_failed_at | string | null | Read-only. ISO 8601 time of the latest decline, while retrying or stopped |
auto_reload_consecutive_declines | integer | null | Read-only. Failed auto-reloads in a row on the current default card, while retrying or stopped; null otherwise |
last_auto_reload | object | null | Read-only. amount_cents and created_at of the newest successful auto-reload, or null before the first one |
auto_reload_month_spend_cents | integer | Read-only. Auto-reload credits this calendar month (UTC), as auto_reload_monthly_limit_cents counts them |
month_spend_cents | integer | Read-only. Usage charges (calls, phone-number rent, conversion reports, voice samples) this calendar month in the organization's reporting time zone, today included. Top-ups, auto-reloads and adjustments are excluded |
average_daily_spend_cents_7d | integer | null | Read-only. Usage charges over last week, the 7 whole days ending yesterday in the organization's reporting time zone, averaged per day of history (7 days, or the account's age if younger, at least 1 day; an account opened today counts today so far as one day), rounded. Top-ups, auto-reloads and adjustments are excluded. null when there was no usage in that window |
balance_runway_days | integer | null | Read-only. Whole days balance_cents lasts at that daily average (0 means less than a day). null when the balance is zero or negative or there was no recent usage |
last_top_up | object | null | Read-only. amount_cents, created_at and kind (manual or auto) of the newest successful top-up, or null before the first one |
has_payment_method | boolean | Derived — true iff a default Stripe payment method is set |
has_ever_topped_up | boolean | Derived — true once the account has at least one successful manual top-up or auto-reload |
pricing | object | Read-only. Which pricing the account is on today: model is cost_plus (each call's parts at providers' list prices plus a markup; see Pricing), grandfathered (the account's earlier pricing, until it moves) or contract (a customer contract sets the price). moves_on is the UTC day a grandfathered account moves to cost_plus (at the latest 2026-12-01), else null. An owner or admin can switch early from the app's Billing page (Switch now); the switch is one way |
Get billing account
curl https://api.thunderphone.com/v1/billing \
-H "Authorization: Bearer sk_live_YOUR_API_KEY"Returns 200 OK with a Billing account object.
Update auto-reload
Enable, disable, or reconfigure automatic balance reloads. A
payment method must be on file (has_payment_method: true) before
auto_reload_enabled can be set to true — otherwise the server
returns 422 Unprocessable Entity with
{"detail": "Auto-reload requires a default payment method. Create a setup intent first."}.
curl -X PATCH https://api.thunderphone.com/v1/billing \
-H "Authorization: Token YOUR_SESSION_TOKEN" \
-H "X-ThunderPhone-Org: 42" \
-H "Content-Type: application/json" \
-d '{
"auto_reload_enabled": true,
"auto_reload_minimum_cents": 1000,
"auto_reload_amount_cents": 5000,
"auto_reload_monthly_limit_cents": 50000
}'curl -X PATCH https://api.thunderphone.com/v1/billing \
-H "Authorization: Token YOUR_SESSION_TOKEN" \
-H "X-ThunderPhone-Org: 42" \
-H "Content-Type: application/json" \
-d '{"auto_reload_enabled": false}'| Field | Type | Required when enabling |
|---|---|---|
auto_reload_enabled | boolean | |
auto_reload_minimum_cents | integer ≥ 0 | no — triggers a reload once balance drops below. Defaults to 500 ($5) when the request turns auto-reload on and the account has no saved rule |
auto_reload_amount_cents | integer > 0 | no — amount charged on reload. Defaults to the account's most recent manual top-up, at least 1000 ($10), at most 500000 ($5,000) and at most auto_reload_monthly_limit_cents, when the request turns auto-reload on and the account has no saved rule |
auto_reload_monthly_limit_cents | integer ≥ 0, or null | no — null means unlimited |
charge_now | boolean | no — write-only. Set true once the person has agreed that saving charges the card now: when the balance is already below the saved auto_reload_minimum_cents, the reload runs right after the save and charge_now_result in the response says what it did. Without it, saving charges nothing; the reload runs on the next charge (a call, a phone number) |
An account has no saved rule until a reload amount has been saved. Turning
auto-reload on with only {"auto_reload_enabled": true} then uses the
defaults above; a saved rule is never replaced by them, and a request that
doesn't turn auto-reload on never fills them in. With a monthly limit under
$10 there is no default that fits, and the request returns 400 until the
limit is raised or an amount is sent.
Returns 200 OK with the updated Billing account object,
plus charge_now_result: null unless charge_now was sent, otherwise
{"status", "amount_cents"}, where status is one of:
status | Meaning |
|---|---|
charged | The card was charged and the balance has it |
pending | A charge is on its way and hasn't settled yet, including one already in flight when the save came; the balance updates when it does |
declined | The card (and any backup card) was declined. Nothing was charged. Auto-reload stays switched on, but won't charge until the card is updated or the pause ends |
error | Nothing was charged and no decline was recorded (the charge couldn't be made just now). Auto-reload stays on and tries again after a later charge |
not_charged | Nothing was charged now, for example because the balance was no longer below the minimum |
Top up balance
Create a one-time charge to increase your balance. Uses the default
payment method unless payment_method_id is supplied.
curl -X POST https://api.thunderphone.com/v1/billing/top-up \
-H "Authorization: Token YOUR_SESSION_TOKEN" \
-H "X-ThunderPhone-Org: 42" \
-H "Content-Type: application/json" \
-d '{"amount_cents": 10000}'result = requests.post(
"https://api.thunderphone.com/v1/billing/top-up",
headers={"Authorization": "Token YOUR_SESSION_TOKEN", "X-ThunderPhone-Org": "42"},
json={"amount_cents": 10000},
).json()| Field | Type | Required | Description |
|---|---|---|---|
amount_cents | integer ≥ 1 | yes | USD cents. No server-enforced maximum; the app's Add funds dialog takes 500 to 500000 |
payment_method_id | string | no | Stripe PM id. Defaults to the org's default |
idempotency_key | string (≤ 64) | no | Retrying with the same key returns the same charge instead of charging again. Reusing a key with a different amount_cents returns 409 |
Returns 201 Created:
{
"payment_intent_id": "pi_abc123",
"status": "succeeded",
"client_secret": "pi_abc123_secret_..."
}| Field | Type | Description |
|---|---|---|
payment_intent_id | string | Stripe PaymentIntent id |
status | string | Mirrors Stripe's own PaymentIntent.status — typically succeeded, requires_action, or requires_payment_method |
client_secret | string | Pass to Stripe.js / stripe-react on the client side if status === "requires_action" (3DS) |
When status === "succeeded" the balance is credited synchronously
from the request. When status === "requires_action", complete the
3DS flow client-side and wait for the payment_intent.succeeded
webhook — then poll GET /v1/billing to
observe the credit.
Errors
Validation problems (e.g. a missing or non-positive amount_cents)
return 400 with a standard DRF field-error body:
{ "amount_cents": ["Ensure this value is greater than or equal to 1."] }Payment failures return a structured error body with a
machine-readable code, plus message/detail, a retryable hint,
and a next_action your client can act on:
{
"code": "payment_authentication_required",
"message": "This card requires additional verification. Please retry and complete authentication when prompted.",
"detail": "This card requires additional verification. Please retry and complete authentication when prompted.",
"retryable": true,
"next_action": "authenticate_payment"
}| Status | code | retryable | next_action | Condition |
|---|---|---|---|---|
402 | payment_authentication_required | true | authenticate_payment | 3-D Secure / SCA required — complete authentication client-side with the PaymentIntent's client_secret, then retry |
402 | card_declined | false | update_payment_method | The bank declined the card (all decline reasons are collapsed into this one code) |
422 | billing_request_invalid | false | update_payment_method | Stripe rejected the request (bad parameters, unknown customer) |
503 | billing_provider_unavailable | true | retry_payment | Transient Stripe outage or rate limit; retry shortly |
502 | billing_provider_error | true | retry_payment | Any other unexpected Stripe error |
These same coded errors are returned by the other billing write
endpoints when they hit Stripe (/setup-intent,
/default-payment-method).
Add / save a payment method
Two-step flow: create a SetupIntent, confirm it client-side, then set the resulting payment-method id as the org's default.
1. Create a SetupIntent
curl -X POST https://api.thunderphone.com/v1/billing/setup-intent \
-H "Authorization: Token YOUR_SESSION_TOKEN" \
-H "X-ThunderPhone-Org: 42"{
"setup_intent_id": "seti_abc123",
"client_secret": "seti_abc123_secret_...",
"status": "requires_payment_method"
}2. Confirm client-side with Stripe.js
See the Stripe documentation
for stripe.confirmCardSetup(). On success you receive a
payment_method id.
3. Mark the payment method as default
curl -X POST https://api.thunderphone.com/v1/billing/default-payment-method \
-H "Authorization: Token YOUR_SESSION_TOKEN" \
-H "X-ThunderPhone-Org: 42" \
-H "Content-Type: application/json" \
-d '{"payment_method_id": "pm_abc123"}'Returns 200 OK with the updated Billing account object;
has_payment_method is now true.
To switch the default to a card that is already saved, call this endpoint with that card's id from List saved cards.
List saved cards
Returns every card saved on the organization, the default first and the rest newest first. Top-ups and auto-reloads charge the default card. Requires the admin or owner role.
curl https://api.thunderphone.com/v1/billing/payment-methods \
-H "Authorization: Bearer sk_live_YOUR_API_KEY"{
"payment_methods": [
{
"id": "pm_abc123",
"brand": "visa",
"last4": "4242",
"exp_month": 4,
"exp_year": 2031,
"is_default": true,
"is_backup": false
},
{
"id": "pm_def456",
"brand": "mastercard",
"last4": "4444",
"exp_month": 12,
"exp_year": 2030,
"is_default": false,
"is_backup": true
}
]
}is_backup marks the backup card: when the bank declines the default card
during an auto-reload, that auto-reload charges the backup card once
instead. Manual top-ups never use it. An admin sets the backup on the
app's Billing page (Payment tab). An organization that has never saved a card
gets an empty list.
Remove a saved card
Detaches the card from the organization. This cannot be undone; save the card again to use it later. Requires the admin or owner role.
Removing the default card makes another saved card the default: the backup card if there is one, otherwise the newest. The only card can be removed while auto-reload is off; the organization then has no card until one is saved again.
curl -X DELETE https://api.thunderphone.com/v1/billing/payment-methods/pm_def456 \
-H "Authorization: Token YOUR_SESSION_TOKEN" \
-H "X-ThunderPhone-Org: 42"Returns 204 No Content.
| Status | code | Meaning |
|---|---|---|
404 | — | No saved card with that id on this organization |
409 | auto_reload_needs_card | It is the only card and auto-reload is on. Turn off auto-reload or save another card first |
409 | payment_method_in_use | An auto-reload is charging this card right now. Retry shortly |
List transactions
Returns every ledger entry on the account — top-ups, per-call usage, monthly number fees, and manual adjustments — newest first.
curl 'https://api.thunderphone.com/v1/billing/transactions?limit=200' \
-H "Authorization: Bearer sk_live_YOUR_API_KEY"txns = requests.get(
"https://api.thunderphone.com/v1/billing/transactions",
headers={"Authorization": "Bearer sk_live_YOUR_API_KEY"},
params={"limit": 200},
).json()Query parameters
| Param | Type | Default | Description |
|---|---|---|---|
limit | integer | 200 | 1–1000 |
offset | integer | 0 | |
kind | string | Filter to one transaction kind | |
start_date | ISO 8601 | Filter on created_at | |
end_date | ISO 8601 |
The response is a plain JSON array of transaction objects (no
{results, total} envelope). Page forward by increasing offset
until you receive fewer rows than limit.
Transaction object
{
"id": 3421,
"kind": "call_usage",
"description": "Call usage — metered",
"amount_cents": -18,
"amount_usd": "-0.18",
"call_id": 987654321,
"phone_number_id": 201,
"phone_number_value": "+15551234567",
"metadata": {},
"has_receipt": false,
"is_adjustment": false,
"charge_type": "call_usage",
"agent_id": 42,
"created_at": "2026-04-20T18:25:06.201Z"
}| Field | Type | Description |
|---|---|---|
id | integer | Transaction id |
kind | string | One of manual_topup, auto_reload, call_usage, phone_number_monthly, conversion_report, voice_sample_usage, transfer_bridge, adjustment. Newer charges are reported as adjustment; charge_type says what they are |
charge_type | string | What the transaction is, more specific than kind. A plain string, not an enum: the kind itself, or for a newer charge reported as adjustment one of simulation_caller (a side-by-side test call's simulated caller), caller_reputation (spam-label monitoring), line_type_lookup (a campaign's number type lookups) or own_number_check (checking a number the account owns before calls show it). More values may be added |
description | string | Human-readable summary |
amount_cents | integer | Negative for usage/fees, positive for credits |
amount_usd | string | Formatted signed amount |
call_id | integer | null | Set on call_usage rows |
phone_number_id | integer | null | Set on phone_number_monthly rows |
phone_number_value | string | null | E.164 for the number billed |
metadata | object | Kind-specific details |
has_receipt | boolean | true on card-funded manual_topup and auto_reload credits. Get a receipt for these rows |
payment_method_brand | string | null | Card brand charged for a manual_topup or auto_reload credit, such as visa. null on other rows and on older credits |
payment_method_last4 | string | null | Last four digits of that card |
is_adjustment | boolean | true on a later change to a call's charge (kind call_usage): usage that arrived after the call was billed, such as the call review on the current pricing (a debit), or a call abroad settled at what the phone carrier billed for it (a debit, or a credit with a positive amount_cents) |
agent_id | integer | null | The agent on the call a call charge is for (a call_usage row, a transfer or a later increase). null on every other row and for a call with no agent |
created_at | timestamp |
Get a receipt
Returns a link to the payment receipt for a top-up or automatic top-up,
for rows where has_receipt is true. The receipt is hosted by our
payment processor, Stripe, and shows the amount, date, and card charged.
Owners and admins can fetch it; other members get 403, because the receipt shows the card brand and last four digits.
curl https://api.thunderphone.com/v1/billing/transactions/3398/receipt \
-H "Authorization: Bearer sk_live_YOUR_API_KEY"receipt = requests.get(
"https://api.thunderphone.com/v1/billing/transactions/3398/receipt",
headers={"Authorization": "Bearer sk_live_YOUR_API_KEY"},
).json()
print(receipt["receipt_url"]){
"receipt_url": "https://pay.stripe.com/receipts/payment/..."
}| Status | code | Meaning |
|---|---|---|
404 | — | No transaction with that id on this organization, or the transaction has no receipt |
404 | receipt_unavailable | The payment has no receipt yet. Try again later |
Stripe webhook
ThunderPhone receives Stripe webhooks at
/v1/stripe/webhook internally — you don't interact with this endpoint
directly. It processes payment_intent.succeeded,
payment_intent.payment_failed, and setup_intent.succeeded events to
update balances and mark payment methods ready.