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

Authorize

Reserves credit grants at the time of request for later finalization via capture_authorization or release_authorization.

Use this operation when the upstream system requires a strict balance check before finalizing consumption. Credits are moved to a held state immediately, preventing concurrent operations from spending the same credits.

API Behavior

  • Moves credits from usable balance → held (reserved) state.
  • No consumption occurs at this stage; only reservation.
  • Final state is determined later:
    • capture_authorization: converts held credits into consumed.
    • release_authorization: returns held credits to usable balance.

Reserved Credits Behavior

  • Held credits are not consumable by other operations.
  • Held credits are not counted as used until captured.
  • Unreleased holds are automatically returned to usable balance upon expiry.

Use Cases

  • Concurrency control
  • Prevents multiple simultaneous operations from overspending the same credits.
  • Ensures credits are reserved for a specific flow while other requests see reduced availability.

Two-step workflows Supports "check now, finalize later" flows.

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/authorize

Input Parameters

id
optional, string, max chars=50

Optional client-supplied identifier for this authorize operation.

Behavior

  • When provided, must uniquely identify this operation across the entire ledger.
  • Should not conflict with any other operation, regardless of type.

Usage

  • Identifies the specific reservation of credits created by this request.
  • Used as the reference for subsequent operations:
    • capture_authorization: to finalize (consume) the held credits.
    • release_authorization: to release the held credits back to usable balance.
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 credit grants to reserve from the usable balance. While held, this amount is unavailable for other operations, helping prevent concurrent requests from spending the same credits. 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

  • On authorize, this amount is moved from usable_balance to hold_amount. It is not consumed yet.
  • The held amount can later be:
    • Captured via capture_authorization.
    • Released via release_authorization.
    • Auto-released when the hold expires.

Example

If amount = "50", the ledger reserves 50 credits immediately, if available. A later capture_authorization can consume all or part of that hold. Any unused remainder is released back to the usable balance.

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.

auto_release_timestamp
optional, timestamp(UTC) in seconds

Unix timestamp (in seconds) indicating when an unfinalized hold will be automatically released back to the usable balance.

Behavior

  • Applies only to authorize operations.
  • If not explicitly provided, the system assigns a default expiry. Defaults to approximately 10 minutes after the authorize request is processed.

Usage

Ensures held credits are not locked indefinitely by abandoned or unfinalized authorizations.

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