pingx.aiAPI docs Markdown

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

MethodPathOperationScope
GET/billing/v1/accountGetBillingread
GET/billing/v1/credit-changesListCreditChangesread
GET/billing/v1/usage/eventsListUsageread
GET/billing/v1/usage/summaryGetUsageSummaryread

#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

FieldTypeDescription
configuredbooleanFalse when billing is not set up for this organization; the remaining fields are then zero values.
modeenumThe billing mode. One of: MODE_UNSPECIFIED, MODE_PREPAID, MODE_POSTPAID, MODE_LIMITED_POSTPAID.
balanceMillicreditsstring (int64)Current wallet balance in millicredits (1 credit = 1000). May be negative for postpaid modes.
negativeCreditLimitMillicreditsstring (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

NameTypeDescription
pageSizeintegerMaximum changes per page. <= 0 means 25; maximum 100.
pageTokenstringOpaque token from a previous response's nextPageToken; empty for the newest page. An invalid token is INVALID_ARGUMENT.

Response ListCreditChangesResponse

FieldTypeDescription
creditChangesCreditChange[]Credit changes, newest first.
creditChanges[].idstring (int64)Monotonic id; newer changes have larger ids.
creditChanges[].kindenumWhether credits were added or removed. One of: CREDIT_CHANGE_KIND_UNSPECIFIED, CREDIT_CHANGE_KIND_CREDIT, CREDIT_CHANGE_KIND_DEBIT.
creditChanges[].amountMillicreditsstring (int64)Size of the change in millicredits (always positive; see kind for the direction).
creditChanges[].balanceAfterMillicreditsstring (int64)Wallet balance right after this change, in millicredits.
creditChanges[].descriptionstringThe note PingX recorded with the change.
creditChanges[].createdAtstringWhen the change was made (RFC 3339).
nextPageTokenstringToken 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

NameTypeDescription
operationstringOnly events of this operation key (see OperationUsage.operation); empty means every operation.
pageSizeintegerMaximum events per page. <= 0 means 25; maximum 100.
pageTokenstringOpaque token from a previous response's nextPageToken; empty for the newest page. An invalid token is INVALID_ARGUMENT.

Response ListUsageResponse

FieldTypeDescription
eventsUsageEvent[]Usage events, newest first.
events[].idstring (int64)Monotonic id; newer events have larger ids.
events[].operationstringOperation key, e.g. "whatsapp.message".
events[].namestringDisplay name of the operation.
events[].unitstringUnit of quantity.
events[].detailsobjectOperation-specific details, e.g. country and message category.
events[].quantitystring (int64)Quantity in the operation's unit.
events[].amountMillicreditsstring (int64)Credits involved in millicredits.
events[].outcomeenumWhether it was charged, refunded or denied. One of: USAGE_OUTCOME_UNSPECIFIED, USAGE_OUTCOME_CHARGED, USAGE_OUTCOME_REFUNDED, USAGE_OUTCOME_DENIED.
events[].createdAtstringWhen it happened (RFC 3339).
nextPageTokenstringToken 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

NameTypeDescription
daysintegerLookback window in days ending now. <= 0 means 30; maximum 366.

Response GetUsageSummaryResponse

FieldTypeDescription
operationsOperationUsage[]Usage per operation.
operations[].operationstringStable operation key, e.g. "whatsapp.message". Use it as the filter in ListUsage.
operations[].namestringDisplay name, e.g. "WhatsApp message".
operations[].unitstringUnit of quantity, e.g. "message" or "minute".
operations[].operationsstring (int64)Number of charged operations in the window.
operations[].quantitystring (int64)Total quantity in the operation's unit.
operations[].amountMillicreditsstring (int64)Credits charged in the window, in millicredits.
operations[].deniedstring (int64)Attempts that were refused (for example for lack of credits); nothing was sent or charged for them.
totalMillicreditsstring (int64)Total credits charged across all operations, in millicredits.
daysintegerThe effective lookback window in days after defaulting/clamping.
curl "https://api.pingx.ai/billing/v1/usage/summary" \
  -H "Authorization: Bearer $PINGX_API_KEY"