Skip to content

Billing API

Your invoices, the card on file, and paying an invoice now. These work even while streaming is paused for an unpaid bill, so the bill can always be paid.

This page is generated from the OpenAPI specification; the same text is inMarkdown for tools and AI assistants.

Read your billing

GET/v1/billing

Your last invoices, the card on file and your account credit. Works while streaming is paused for an unpaid bill.

Response 200

Billing.

Fields
NameTypeDescription
billed_by_cardrequiredboolean

False when your organization is invoiced by agreement.

invoicesrequiredarray of object
invoices[].idrequiredstring (uuid)
invoices[].periodrequiredstring

YYYY-MM, the month billed.

invoices[].statusrequiredstring

One of "open", "paid", "failed", "carried".

invoices[].usage_centsrequiredinteger
invoices[].platform_fee_centsrequiredinteger
invoices[].carried_in_centsrequiredinteger
invoices[].total_centsrequiredinteger
invoices[].credit_centsrequiredinteger
invoices[].charged_centsrequiredinteger
invoices[].refunded_centsrequiredinteger
invoices[].line_itemsrequiredarray of object
invoices[].line_items[].productrequiredstring

One of "stream", "restream", "captions", "translation".

invoices[].line_items[].tierrequiredstring
invoices[].line_items[].minutesrequiredinteger
invoices[].line_items[].centsrequiredinteger
invoices[].attemptsrequiredinteger
invoices[].next_attempt_atrequiredstring (date-time) or null
invoices[].last_error_classrequiredstring or null

Why the last charge failed. Treat a value not listed here as gateway_error.

One of "card_expired", "insufficient_funds", "card_invalid", "card_declined", "no_payment_method", "gateway_timeout", "gateway_error".

invoices[].last_error_messagerequiredstring or null

The same reason in plain words, with what to do about it, fit to show a person.

invoices[].processor_transaction_idrequiredstring or null
invoices[].paid_atrequiredstring (date-time) or null
invoices[].created_atrequiredstring (date-time)
credit_balance_centsrequiredinteger
streaming_pausedrequiredboolean

A bill is unpaid after its seven days: no stream can be booked or started until it is paid.

cardobject
card.brandrequiredstring or null
card.last4requiredstring or null
card.exp_monthrequiredinteger or null
card.exp_yearrequiredinteger or null
card.has_backuprequiredboolean
billing_emailstring or null
platform_fee_centsinteger
processor_customer_idstring or null

Your customer record at the payment processor, set by your first card. Tokenize any later card onto this record (pass it as customer_id to the card form); a card stored on another record is refused.

Errors

StatusCodeMeaning
503billing_unavailable

Billing is not available on this deployment.

Terminal window
curl "https://api.cardinalstreaming.com/v1/billing" \
-H "Authorization: Bearer $CARDINAL_API_KEY"

Read the bill so far

GET/v1/billing/upcoming

This month’s invoice as it stands: usage so far priced as the invoice will price it, the platform fee, anything carried, the credit drawn first, the estimated charge and its date, and what is still owed on earlier invoices.

Response 200

The bill so far.

Fields
NameTypeDescription
periodrequiredstring

The current month, YYYY-MM.

billed_by_cardrequiredboolean
linesrequiredarray of object
lines[].productrequiredstring

One of "stream", "restream", "captions", "translation".

lines[].tierrequiredstring

One of "standard_1080p", "pro_4k".

lines[].minutesrequiredinteger

Billed minutes.

lines[].centsrequiredinteger

The amount in whole cents, exactly as invoiced.

usage_centsrequiredinteger
platform_fee_centsrequiredinteger
carried_centsrequiredinteger
credits_applied_centsrequiredinteger
estimated_total_centsrequiredinteger
charge_onrequiredstring (date)
outstanding_centsrequiredinteger
outstanding_invoicesrequiredinteger
card_last4requiredstring or null
streaming_pausedrequiredboolean

A bill is unpaid after its seven days: no stream can be booked or started until it is paid.

Errors

StatusCodeMeaning
503billing_unavailable

Billing is not available on this deployment.

Terminal window
curl "https://api.cardinalstreaming.com/v1/billing/upcoming" \
-H "Authorization: Bearer $CARDINAL_API_KEY"

Put a card on file

PUT/v1/billing/card

Sets the card streaming is billed to (or the backup card, tried when the main one is declined). A card number never reaches this API: the console collects it in the browser straight to the payment processor, which returns the payment_method_id you send here.

Request body

NameTypeDescription
payment_method_idrequiredstring
backupboolean

Set the backup card instead of the main one.

Response 204

The card is on file.

Errors

StatusCodeMeaning
400invalid_body

The body is not JSON.

400invalid_request

The payment method is missing, unknown, removed, not a card, or another customer’s; or it is the organization’s first card and was not stored in the last hour.

503billing_unavailable

Billing is not available on this deployment.

Terminal window
curl -X PUT "https://api.cardinalstreaming.com/v1/billing/card" \
-H "Authorization: Bearer $CARDINAL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"payment_method_id": "pm_8f3c2a91d0",
"backup": false
}'

Pay an invoice now

POST/v1/billing/invoices/{invoice_id}/pay

Charges an unpaid invoice now, after any account credit. Paying the bill that paused streaming resumes it at once. A declined card is 402 payment_failed and changes nothing else.

Path parameters

NameTypeDescription
invoice_idrequiredstring (uuid)

The invoice’s id.

Response 200

Paid, or settled by credit, or carried into next month because what remained was under $0.50.

Fields
NameTypeDescription
statusrequiredstring

One of "succeeded", "settled_without_charge", "carried", "failed".

error_classstring
messagestring
suspendedrequiredboolean

Whether this attempt paused streaming. A payment never does.

charged_centsrequiredinteger
credited_centsrequiredinteger

Errors

StatusCodeMeaning
402payment_failed

The card was not charged; error_class says why and detail says what to do, in words fit to show a person.

404not_found

No such invoice in your organization.

409not_payable

The invoice is not owed.

503billing_unavailable

Billing is not available on this deployment.

Terminal window
curl -X POST "https://api.cardinalstreaming.com/v1/billing/invoices/0d6f2b1c-3e4a-4b8f-9c11-5a7d2e9f8b10/pay" \
-H "Authorization: Bearer $CARDINAL_API_KEY"
Response 200
{
"status": "succeeded",
"charged_cents": 2750,
"credited_cents": 1500,
"suspended": false
}