Billing reference
Every Billing endpoint with parameters, request and response fields, required scope and a curl example.
Every Billing endpoint. Base URL https://api.pingx.ai; send Authorization: Bearer <API key>. Read endpoints need billing:read (or :write), write endpoints need billing:write; the bare billing scope grants both. See Authentication and conventions. Machine-readable: openapi.json.
4 endpoints
| Method | Path | Operation | Scope |
|---|---|---|---|
GET | /billing/v1/account | GetBilling | read |
GET | /billing/v1/credit-changes | ListCreditChanges | read |
GET | /billing/v1/usage/events | ListUsage | read |
GET | /billing/v1/usage/summary | GetUsageSummary | read |
#GET /billing/v1/account
GetBilling · needs billing:read (or write)
Returns the organization's billing mode and wallet balance. When billing has not been set up for the organization, configured = false and the other fields are their zero values. Read-only and idempotent.
Response GetBillingResponse
| Field | Type | Description |
|---|---|---|
configured | boolean | False when billing is not set up for this organization; the remaining fields are then zero values. |
mode | enum | The billing mode. One of: MODE_UNSPECIFIED, MODE_PREPAID, MODE_POSTPAID, MODE_LIMITED_POSTPAID. |
balanceMillicredits | string (int64) | Current wallet balance in millicredits (1 credit = 1000). May be negative for postpaid modes. |
negativeCreditLimitMillicredits | string (int64) | For MODE_LIMITED_POSTPAID: how far below zero the balance may go, as a positive number of millicredits. 0 for other modes. |
curl "https://api.pingx.ai/billing/v1/account" \
-H "Authorization: Bearer $PINGX_API_KEY"#GET /billing/v1/credit-changes
ListCreditChanges · needs billing:read (or write)
Lists the credit changes recorded on the wallet by PingX (credits added and credits removed), newest first, each with the balance after the change. Does not include usage charges (see ListUsage). Read-only.
Query parameters
| Name | Type | Description |
|---|---|---|
pageSize | integer | Maximum changes per page. <= 0 means 25; maximum 100. |
pageToken | string | Opaque token from a previous response's nextPageToken; empty for the newest page. An invalid token is INVALID_ARGUMENT. |
Response ListCreditChangesResponse
| Field | Type | Description |
|---|---|---|
creditChanges | CreditChange[] | Credit changes, newest first. |
creditChanges[].id | string (int64) | Monotonic id; newer changes have larger ids. |
creditChanges[].kind | enum | Whether credits were added or removed. One of: CREDIT_CHANGE_KIND_UNSPECIFIED, CREDIT_CHANGE_KIND_CREDIT, CREDIT_CHANGE_KIND_DEBIT. |
creditChanges[].amountMillicredits | string (int64) | Size of the change in millicredits (always positive; see kind for the direction). |
creditChanges[].balanceAfterMillicredits | string (int64) | Wallet balance right after this change, in millicredits. |
creditChanges[].description | string | The note PingX recorded with the change. |
creditChanges[].createdAt | string | When the change was made (RFC 3339). |
nextPageToken | string | Token for the next (older) page; empty when there are no more. |
curl "https://api.pingx.ai/billing/v1/credit-changes" \
-H "Authorization: Bearer $PINGX_API_KEY"#GET /billing/v1/usage/events
ListUsage · needs billing:read (or write)
Lists individual usage events — charges, refunds and refused (denied) attempts — newest first, optionally filtered to one operation. Metering that did not charge anything is not included. Same availability errors as GetUsageSummary. Read-only.
Query parameters
| Name | Type | Description |
|---|---|---|
operation | string | Only events of this operation key (see OperationUsage.operation); empty means every operation. |
pageSize | integer | Maximum events per page. <= 0 means 25; maximum 100. |
pageToken | string | Opaque token from a previous response's nextPageToken; empty for the newest page. An invalid token is INVALID_ARGUMENT. |
Response ListUsageResponse
| Field | Type | Description |
|---|---|---|
events | UsageEvent[] | Usage events, newest first. |
events[].id | string (int64) | Monotonic id; newer events have larger ids. |
events[].operation | string | Operation key, e.g. "whatsapp.message". |
events[].name | string | Display name of the operation. |
events[].unit | string | Unit of quantity. |
events[].details | object | Operation-specific details, e.g. country and message category. |
events[].quantity | string (int64) | Quantity in the operation's unit. |
events[].amountMillicredits | string (int64) | Credits involved in millicredits. |
events[].outcome | enum | Whether it was charged, refunded or denied. One of: USAGE_OUTCOME_UNSPECIFIED, USAGE_OUTCOME_CHARGED, USAGE_OUTCOME_REFUNDED, USAGE_OUTCOME_DENIED. |
events[].createdAt | string | When it happened (RFC 3339). |
nextPageToken | string | Token for the next (older) page; empty when there are no more. |
curl "https://api.pingx.ai/billing/v1/usage/events" \
-H "Authorization: Bearer $PINGX_API_KEY"#GET /billing/v1/usage/summary
GetUsageSummary · needs billing:read (or write)
Returns credits used over the last N days broken down by operation (for example "WhatsApp message", voice minutes), with totals and the number of refused attempts. FAILED_PRECONDITION when usage reporting is not available for the deployment; UNAVAILABLE when it is temporarily down (retry). Read-only and idempotent.
Query parameters
| Name | Type | Description |
|---|---|---|
days | integer | Lookback window in days ending now. <= 0 means 30; maximum 366. |
Response GetUsageSummaryResponse
| Field | Type | Description |
|---|---|---|
operations | OperationUsage[] | Usage per operation. |
operations[].operation | string | Stable operation key, e.g. "whatsapp.message". Use it as the filter in ListUsage. |
operations[].name | string | Display name, e.g. "WhatsApp message". |
operations[].unit | string | Unit of quantity, e.g. "message" or "minute". |
operations[].operations | string (int64) | Number of charged operations in the window. |
operations[].quantity | string (int64) | Total quantity in the operation's unit. |
operations[].amountMillicredits | string (int64) | Credits charged in the window, in millicredits. |
operations[].denied | string (int64) | Attempts that were refused (for example for lack of credits); nothing was sent or charged for them. |
totalMillicredits | string (int64) | Total credits charged across all operations, in millicredits. |
days | integer | The effective lookback window in days after defaulting/clamping. |
curl "https://api.pingx.ai/billing/v1/usage/summary" \
-H "Authorization: Bearer $PINGX_API_KEY"