CastBricks Docs

Billing

Check your SMS balance, browse packages, and manage payments

Billing

CastBrick uses a pre-paid credit system. You purchase an SMS pack, and each message sent deducts from your balance. Credits never expire.


Get balance

GET /billing/balance

Returns your current SMS credit balance and low-balance alert settings.

Response 200

{
  "balance": 1850.00,
  "lowBalanceThreshold": 200.00,
  "alertEmail": "admin@yourapp.com",
  "lastAlertSentAt": "2026-05-01T08:00:00Z"
}
FieldDescription
balanceCurrent balance in SMS credits
lowBalanceThresholdAlert is triggered when balance falls below this value
alertEmailEmail that receives low-balance notifications
lastAlertSentAtWhen the last low-balance alert was sent

Code sample

curl https://api.castbrick.co/v1/billing/balance \
  -H "Authorization: Bearer cb_live_xxxxxxxxxxxx"

List packages

GET /billing/packages

Returns the available SMS credit packs. No authentication required.

Response 200

[
  {
    "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "name": "Starter",
    "credits": 500,
    "price": 10.00,
    "currency": "AOA",
    "pricePerSms": 0.020
  },
  {
    "id": "4ab96e75-6828-573d-c4gd-3d3d74h77bfb",
    "name": "Growth",
    "credits": 2000,
    "price": 10.00,
    "currency": "AOA",
    "pricePerSms": 0.005
  },
  {
    "id": "5bc07f86-7939-684e-d5he-4e4e85i88cgc",
    "name": "Scale",
    "credits": 20000,
    "price": 190.00,
    "currency": "AOA",
    "pricePerSms": 0.0095
  }
]

Code sample

curl https://api.castbrick.co/v1/billing/packages

Initiate a payment

POST /billing/payments/initiate

Starts a payment session to purchase an SMS pack. Returns a redirect URL to complete the payment.

Request body

{
  "packageId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "provider": "Stripe",
  "method": "Card",
  "currency": "USD",
  "returnUrl": "https://yourapp.com/billing",
  "cancelUrl": "https://yourapp.com/billing/cancel",
  "successUrl": "https://yourapp.com/billing/success",
  "failureUrl": "https://yourapp.com/billing/failure"
}
FieldTypeRequiredDescription
packageIdUUIDYesID of the package to purchase
providerstringYesPayment provider: Stripe
methodstringYesPayment method: Card
currencystringYesISO 4217 currency code (e.g. USD, AOA)
returnUrlstringYesURL user is redirected to after payment attempt
cancelUrlstringYesURL if user cancels
successUrlstringYesURL after successful payment
failureUrlstringYesURL after failed payment

Response 200

{
  "paymentUrl": "https://checkout.stripe.com/c/pay/cs_live_...",
  "providerRef": "cs_live_a1b2c3d4",
  "paymentId": "pay-uuid"
}

Redirect the user to paymentUrl to complete the purchase.

Code sample

curl -X POST https://api.castbrick.co/v1/billing/payments/initiate \
  -H "Authorization: Bearer cb_live_xxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "packageId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "provider": "Stripe",
    "method": "Card",
    "currency": "USD",
    "returnUrl": "https://yourapp.com/billing",
    "cancelUrl": "https://yourapp.com/billing/cancel",
    "successUrl": "https://yourapp.com/billing/success",
    "failureUrl": "https://yourapp.com/billing/failure"
  }'

List payments

GET /billing/payments

Returns your payment history with optional filters.

Query parameters

ParameterDefaultDescription
cursorPagination cursor from the previous response
limit50Results per page
statusFilter: pending, completed, failed, refunded
fromStart date (ISO 8601)
toEnd date (ISO 8601)

Code sample

curl "https://api.castbrick.co/v1/billing/payments?limit=20&status=completed" \
  -H "Authorization: Bearer cb_live_xxxxxxxxxxxx"

List transactions

GET /billing/transactions

Returns a credit ledger — every debit (message sent) and credit (top-up) on your account.

Query parameters

ParameterDefaultDescription
cursorPagination cursor

Code sample

curl https://api.castbrick.co/v1/billing/transactions \
  -H "Authorization: Bearer cb_live_xxxxxxxxxxxx"

Credit consumption

Each SMS message sent deducts credits from your balance:

ScenarioCredits used
1 SMS (1 segment, 1 recipient)1
1 SMS (2 segments, 1 recipient)2
1 broadcast to 1,000 contacts1,000
1 broadcast to 1,000 contacts, 2 segments2,000

A segment is 160 characters for GSM-7 encoding or 70 characters for UCS-2 (unicode). Messages over one segment are split and billed per segment.