Balance Query API
The Balance Query API retrieves the available balance of an account and its API Keys, supporting enterprise operations monitoring, per-key troubleshooting, and self-service for individual developers. The Base URL is https://tokenplus.net.
There are 3 balance endpoints, distinguished by the credential used to determine the permission scope:
| Endpoint | Credential | Capability | Rate limit |
|---|---|---|---|
GET /v1/balance | Management Key | Query the account balance and balances of all Regular Keys | 60 requests/min |
GET /v1/keys/{key_id}/balance | Management Key | Query balance details for a specified Regular Key under the same account | 60 requests/min |
GET /v1/me/balance | Regular Key | Query the owning account balance and the current Key's balance info | 120 requests/min |
Permission boundaries:
- A Management Key can only call the first two endpoints and cannot call
/v1/me/balance. - A Regular Key can only call
/v1/me/balanceand cannot call the Management balance endpoints. /v1/balanceonly returns Regular Keys and does not support querying or enumerating Management Keys.- When a specified Key does not exist, has been deleted, or belongs to another account, the unified response is
404 key_not_found.
General Request Conventions
| Item | Convention |
|---|---|
| Base URL | https://tokenplus.net |
| Request method | GET |
| Auth header | Authorization: Bearer {api-key} |
| Response type | Content-Type: application/json |
| Time format | RFC 3339 UTC, e.g. 2026-08-06T08:00:00Z |
Money and Null Value Semantics
- All amounts are denominated in USD and returned at the top level as
currency: "USD". - All amounts and percentages are decimal strings, e.g.
"850","85.5","42.75". nullmeans the field does not apply, is unlimited, or a trustworthy value is currently unavailable; the exact meaning follows the field description.- Callers must not automatically convert
nullto0.
Snapshot and Cache
- Every successful response contains
as_of, representing the time of the committed data snapshot. - When queries and consumption run concurrently, there is no guarantee that the balance will not continue to change after the response.
- All success and error responses must include
Cache-Control: private, no-store.
Field Definitions
- Top-level and Account
- Key Fields
- Consumption Details
| Field | Type | Nullable | Description |
|---|---|---|---|
object | string | No | balance, key_balance, or self_balance |
currency | string | No | Always USD |
as_of | string | No | Response data snapshot time, RFC 3339 UTC |
account.total_balance | decimal string | No | Account's current online spendable wallet balance; negative values are displayed as "0" |
account.total_consumed | decimal string | No | Account cumulative consumption; returned only by the Management list endpoint |
account.paid_balance | null | Yes | Not available this period; always returns null |
account.free_balance | null | Yes | Not available this period; always returns null |
account.paid_consumed | null | Yes | Not available this period; appears only in the Management list endpoint |
account.free_consumed | null | Yes | Not available this period; appears only in the Management list endpoint |
account.breakdown_status | string | No | Always unavailable this period |
total_balance is the online spendable balance and is not the same as a refundable balance. Customer support or finance must not calculate refund amounts based solely on this endpoint.
| Field | Type | Nullable | Description |
|---|---|---|---|
id | string | No | Regular Key public ID, not the database internal ID |
name | string | No | Key name |
key_type | string | No | Always regular |
disabled | boolean | No | Whether the current projection state cannot be used for inference |
manually_disabled | boolean | No | Whether the user manually disabled it, used to preserve user intent |
limit | decimal string | Yes | Key limit amount; null for unlimited keys |
limit_reset | string | No | daily, weekly, monthly, or never |
quota_scope | string | Yes | usage, subscription, all, or null, indicating the funding source the limit constraint applies to |
period | object | Yes | Current rolling period; null for never or when there is no period |
consumed_this_period | decimal string | Yes | Current period consumption; null when the data cannot be reliably determined |
consumed_today | decimal string | Yes | Today's consumption; null when logs are incomplete |
key_limit_remaining | decimal string | Yes | Remaining independent Key limit; null for unlimited keys |
remaining | decimal string | Yes | Compatible field for key_limit_remaining; semantics and value are identical |
effective_remaining | decimal string | Yes | Actual currently available quota after combining the account wallet and the Key limit |
usage_pct | decimal string | Yes | Key limit usage percentage, range 0 to 100; null for unlimited keys |
status | string | No | active or disabled |
status_reason | string | Yes | null when active; returns the specific reason when disabled |
Possible status_reason values and their priority:
user_disabled: the account is disabled;pending_subscription: the subscription key is waiting for the subscription to take effect;expired: the key has expired;limit_exhausted: the key limit has been exhausted;manual: the key was manually disabled by the user;- The active state does not return an
activestring; it isnullexternally.
consumed is returned only by single-Key Management queries.
| Field | Type | Nullable | Description |
|---|---|---|---|
consumed.all_time | decimal string | No | Key historical cumulative consumption |
consumed.this_period | decimal string | Yes | Current period consumption |
consumed.today | decimal string | Yes | Today's consumption |
consumed.by_model | array | Yes | Consumption split by model within the currently verifiable scope |
consumed.complete | boolean | No | Whether the consumption logs fully cover this result |
consumed.retention_start | string | Yes | Earliest retention time of the currently available logs |
When logs are unavailable, retention is insufficient, or the query snapshot has changed:
todayandby_modelreturnnull;complete=false;- Must not return
0or an empty array to imply "confirmed no consumption".
Balance and Period Calculation Rules
Account Balance
total_balancereads only the account's online authoritative balance.- When the account balance is negative, it is displayed as
"0"externally with an anomaly logged; a negative available balance is not returned.
Key Balance
| Key situation | key_limit_remaining | effective_remaining |
|---|---|---|
| Has an independent limit | Remaining key limit, minimum "0" | The amount actually usable between the wallet balance and the remaining key limit |
| Unlimited key | null | Constrained by the account balance or the corresponding funding source |
| Disabled, expired, or exhausted | Still returned according to the limit state | Still returns the actual quota projection at query time; the query endpoint itself returns 200 |
Period
daily,weekly, andmonthlyform a rolling period based on the time the key was saved, not split by natural day, week, or month.- Periods are uniformly expressed as
[start, end_exclusive). period.endandperiod.days_remainingare not provided to avoid boundary ambiguity and client timezone differences.- When
limit_reset=neveror there is no period policy,period=null.
Error Responses
- Error Format
- Main Error Codes
Fixed format:
{
"error": {
"code": "key_not_found",
"message": "API key not found.",
"param": "key_id",
"request_id": "req_..."
}
}
Clients must branch on the HTTP status code and error.code, and must not match on the message text.
| HTTP | Error code | Applicable scenario |
|---|---|---|
| 400 | invalid_parameter | Page number, page size, status, or other parameters are invalid |
| 400 | unsupported_key_type | /v1/balance requested with key_type=management |
| 401 | invalid_management_key | A Management Key is missing, forged, invalid, disabled, or deleted on a Management endpoint |
| 401 | invalid_api_key | A Regular Key is missing, forged, invalid, or deleted on a self-service endpoint |
| 403 | forbidden_scope | A valid Regular Key calls a Management endpoint, or a Management Key calls a self-service endpoint |
| 403 | account_disabled | The account of the self-service query has been disabled |
| 404 | key_not_found | The specified key does not exist, has been deleted, or does not belong to the current account |
| 422 | usage_query_too_large | The usage aggregated by model exceeds the system protection scope |
| 429 | rate_limit_exceeded | The balance query endpoint itself triggers rate limiting |
| 500 | internal_error | The service temporarily cannot complete the query; includes when Redis rate limiting is enabled but Redis is unavailable |
| 504 | usage_query_timeout | The usage query timed out |
Key limit exhaustion is not a balance query error and does not return 429.
Rate Limit, Security, and Privacy
- Two Management endpoints: 60 requests/min each per Management Key, user, and source IP.
- Regular self-service endpoint: 120 requests/min per Regular Key, user, and source IP.
- Exceeding any dimension returns
429 rate_limit_exceeded.
Security and privacy:
- Does not return Regular Key plaintext, key hash, full preview, or internal auto-increment ID.
- Does not return or enumerate Management Keys.
- Cross-account keys and non-existent keys use the same 404 to prevent resource probing.
- All success and error responses prohibit storage by browsers or intermediate proxies.