LOCALHOST
All pages
API reference

Billing

Wallet, invoices, transactions, what renews and what the account may have.

Every call needs Authorization: Bearer lh_… unless marked No key needed; the example uses $API for https://api.localhost.co.zw and $LH_API_KEY for your key. A * marks a required field.

#

Account Entitlements

billing:read

GET /billing/entitlements

What the account may have from what it pays for (null: no limit), and what it has now.

Responses

  • 200 EntitlementsOut
  • 401 no key, or a key that was revoked
  • 403 the key lacks the permission
Example request
curl -X GET "$API/billing/entitlements" \
  -H "Authorization: Bearer $LH_API_KEY"
#

Invoices

Any key

GET /billing/invoices

Responses

  • 200 list[InvoiceOut]
  • 401 no key, or a key that was revoked
Example request
curl -X GET "$API/billing/invoices" \
  -H "Authorization: Bearer $LH_API_KEY"
#

Subscriptions

billing:read

GET /billing/subscriptions

Everything that renews from the wallet.

Responses

  • 200 list[SubscriptionOut]
  • 401 no key, or a key that was revoked
  • 403 the key lacks the permission
Example request
curl -X GET "$API/billing/subscriptions" \
  -H "Authorization: Bearer $LH_API_KEY"
#

Transactions

billing:read

GET /billing/transactions

Wallet movements, newest first (up to 500).

Parameters

NameTypeNotes
limit query integer default 100

Responses

  • 200 list[TransactionOut]
  • 401 no key, or a key that was revoked
  • 403 the key lacks the permission
Example request
curl -X GET "$API/billing/transactions" \
  -H "Authorization: Bearer $LH_API_KEY"
#

Wallet

Any key

GET /billing/wallet

Responses

  • 200 WalletOut
  • 401 no key, or a key that was revoked
Example request
curl -X GET "$API/billing/wallet" \
  -H "Authorization: Bearer $LH_API_KEY"
#

Invoice

billing:read

GET /billing/invoices/{number}

Parameters

NameTypeNotes
number * in path string

Responses

  • 200 InvoiceOut
  • 401 no key, or a key that was revoked
  • 403 the key lacks the permission
Example request
curl -X GET "$API/billing/invoices/<number>" \
  -H "Authorization: Bearer $LH_API_KEY"
#

Subscription Auto Renew

billing:write

POST /billing/subscriptions/{pk}/auto-renew

Renew by itself from the wallet, or not. Turning it on also undoes a cancel.

Parameters

NameTypeNotes
pk * in path integer

Request body AutoRenewIn

NameTypeNotes
on * boolean

Responses

  • 200 SubscriptionOut
  • 401 no key, or a key that was revoked
  • 403 the key lacks the permission
Example request
curl -X POST "$API/billing/subscriptions/<pk>/auto-renew" \
  -H "Authorization: Bearer $LH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "on": true
  }'
#

Subscription Cancel

billing:write

POST /billing/subscriptions/{pk}/cancel

Stop it renewing: it keeps working until renews_at, then it is paused. Undo with auto-renew on.

Parameters

NameTypeNotes
pk * in path integer

Responses

  • 200 SubscriptionOut
  • 401 no key, or a key that was revoked
  • 403 the key lacks the permission
Example request
curl -X POST "$API/billing/subscriptions/<pk>/cancel" \
  -H "Authorization: Bearer $LH_API_KEY"
#

Subscription Level

billing:write

POST /billing/subscriptions/{pk}/level

Move a package to another level now. The difference for the rest of the paid period is charged (or credited back
when it is cheaper); the renewal date stays.

Parameters

NameTypeNotes
pk * in path integer

Request body LevelIn

NameTypeNotes
level * string

Responses

  • 200 ChangeOut
  • 401 no key, or a key that was revoked
  • 403 the key lacks the permission
Example request
curl -X POST "$API/billing/subscriptions/<pk>/level" \
  -H "Authorization: Bearer $LH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "level": "<level>"
  }'
#

Subscription Pay

billing:write

POST /billing/subscriptions/{pk}/pay

Pay a missed or paused renewal from the wallet now; anything paused comes back. 402 when the wallet is short.

Parameters

NameTypeNotes
pk * in path integer

Responses

  • 200 SubscriptionOut
  • 401 no key, or a key that was revoked
  • 403 the key lacks the permission
Example request
curl -X POST "$API/billing/subscriptions/<pk>/pay" \
  -H "Authorization: Bearer $LH_API_KEY"

Shapes

The objects these endpoints send and receive.

AutoRenewIn

NameTypeNotes
on * boolean

ChangeOut

NameTypeNotes
subscription * SubscriptionOut
charged * string

EntitlementsOut

NameTypeNotes
allowed * object
used * object

InvoiceOut

NameTypeNotes
number * string
status * string
currency * string
total * string
issued_at * string | null
paid_at * string | null
lines * list[object]

LevelIn

NameTypeNotes
level * string

SubscriptionOut

NameTypeNotes
id * integer
kind * string
label * string
price * string
period * string
renews_at * string
auto_renew * boolean
status * string
grace_until * string | null
paused_at * string | null
delete_after * string | null

TransactionOut

NameTypeNotes
kind * string
amount * string
description * string
balance_after * string | null
reference * string
created_at * string

WalletOut

NameTypeNotes
balance * string
currency * string
auto_renew * boolean