Phonebox / Docs
API reference

Account

Read the project's balance, reservations, monthly spending, limits, phone counts, price and the countries phones can be created in, and create a checkout link for credits.

View as Markdown

The account belongs to the project that the key selects. Pricing and credits explains balances, reservations and the spending limit.

Get the account

GET /v1/account needs the phones:read scope.

It reads the project and touches no phone, so it is a cheap way to check that a key works.

curl https://phonebox.dev/v1/account \
  -H "Authorization: Bearer $PHONEBOX_API_KEY"
Response: account
{
  "project": "Checkout QA",
  "balance_usd": "21.400000",
  "reserved_usd": "7.200000",
  "spend_limit_usd": "100.000000",
  "spent_this_month_usd": "4.120000",
  "limits": { "phones": 10, "running": 2 },
  "running": 1,
  "phones": 3,
  "price": { "per_minute_usd": "0.060000", "minimum_seconds": 60 },
  "countries": [
    { "code": "AR", "name": "Argentina" },
    { "code": "AU", "name": "Australia" },
    { "code": "US", "name": "United States" }
  ]
}
FieldTypeMeaning
projectstringThe project's name.
balance_usdmoneyYour credit, before reservations.
reserved_usdmoneyThe credit held by open sessions. What you can spend on a new session is balance_usd minus reserved_usd.
spend_limit_usdmoneyThe monthly spending limit.
spent_this_month_usdmoneyWhat sessions that ended this calendar month, in UTC, were charged.
limits.phonesintegerThe most phones the project can have, not counting deleted or failed ones.
limits.runningintegerThe most phones the project can run at once. The limit counts all of your projects together.
runningintegerPhones with an open session: creating, starting or ready.
phonesintegerPhones that count toward the phone limit: every phone that isn't deleted or failed.
price.per_minute_usdmoneyThe price of a phone-minute.
price.minimum_secondsintegerThe shortest time a session is billed for.
countriesarrayThe countries a phone can be created in, as {code, name}, sorted by name. Pass a code as country when you create a phone. The example shows three of them. A country is where the phone appears to be.

The balance, reservations, spending, limits and price are always the project's. For a key limited to certain phones, running and phones count only the phones that key may use.

This endpoint returns no errors of its own. The common errors apply.

POST /v1/credits/checkout needs the phones:control scope.

Creates a checkout page where a person buys credits for the key's project. It is the same purchase as on the console's Billing page, so an agent or a terminal can ask for credit without sending anyone to the console. The body is optional.

FieldTypeDefaultRules
amount_usdinteger10The credit to buy, in whole US dollars, from 10 to 1000.
POST /v1/credits/checkout
{
  "amount_usd": 25
}
curl https://phonebox.dev/v1/credits/checkout \
  -H "Authorization: Bearer $PHONEBOX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"amount_usd": 25}'

It answers 201 Created:

Response: checkout
{
  "url": "https://checkout.example.com/c/9f2b7c1e",
  "amount_usd": 25
}
FieldTypeMeaning
urlstringThe checkout page, on our payment provider's site. Give it to a person, who pays there. Tax is added at checkout, and a discount code can be entered.
amount_usdintegerThe credit the purchase adds, before tax and any discount.

Nothing is charged until the person pays. The credit is added when the payment is confirmed, not when the page closes, so poll the account until balance_usd shows it. A link that nobody pays costs nothing.

ErrorWhen
400 validation_failedamount_usd isn't a whole number from 10 to 1000, or the body has another field.
403 insufficient_scopeThe key is Read-only.
429 rate_limitedThe project created 10 checkout links within the hour. Retry-After says when the next one can be created.
503 billing_not_configuredPayments aren't connected on this deployment.

The common errors apply too.

On this page