Check Balance
You can check a customer’s wallet balance at any time via the Customer Wallet API. A customer wallet may contain multiple accounts of different currencies or assets.
In this guide we’ve placed this step last to show how the balance updates after usage events are sent. In practice, you'll typically want to check the balance before allowing the customer to perform the billable action.
Overdrafts are enabled on wallet accounts by default, ensuring that usage can be billed in full. We recommend that you check balances according to your own business logic and overdraft tolerance.
Get Wallet Example
curl -L 'https://api.credyt.ai/customers/:customerId/wallet' \
-H 'Accept: application/json' \
-H 'X-CREDYT-API-KEY: <CREDYT-API-KEY>'
Response
After submitting a few video_promoted events in the previous section we can see our balance has been reduced accordingly.
{
"accounts": [
{
"id": "default:USD",
"name": "default",
"asset": "USD",
"available": 998.5
}
]
}
Get Account Example
If you know the address of the account you wish to check, you can use the Wallet Account API. Typically this will be in the format default:{currency}.
curl -L 'https://api.credyt.ai/customers/:customerId/wallet/default:USD' \
-H 'Accept: application/json' \
-H 'X-CREDYT-API-KEY: <CREDYT-API-KEY>'
Response
{
"id": "default:USD",
"name": "default",
"asset": "USD",
"available": 998.5,
"pending_in": 0,
"pending_out": 0
}