Skip to content
Join our SlackContact usGet started

Create Rate Card

client.RateCards.New(ctx, body) (*RateCardResource, error)
post/rate-cards

Create Rate Card

ParametersExpand Collapse
body RateCardNewParams
BillingInterval param.Field[RateCardNewParamsBillingInterval]

How often the customer will be billed for this rate card.

const RateCardNewParamsBillingIntervalMonthly RateCardNewParamsBillingInterval = "monthly"
const RateCardNewParamsBillingIntervalYearly RateCardNewParamsBillingInterval = "yearly"
Name param.Field[string]

The name of the rate card displayed to the customer.

Description param.Field[string]optional

The description of the rate card displayed to the customer.

FixedRates param.Field[[]RateCardNewParamsFixedRate]optional

The fixed rates of the rate card. These are billed at the start of each billing cycle.

Name string

The name of the rate displayed to the customer.

Price RateCardNewParamsFixedRatePriceUnion

Flat price is a price that linearly scales with the quantity.

Accepts one of the following:
type FlatPriceInput struct{…}

Flat price is a price that linearly scales with the quantity.

CurrencyCode string

The currency code of the amount.

Value AmountInputValueUnion

The value of the amount in the smallest unit of the currency.

Accepts one of the following:
float64
string
PriceType FlatPriceInputPriceTypeoptional
Accepts one of the following:
const FlatPriceInputPriceTypeFlat FlatPriceInputPriceType = "flat"
type PackagePriceInput struct{…}

Package price is a price that is charged for a fixed number of units. For example, $10 per 1000 units. If the quantity is not a multiple of the package units, the rounding behavior will be applied.

CurrencyCode string

The currency code of the amount.

Value AmountInputValueUnion

The value of the amount in the smallest unit of the currency.

Accepts one of the following:
float64
string
PackageUnits int64
RoundingBehavior PackagePriceInputRoundingBehavior
Accepts one of the following:
const PackagePriceInputRoundingBehaviorRoundUp PackagePriceInputRoundingBehavior = "round_up"
const PackagePriceInputRoundingBehaviorRoundDown PackagePriceInputRoundingBehavior = "round_down"
PriceType PackagePriceInputPriceTypeoptional
Accepts one of the following:
const PackagePriceInputPriceTypePackage PackagePriceInputPriceType = "package"
Description stringoptional

The description of the rate displayed to the customer.

Metadata param.Field[map[string, string]]optional
UsageBasedRates param.Field[[]RateCardNewParamsUsageBasedRateUnion]optional

The usage based rates of the rate card. These are billed at the end of each billing cycle.

type RateCardNewParamsUsageBasedRateSimple struct{…}
Name string

The name of the rate displayed to the customer.

Price RateCardNewParamsUsageBasedRateSimplePriceUnion

Flat price is a price that linearly scales with the quantity.

Accepts one of the following:
type FlatPriceInput struct{…}

Flat price is a price that linearly scales with the quantity.

CurrencyCode string

The currency code of the amount.

Value AmountInputValueUnion

The value of the amount in the smallest unit of the currency.

Accepts one of the following:
float64
string
PriceType FlatPriceInputPriceTypeoptional
Accepts one of the following:
const FlatPriceInputPriceTypeFlat FlatPriceInputPriceType = "flat"
type PackagePriceInput struct{…}

Package price is a price that is charged for a fixed number of units. For example, $10 per 1000 units. If the quantity is not a multiple of the package units, the rounding behavior will be applied.

CurrencyCode string

The currency code of the amount.

Value AmountInputValueUnion

The value of the amount in the smallest unit of the currency.

Accepts one of the following:
float64
string
PackageUnits int64
RoundingBehavior PackagePriceInputRoundingBehavior
Accepts one of the following:
const PackagePriceInputRoundingBehaviorRoundUp PackagePriceInputRoundingBehavior = "round_up"
const PackagePriceInputRoundingBehaviorRoundDown PackagePriceInputRoundingBehavior = "round_down"
PriceType PackagePriceInputPriceTypeoptional
Accepts one of the following:
const PackagePriceInputPriceTypePackage PackagePriceInputPriceType = "package"
PricingMetricID string

The ID of the pricing metric to use for this rate.

UsageBasedRateType Simple
Accepts one of the following:
const SimpleSimple Simple = "simple"
Description stringoptional

The description of the rate displayed to the customer.

IncludedUnits int64optional

The number of units included in the rate before the price is applied.

minimum0
type RateCardNewParamsUsageBasedRateDimensional struct{…}
Dimensions []RateCardNewParamsUsageBasedRateDimensionalDimension

The dimensions of the rate.

Key string

The name of the dimension. This is used to identify the dimension in the pricing matrix.

Values []string

A list of possible values for the dimension.

Description stringoptional

The description of the dimension.

Name string

The name of the rate displayed to the customer.

PricingMatrix RateCardNewParamsUsageBasedRateDimensionalPricingMatrix

The pricing matrix of the rate.

Cells []RateCardNewParamsUsageBasedRateDimensionalPricingMatrixCell
DimensionCoordinates map[string, string]

A key-value mapping of dimension keys and values to identify the price for a given set of dimension values.

Price RateCardNewParamsUsageBasedRateDimensionalPricingMatrixCellPriceUnion

The price for the cell.

Accepts one of the following:
type FlatPriceInput struct{…}

Flat price is a price that linearly scales with the quantity.

CurrencyCode string

The currency code of the amount.

Value AmountInputValueUnion

The value of the amount in the smallest unit of the currency.

Accepts one of the following:
float64
string
PriceType FlatPriceInputPriceTypeoptional
Accepts one of the following:
const FlatPriceInputPriceTypeFlat FlatPriceInputPriceType = "flat"
type PackagePriceInput struct{…}

Package price is a price that is charged for a fixed number of units. For example, $10 per 1000 units. If the quantity is not a multiple of the package units, the rounding behavior will be applied.

CurrencyCode string

The currency code of the amount.

Value AmountInputValueUnion

The value of the amount in the smallest unit of the currency.

Accepts one of the following:
float64
string
PackageUnits int64
RoundingBehavior PackagePriceInputRoundingBehavior
Accepts one of the following:
const PackagePriceInputRoundingBehaviorRoundUp PackagePriceInputRoundingBehavior = "round_up"
const PackagePriceInputRoundingBehaviorRoundDown PackagePriceInputRoundingBehavior = "round_down"
PriceType PackagePriceInputPriceTypeoptional
Accepts one of the following:
const PackagePriceInputPriceTypePackage PackagePriceInputPriceType = "package"
PricingMetricID string

The ID of the pricing metric to use for this rate.

UsageBasedRateType Dimensional
Accepts one of the following:
const DimensionalDimensional Dimensional = "dimensional"
Description stringoptional

The description of the rate displayed to the customer.

IncludedUnits int64optional

The number of units included in the rate before the price is applied.

minimum0
ReturnsExpand Collapse
type RateCardResource struct{…}
ID string

The ID of the rate card.

BillingInterval RateCardResourceBillingInterval

How often the customer will be billed for this rate card.

Accepts one of the following:
const RateCardResourceBillingIntervalMonthly RateCardResourceBillingInterval = "monthly"
const RateCardResourceBillingIntervalYearly RateCardResourceBillingInterval = "yearly"
CreatedAt Time

The date and time the rate card was created.

formatdate-time
FixedRates []RateCardResourceFixedRate

The fixed rates of the rate card.

ID string
Description string
Name string
Price RateCardResourceFixedRatePriceUnion

Flat price is a price that linearly scales with the quantity.

Accepts one of the following:
type FlatPriceOutput struct{…}

Flat price is a price that linearly scales with the quantity.

CurrencyCode string

The currency code of the amount.

Value string

The value of the amount in the smallest unit of the currency.

PriceType FlatPriceOutputPriceTypeoptional
Accepts one of the following:
const FlatPriceOutputPriceTypeFlat FlatPriceOutputPriceType = "flat"
type PackagePriceOutput struct{…}

Package price is a price that is charged for a fixed number of units. For example, $10 per 1000 units. If the quantity is not a multiple of the package units, the rounding behavior will be applied.

CurrencyCode string

The currency code of the amount.

Value string

The value of the amount in the smallest unit of the currency.

PackageUnits int64
RoundingBehavior PackagePriceOutputRoundingBehavior
Accepts one of the following:
const PackagePriceOutputRoundingBehaviorRoundUp PackagePriceOutputRoundingBehavior = "round_up"
const PackagePriceOutputRoundingBehaviorRoundDown PackagePriceOutputRoundingBehavior = "round_down"
PriceType PackagePriceOutputPriceTypeoptional
Accepts one of the following:
const PackagePriceOutputPriceTypePackage PackagePriceOutputPriceType = "package"
Metadata map[string, string]

Additional metadata about the rate card. You may use this to store any custom data about the rate card.

Name string

The name of the rate card.

UpdatedAt Time

The date and time the rate card was last updated.

formatdate-time
UsageBasedRates []RateCardResourceUsageBasedRateUnion

The usage based rates of the rate card.

Accepts one of the following:
type RateCardResourceUsageBasedRateSimple struct{…}
ID string
Description string
IncludedUnits int64
Name string
Price RateCardResourceUsageBasedRateSimplePriceUnion

Flat price is a price that linearly scales with the quantity.

Accepts one of the following:
type FlatPriceOutput struct{…}

Flat price is a price that linearly scales with the quantity.

CurrencyCode string

The currency code of the amount.

Value string

The value of the amount in the smallest unit of the currency.

PriceType FlatPriceOutputPriceTypeoptional
Accepts one of the following:
const FlatPriceOutputPriceTypeFlat FlatPriceOutputPriceType = "flat"
type PackagePriceOutput struct{…}

Package price is a price that is charged for a fixed number of units. For example, $10 per 1000 units. If the quantity is not a multiple of the package units, the rounding behavior will be applied.

CurrencyCode string

The currency code of the amount.

Value string

The value of the amount in the smallest unit of the currency.

PackageUnits int64
RoundingBehavior PackagePriceOutputRoundingBehavior
Accepts one of the following:
const PackagePriceOutputRoundingBehaviorRoundUp PackagePriceOutputRoundingBehavior = "round_up"
const PackagePriceOutputRoundingBehaviorRoundDown PackagePriceOutputRoundingBehavior = "round_down"
PriceType PackagePriceOutputPriceTypeoptional
Accepts one of the following:
const PackagePriceOutputPriceTypePackage PackagePriceOutputPriceType = "package"
PricingMetricID string
UsageBasedRateType stringoptional
Accepts one of the following:
const RateCardResourceUsageBasedRateSimpleUsageBasedRateTypeSimple RateCardResourceUsageBasedRateSimpleUsageBasedRateType = "simple"
type RateCardResourceUsageBasedRateDimensional struct{…}
ID string
Description string
Dimensions []RateCardResourceUsageBasedRateDimensionalDimension
Description string
Key string
Values []string
IncludedUnits int64
Name string
PricingMatrix RateCardResourceUsageBasedRateDimensionalPricingMatrix
Cells []RateCardResourceUsageBasedRateDimensionalPricingMatrixCell
DimensionCoordinates map[string, string]
Price RateCardResourceUsageBasedRateDimensionalPricingMatrixCellPriceUnion

Flat price is a price that linearly scales with the quantity.

Accepts one of the following:
type FlatPriceOutput struct{…}

Flat price is a price that linearly scales with the quantity.

CurrencyCode string

The currency code of the amount.

Value string

The value of the amount in the smallest unit of the currency.

PriceType FlatPriceOutputPriceTypeoptional
Accepts one of the following:
const FlatPriceOutputPriceTypeFlat FlatPriceOutputPriceType = "flat"
type PackagePriceOutput struct{…}

Package price is a price that is charged for a fixed number of units. For example, $10 per 1000 units. If the quantity is not a multiple of the package units, the rounding behavior will be applied.

CurrencyCode string

The currency code of the amount.

Value string

The value of the amount in the smallest unit of the currency.

PackageUnits int64
RoundingBehavior PackagePriceOutputRoundingBehavior
Accepts one of the following:
const PackagePriceOutputRoundingBehaviorRoundUp PackagePriceOutputRoundingBehavior = "round_up"
const PackagePriceOutputRoundingBehaviorRoundDown PackagePriceOutputRoundingBehavior = "round_down"
PriceType PackagePriceOutputPriceTypeoptional
Accepts one of the following:
const PackagePriceOutputPriceTypePackage PackagePriceOutputPriceType = "package"
PricingMetricID string
UsageBasedRateType stringoptional
Accepts one of the following:
const RateCardResourceUsageBasedRateDimensionalUsageBasedRateTypeDimensional RateCardResourceUsageBasedRateDimensionalUsageBasedRateType = "dimensional"
Description stringoptional

The description of the rate card.

Create Rate Card
package main

import (
  "context"
  "fmt"

  "github.com/stainless-sdks/-go"
  "github.com/stainless-sdks/-go/option"
)

func main() {
  client := lark.NewClient(
    option.WithAPIKey("My API Key"),
  )
  rateCardResource, err := client.RateCards.New(context.TODO(), lark.RateCardNewParams{
    BillingInterval: lark.RateCardNewParamsBillingIntervalMonthly,
    Name: "Pro Plan",
    Description: lark.String("For production applicatidddons with moderate usage."),
    FixedRates: []lark.RateCardNewParamsFixedRate{lark.RateCardNewParamsFixedRate{
      Name: "Base Rate",
      Price: lark.RateCardNewParamsFixedRatePriceUnion{
        OfFlat: &lark.FlatPriceInputParam{
          PriceType: lark.FlatPriceInputPriceTypeFlat,
          Amount: lark.AmountInputParam{
            Value: lark.AmountInputValueUnionParam{
              OfFloat: lark.Float(2500),
            },
            CurrencyCode: "usd",
          },
        },
      },
    }},
    Metadata: map[string]string{
    },
    UsageBasedRates: []lark.RateCardNewParamsUsageBasedRateUnion{lark.RateCardNewParamsUsageBasedRateUnion{
      OfSimple: &lark.RateCardNewParamsUsageBasedRateSimple{
        Name: "Compute Hours",
        Price: lark.RateCardNewParamsUsageBasedRateSimplePriceUnion{
          OfFlat: &lark.FlatPriceInputParam{
            PriceType: lark.FlatPriceInputPriceTypeFlat,
            Amount: lark.AmountInputParam{
              Value: lark.AmountInputValueUnionParam{
                OfFloat: lark.Float(100),
              },
              CurrencyCode: "usd",
            },
          },
        },
        IncludedUnits: lark.Int(30),
        PricingMetricID: "pmtr_GlX5Tcm2HOn00CoRTFxw2Amw",
      },
    }},
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", rateCardResource.ID)
}
{
  "id": "rc_jQK2n0wutCj6bBcAIrL6o07g",
  "billing_interval": "monthly",
  "created_at": "2025-11-01T00:00:00Z",
  "fixed_rates": [
    {
      "id": "fr_04EjnYJoQLC7gtLKI6mPzZny",
      "description": "description",
      "name": "Base Rate",
      "price": {
        "amount": {
          "currency_code": "usd",
          "value": "2500"
        },
        "price_type": "flat"
      }
    }
  ],
  "metadata": {},
  "name": "Pro Plan",
  "updated_at": "2025-11-01T00:00:00Z",
  "usage_based_rates": [
    {
      "id": "ubr_zoXOJrDXlGGJWRNq3HqFYhbP",
      "description": "description",
      "included_units": 30,
      "name": "Compute Hours",
      "price": {
        "amount": {
          "currency_code": "usd",
          "value": "100"
        },
        "price_type": "flat"
      },
      "pricing_metric_id": "pmtr_GlX5Tcm2HOn00CoRTFxw2Amw",
      "usage_based_rate_type": "simple"
    }
  ],
  "description": "For production applications with moderate usage."
}
Returns Examples
{
  "id": "rc_jQK2n0wutCj6bBcAIrL6o07g",
  "billing_interval": "monthly",
  "created_at": "2025-11-01T00:00:00Z",
  "fixed_rates": [
    {
      "id": "fr_04EjnYJoQLC7gtLKI6mPzZny",
      "description": "description",
      "name": "Base Rate",
      "price": {
        "amount": {
          "currency_code": "usd",
          "value": "2500"
        },
        "price_type": "flat"
      }
    }
  ],
  "metadata": {},
  "name": "Pro Plan",
  "updated_at": "2025-11-01T00:00:00Z",
  "usage_based_rates": [
    {
      "id": "ubr_zoXOJrDXlGGJWRNq3HqFYhbP",
      "description": "description",
      "included_units": 30,
      "name": "Compute Hours",
      "price": {
        "amount": {
          "currency_code": "usd",
          "value": "100"
        },
        "price_type": "flat"
      },
      "pricing_metric_id": "pmtr_GlX5Tcm2HOn00CoRTFxw2Amw",
      "usage_based_rate_type": "simple"
    }
  ],
  "description": "For production applications with moderate usage."
}