Herald
OpenapiExt

Consume points from user account

Consumes points from a user's account for paid operations. Returns transaction details including the new balance. # Authentication Requires valid API Key via X-API-Key header # Realm Isolation The API key must belong to the same realm as the requested realm. Cross-realm requests will return 403 Forbidden. # Example ```bash curl -X POST \ https://api.example.com/api/ext/points/realm123/consume \ -H "X-API-Key: your-api-key" \ -H "Content-Type: application/json" \ -d '{ "userId": "user-123", "clientAppId": "app-abc", "amount": 100, "description": "AI API call" }' ```

POST
/api/ext/points/{realmId}/consume

Consumes points from a user's account for paid operations. Returns transaction details including the new balance.

Authentication

Requires valid API Key via X-API-Key header

Realm Isolation

The API key must belong to the same realm as the requested realm. Cross-realm requests will return 403 Forbidden.

Example

curl -X POST \
  https://api.example.com/api/ext/points/realm123/consume \
  -H "X-API-Key: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "userId": "user-123",
    "clientAppId": "app-abc",
    "amount": 100,
    "description": "AI API call"
  }'

Authorization

api_key
headerX-API-Key<token>

Client-app API key (third-party external API).

Path Parameters

realmId*string

Realm ID

Request Body

application/json
  1. body

Consume points request (SDK-compatible)

amount*integer
Formatint64
clientAppId*string
description?string|null
idempotencyKey?string|null
userId*string

Response Body

Points consumed successfully

application/json
  1. response

Consume points response (SDK-compatible).

Breaking change: the previous single-transaction shape is replaced by a per-bucket multi-transaction shape. correlation_id groups the N transactions of one consume (DB points_transactions.correlation_id); single-pool hits still produce exactly one transaction.

allocations*array<>

Ledger-level allocations. See [AllocationDetail].

amount*integer

Total points consumed in this request (sum across all affected buckets).

Formatint64
correlationId*string

Grouping key shared by the N transactions of this consume. Falls back to the primary transaction id when the underlying row has no correlation_id (legacy single-pool replay).

transactions*array<>

One entry per affected bucket, sorted by bucket_id ASC. Length 1 for a single-pool hit.

userId*string
Example Request
curl -X POST 'https://example.com/api/ext/points/string/consume' \
  -H 'Content-Type: application/json' \
  -d '{
  "amount": 0,
  "clientAppId": "string",
  "userId": "string"
}'
Example Response
{
  "allocations": [
    {
      "allocatedAmount": 0,
      "bucketId": "string",
      "creditType": "string",
      "ledgerId": "string",
      "walletId": "string"
    }
  ],
  "amount": 0,
  "correlationId": "string",
  "transactions": [
    {
      "amount": 0,
      "balanceAfter": 0,
      "bucketId": "string",
      "transactionId": "string",
      "userId": "string",
      "walletId": "string"
    }
  ],
  "userId": "string"
}