Customers
A customer belongs to one business and pays the bills. Create one with just an email, or with everything tax and invoicing will need:
curl -X POST $TMBILLING_URL/v1/businesses/$BIZ/customers \
-H "Authorization: Bearer $TMBILLING_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"email": "[email protected]",
"first_name": "Maya",
"last_name": "Castillo",
"company": "Brightwater Analytics",
"currency": "USD",
"address": {
"line1": "12 Dean Street",
"city": "London",
"postal_code": "W1D 3RR",
"country": "GB"
}
}'
Set the currency carefully
currency fixes what you bill this customer in, and therefore which prices you can put them on.
Subscribe a USD customer to a EUR price and tmbilling refuses the request rather than converting
it. See Money and currency.
Fill in the address before the first invoice
address.country and its state or province set the place of supply, which decides what tax
applies. vat_number, tax_exempt and withholding_rate_bps change the calculation outright.
Set them before you raise an invoice. tmbilling snapshots them onto each invoice, so correcting an address later does not re-tax a document it already issued. See Tax.
/v1/businesses/{biz}/customers/{cus}/validate_vatValidates the stored VAT number rather than trusting what someone typed.
Add contacts
The customer record holds the primary billing identity. Add contacts for the other people who should receive billing email — an accounts-payable address, a technical owner.
/v1/businesses/{biz}/customers/{cus}/contactsAttach payment methods
Card details never reach tmbilling. The gateway vaults the instrument and returns a token, and tmbilling stores that token with the non-secret descriptors — brand, last four, expiry. Your deployment stays out of PCI scope.
Each payment method carries a status that an expiry sweep keeps current — valid, expiring,
expired, invalid or pending_verification — and a role:
| Role | When tmbilling charges it |
|---|---|
primary | First, for every automatic collection. |
backup | When the primary declines for any reason, within the same collection attempt rather than on the next retry: newest first, at most three instruments per run. A customer with a backup card survives an expired primary without entering dunning. |
none | Never, for automatic collection. The card stays on file. |
A customer has one primary. Every other card is a backup unless set to none, and a newly vaulted
card starts as a backup. Making a card primary moves the previous primary to backup. You cannot demote the primary itself (409), so make another card primary instead.
/v1/businesses/{biz}/customers/{cus}/payment_methods/{pm}/assign_role/v1/businesses/{biz}/customers/{cus}/payment_methodsTo collect a card without your API key reaching your buyer's browser, create a hosted checkout or customer portal session. See Hosted checkout and portal.
Read their balances
Each customer holds three separate balances per currency, not one number. tmbilling spends them in a fixed order, and only some of them are refundable.
/v1/businesses/{biz}/customers/{cus}/walletSee Credits and the ledger for what each balance means.
Run customer operations
| Call | What it does |
|---|---|
POST /customers/{cus}/collect_payment | Charges the customer and pays down their open invoices, booking anything left over as excess credit. |
POST /customers/{cus}/change_billing_date | Moves this customer's calendar billing date, so you can align all their subscriptions on one invoice day. |
POST /customers/{cus}/clear_personal_data | Redacts personal data for a GDPR erasure request while leaving the invoices and ledger entries intact. |
Archive a customer
DELETE archives a customer rather than deleting them. Their record, invoices and ledger entries
remain, because tmbilling never deletes money that moved. Archiving stops new activity. It does not rewrite history.
Related
Catalog
Build your catalog from product groups, products and prices, select from eight pricing models, and give an add-on a different price on each plan.
Subscriptions
Follow a subscription through its statuses and terms, select one of the two endpoints that change items, and estimate every money-moving call before you run it.