Introducing the Chargebee CLI

Create a credit rate

Creates the credit rate for a metered feature. The new credit rate is version 0, is active, and applies right away to every subscription that has a credit grant for its credit_unit_id.

Prerequisites & Constraints

  • The metered feature must exist and be active.
  • The metered feature must not already have a credit rate.

Implementation Notes

Sample Request

create a credit rate for a metered feature

Sample Result[JSON]

URL Format

POST https://[site].chargebee.com/api/v2/metered_features/{metered-feature-id}/create_credit_rate

Input Parameters

credit_unit_id
required, string, max chars=50

The identifier of the credit unit that usage is converted into. It cannot be changed after the credit rate is created.

conversion_model
required, enumerated string

Determines how usage is converted into credits. See Conversion models.

Enum Values
unit

Every unit of usage costs credit_cost credits. Do not pass package_size.

package

Usage is charged in packages of package_size units, and each package costs credit_cost credits. Packages are counted on the total usage in the billing term, and a partly used package is charged as a full package.

package_size
optional, bigdecimal, min=1E-9, max=999999999.999999999

The number of usage units in one package.

Required if

  • conversion_model is package.

Constraints

  • Must be greater than 0.
  • Supports up to 9 decimal places.
  • Not accepted when conversion_model is unit.
credit_cost
required, bigdecimal, min=0, max=999999999.999999999

The credits charged for each unit of usage when conversion_model is unit, or for each package of package_size units when conversion_model is package.

Constraints

  • Must be greater than or equal to 0.
  • Supports up to 9 decimal places.
note
optional, string, max chars=500

The reason for creating this credit rate, shown in the version history.

Returns

Credit rate object

The credit rate that was created, as version 0.