Sample - Stripe API
POST/v1/billing/credit_grants

Create a credit grant

Creates a credit grant that allocates billing credits to a customer or customer account. Supply amount and applicability_config, and optionally set the category, effective and expiration times, metadata, name, or application priority. The created grant records how and when its credits can be applied.

  • RetriesRetries up to 2×, 500ms backoff, 30s timeout.
  • IdempotentThe SDK sends Idempotency-Key, so a retried request is only applied once.

11 body fields

Credit grant allocation and applicability configuration.

amountobjectrequired
Amount of this credit grant.
applicability_configobjectrequired
Configuration specifying what this credit grant applies to. We currently only support `metered` prices that have a [Billing Meter](https://docs.stripe.com/api/billing/meter) attached to them.
categorystringoptional
The category of this credit grant. It defaults to `paid` if not specified.
Allowed:paidpromotional
customerstringoptional
ID of the customer receiving the billing credits.
customer_accountstringoptional
ID of the account representing the customer receiving the billing credits.
effective_atintegeroptional
The time when the billing credits become effective-when they're eligible for use. It defaults to the current timestamp if not specified.
expandarray<string>optional
Specifies which fields in the response should be expanded.
expires_atintegeroptional
The time when the billing credits expire. If not specified, the billing credits don't expire.
metadataobjectoptional
Set of key-value pairs that you can attach to an object. You can use this to store additional information about the object (for example, cost basis) in a structured format.
namestringoptional
A descriptive name shown in the Dashboard.
priorityintegeroptional
The desired priority for applying this credit grant. If not specified, it will be set to the default value of 50. The highest priority is 0 and the lowest is 100.

2 status codes
200Returns the created credit grant with its amount, applicability configuration, customer, effective and expiration times, metadata, priority, identifier, and object status.
amountobjectrequired
applicability_configobjectrequired
categorystringrequired
The category of this credit grant. This is for tracking purposes and isn't displayed to the customer.
Allowed:paidpromotional
createdintegerrequired
Time at which the object was created. Measured in seconds since the Unix epoch.
customerstringrequired
ID of the customer receiving the billing credits.
customer_accountstringoptional
ID of the account representing the customer receiving the billing credits
effective_atintegeroptional
The time when the billing credits become effective-when they're eligible for use.
expires_atintegeroptional
The time when the billing credits expire. If not present, the billing credits don't expire.
idstringrequired
Unique identifier for the object.
livemodebooleanrequired
If the object exists in live mode, the value is `true`. If the object exists in test mode, the value is `false`.
metadataobjectrequired
Set of [key-value pairs](https://docs.stripe.com/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
namestringoptional
A descriptive name shown in dashboard.
objectstringrequired
String representing the object's type. Objects of the same type share the same value.
Allowed:billing.credit_grant
priorityintegeroptional
The priority for applying this credit grant. The highest priority is 0 and the lowest is 100.
test_clockstringoptional
ID of the test clock this credit grant belongs to.
updatedintegerrequired
Time at which the object was last updated. Measured in seconds since the Unix epoch.
voided_atintegeroptional
The time when this credit grant was voided. If not present, the credit grant hasn't been voided.
defaultError response.
errorobjectrequired

Error handling

amount and applicability_config are required. amount.type must be monetary, category must be paid or promotional, and effective_at must use Unix time when provided; name must not exceed 100 characters.