## Create `client.V1.CreditGrants.New(ctx, body) (*V1CreditGrantNewResponse, error)` **post** `/v1/credits/createGrant` Create a new credit grant ### Parameters - **body:** `V1CreditGrantNewParams` - **CustomerID:** `param.Field[string]` the Metronome ID of the customer - **ExpiresAt:** `param.Field[Time]` The credit grant will only apply to usage or charges dated before this timestamp - **GrantAmount:** `param.Field[V1CreditGrantNewParamsGrantAmount]` the amount of credits granted - **Amount:** `float64` - **CreditTypeID:** `string` the ID of the pricing unit to be used. Defaults to USD (cents) if not passed. - **Name:** `param.Field[string]` the name of the credit grant as it will appear on invoices - **PaidAmount:** `param.Field[V1CreditGrantNewParamsPaidAmount]` the amount paid for this credit grant - **Amount:** `float64` - **CreditTypeID:** `string` the ID of the pricing unit to be used. Defaults to USD (cents) if not passed. - **Priority:** `param.Field[float64]` - **CreditGrantType:** `param.Field[string]` - **CustomFields:** `param.Field[map[string, string]]` Custom fields to attach to the credit grant. - **EffectiveAt:** `param.Field[Time]` The credit grant will only apply to usage or charges dated on or after this timestamp - **InvoiceDate:** `param.Field[Time]` The date to issue an invoice for the paid_amount. - **ProductIDs:** `param.Field[[]string]` 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:** `param.Field[string]` - **RolloverSettings:** `param.Field[V1CreditGrantNewParamsRolloverSettings]` 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. - **ExpiresAt:** `Time` The date to expire the rollover credits. - **Priority:** `float64` The priority to give the rollover credit grant that gets created when a rollover happens. - **RolloverAmount:** `V1CreditGrantNewParamsRolloverSettingsRolloverAmount` Specify how much to rollover to the rollover credit grant - Not supported - **Type:** `RolloverAmountMaxPercentageType` Rollover up to a percentage of the original credit grant amount. - `RolloverAmountMaxPercentageType` - **Value:** `float64` The maximum percentage (0-1) of the original credit grant to rollover. - Not supported - **Type:** `RolloverAmountMaxAmountType` Rollover up to a fixed amount of the original credit grant amount. - `RolloverAmountMaxAmountType` - **Value:** `float64` The maximum amount to rollover. - **UniquenessKey:** `param.Field[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 - Not supported - **Data:** `ID` ### Example ```go package main import ( "context" "fmt" "time" "github.com/Metronome-Industries/metronome-go" "github.com/Metronome-Industries/metronome-go/option" ) func main() { client := metronome.NewClient( option.WithBearerToken("My Bearer Token"), ) creditGrant, err := client.V1.CreditGrants.New(context.TODO(), metronome.V1CreditGrantNewParams{ CustomerID: metronome.F("9b85c1c1-5238-4f2a-a409-61412905e1e1"), ExpiresAt: metronome.F(time.Now()), GrantAmount: metronome.F(metronome.V1CreditGrantNewParamsGrantAmount{ Amount: metronome.F(1000.000000), CreditTypeID: metronome.F("5ae401dc-a648-4b49-9ac3-391bb5bc4d7b"), }), Name: metronome.F("Acme Corp Promotional Credit Grant"), PaidAmount: metronome.F(metronome.V1CreditGrantNewParamsPaidAmount{ Amount: metronome.F(5000.000000), CreditTypeID: metronome.F("2714e483-4ff1-48e4-9e25-ac732e8f24f2"), }), Priority: metronome.F(0.500000), CreditGrantType: metronome.F("trial"), EffectiveAt: metronome.F(time.Now()), Reason: metronome.F("Incentivize new customer"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", creditGrant.Data) } ```