Admin Credits — Python SDK
Read and adjust an end-customer's credit balance.
Overview
The admin Credits resource reads a customer's credit/billing balance and adjusts the customer's manually-granted (adjustable) credit amount.
Accessed via admin.credits.
Available Operations
| Method | Description |
|---|---|
get_credit() | Read a customer's credit balance summary |
set_credit() | Adjust a customer's adjustable credit amount |
get_credit
Read a customer's credit/billing balance.
Example Usage
balance = admin.credits.get_credit(user_id=42)
print(balance)
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| user_id | int | Yes | -- | Target customer id (positional argument) |
Response
Returns a dict with the customer's balance fields. Note that several backend field names are spelled ...Amout (rechargeAmout, refundAmout, usedAmout, otherAmout) and are returned exactly as the server sends them.
Errors
| Code | Exception | When |
|---|---|---|
2007 | PermissionError | Admin lacks Credit Management permission |
3001 | AuthenticationError | Session expired and refresh failed |
set_credit
Adjust a customer's adjustable credit amount.
Example Usage
ok = admin.credits.set_credit(user_id=42, amount=100)
print(ok) # True
# Reset back to zero
admin.credits.set_credit(user_id=42, amount=0)
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| user_id | int | Yes | -- | Target customer id (positional argument) |
| amount | number | Yes | -- | Adjustable credit amount to set (positional argument) |
Response
Returns bool — True on success. On the wire the amount is sent under the backend's otherAmout field name.
Errors
| Code | Exception | When |
|---|---|---|
1001 | ValidationError | Invalid user_id or amount |
2007 | PermissionError | Admin lacks Credit Management permission |
3001 | AuthenticationError | Session expired and refresh failed |