## Create `client.v1.creditGrants.create(CreditGrantCreateParamsbody, RequestOptionsoptions?): CreditGrantCreateResponse` **post** `/v1/credits/createGrant` Create a new credit grant ### Parameters - **body:** `CreditGrantCreateParams` - **customer\_id:** `string` the Metronome ID of the customer - **expires\_at:** `string` The credit grant will only apply to usage or charges dated before this timestamp - **grant\_amount:** `GrantAmount` the amount of credits granted - **amount:** `number` - **credit\_type\_id:** `string` the ID of the pricing unit to be used. Defaults to USD (cents) if not passed. - **name:** `string` the name of the credit grant as it will appear on invoices - **paid\_amount:** `PaidAmount` the amount paid for this credit grant - **amount:** `number` - **credit\_type\_id:** `string` the ID of the pricing unit to be used. Defaults to USD (cents) if not passed. - **priority:** `number` - **credit\_grant\_type:** `string` - **custom\_fields:** `Record` Custom fields to attach to the credit grant. - **effective\_at:** `string` The credit grant will only apply to usage or charges dated on or after this timestamp - **invoice\_date:** `string` The date to issue an invoice for the paid_amount. - **product\_ids:** `Array` The product(s) which these credits will be applied to. (If unspecified, the credits will be applied to charges for all products.). The array ordering specified here will be used to determine the order in which credits will be applied to invoice line items - **reason:** `string` - **rollover\_settings:** `RolloverSettings` Configure a rollover for this credit grant so if it expires it rolls over a configured amount to a new credit grant. This feature is currently opt-in only. Contact Metronome to be added to the beta. - **expires\_at:** `string` The date to expire the rollover credits. - **priority:** `number` The priority to give the rollover credit grant that gets created when a rollover happens. - **rollover\_amount:** `RolloverAmountMaxPercentage | RolloverAmountMaxAmount` Specify how much to rollover to the rollover credit grant - `RolloverAmountMaxPercentage` - `RolloverAmountMaxAmount` - **uniqueness\_key:** `string` Prevents the creation of duplicates. If a request to create a record is made with a previously used uniqueness key, a new record will not be created and the request will fail with a 409 error. ### Returns - `CreditGrantCreateResponse` - **data:** `ID` ### Example ```node import Metronome from '@metronome/sdk'; const client = new Metronome({ bearerToken: 'My Bearer Token', }); const creditGrant = await client.v1.creditGrants.create({ customer_id: '9b85c1c1-5238-4f2a-a409-61412905e1e1', expires_at: '2022-04-01T00:00:00Z', grant_amount: { amount: 1000, credit_type_id: '5ae401dc-a648-4b49-9ac3-391bb5bc4d7b' }, name: 'Acme Corp Promotional Credit Grant', paid_amount: { amount: 5000, credit_type_id: '2714e483-4ff1-48e4-9e25-ac732e8f24f2' }, priority: 0.5, credit_grant_type: 'trial', effective_at: '2022-02-01T00:00:00Z', reason: 'Incentivize new customer', }); console.log(creditGrant.data); ```