Introducing the Chargebee CLI

Update a credit rate

Changes the credit rate for a metered feature by creating a new version. Earlier versions are kept, and usage that was already converted into credits is not re-priced.

Fields you don't pass keep their values from the current version. credit_unit_id cannot be changed. change_option decides which subscriptions get the new version and when. See How the applicable credit rate is determined.

Prerequisites & Constraints

  • The metered feature must already have a credit rate.

Implementation Notes

  • To change the rate for one subscription right away, don't update the credit rate. Use Set a credit rate override instead; an override applies to its subscription as soon as it is created.
  • The response contains the new version. To see the rate that applies to a particular subscription, use List credit rates for a subscription.

Sample Request

update a credit rate with end of term rollout

Sample Result[JSON]

URL Format

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

Input Parameters

change_option
required, enumerated string

Determines which subscriptions get the new version and when. Pass end_of_term or grandfathered.

immediately Not accepted. To change the rate for one subscription right away, use Set a credit rate override.

Enum Values
grandfathered

Only subscriptions created after the update get the new version. Existing subscriptions stay on the version they already use.

end_of_term

Subscriptions created after the update get the new version right away. Existing subscriptions get it when their term renews or resets.

immediately
conversion_model
optional, enumerated string

Determines how usage is converted into credits. If not passed, the current value is kept. 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. If not passed, the current value is kept.

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
optional, 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. If not passed, the current value is kept.

Constraints

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

The reason for this change, shown in the version history.

Returns

Credit rate object

The new version of the credit rate.