Introducing the Better Auth Chargebee plugin: Use it to handle subscriptions, billing, and auth seamlessly.
Chargebeechargebee API

Capture

The capture operation immediately consumes credits for a completed action.

Behavior

  • Credits are directly moved from usable → consumed.
  • No intermediate hold or reservation is created.

Usage

Ideal for simple, immediate consumption scenarios where there is no need for multi-step confirmation or concurrency control.

The response returns both the created ledger_operation object and the updated ledger_account_balance.

Sample Request

Sample Result[JSON]

URL Format

POST https://[site].chargebee.com/api/v2/ledger_operations/capture

Input Parameters

id
optional, string, max chars=50

Optional client-supplied identifier for this capture operation.

Behavior

  • When provided, must uniquely identify this operation across the entire ledger.
  • Should not conflict with any other operation, regardless of type.
subscription_id
required, string, max chars=50

A unique, immutable identifier for the subscription against which credit grants are tracked.

unit_id
required, string, max chars=50

Identifier of the credit unit for which credit grants are tracked. For example, a credit unit id such as ai_credits.

amount
required, string, max chars=36

The number of credits to immediately consume from the usable balance. Pass this value as a decimal string. Maximum supported value: 9999999999999999999999999.9999999999 (up to 25 digits before the decimal and up to 10 digits after).

Behavior

Credits are directly moved from usable → consumed as part of this operation.

Constraints

  • Must be a positive value.
  • Evaluated against the current usable balance at the time of processing.

Example

If amount = "50", then 50 credits are immediately deducted from the usable balance and recorded as consumed.

ledger_operation_timestamp
required, timestamp(UTC) in seconds

Unix timestamp (in seconds) representing when the business operation occurred in the upstream system.

Usage

Used for period attribution, grace-period eligibility, and reporting accuracy.

metadata
optional, jsonobject

Optional opaque JSON object carrying additional business context

Behavior

  • Stored as-is and returned verbatim by the system.
  • Not interpreted, validated, or indexed by the system.

Returns

Ledger operation object
Resource object representing ledger_operation
Ledger account balance object
Resource object representing ledger_account_balance