Skip to content
Book a demoContact 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.

Code string

Code of this rate to be used for setting quantity and price multipliers. This code must be unique within the rate card.

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
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
Description stringoptional

The description of the rate displayed to the customer.

Metadata param.Field[map[string, string]]optional
RateCatalogID param.Field[string]optional

The ID of the rate catalog to pull rates from. If set, rates from the catalog with quantity > 1 will be included.

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{…}
Code string

Code of this rate to be used for price multipliers. This code must be unique within the rate card.

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
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
PricingMetricID string

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

UsageBasedRateType 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{…}
Code string

Code of this rate to be used for price multipliers. This code must be unique within the rate card.

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
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
PricingMetricID string

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

UsageBasedRateType 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
Code 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
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
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
Code 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
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
PricingMetricID string
UsageBasedRateType stringoptional
type RateCardResourceUsageBasedRateDimensional struct{…}
ID string
Code 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
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
PricingMetricID string
UsageBasedRateType stringoptional
Description stringoptional

The description of the rate card.

RateCatalogID stringoptional

The ID of the rate catalog associated with this rate card.

Create Rate Card
package main

import (
  "context"
  "fmt"

  "github.com/stainless-sdks/lark-go"
  "github.com/stainless-sdks/lark-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",
      Code: "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",
        Code: "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",
      "code": "base_rate",
      "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",
      "code": "compute_hours",
      "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.",
  "rate_catalog_id": "rcat_GlX5Tcm2HOn00CoRTFxw2Amw"
}
Returns Examples
{
  "id": "rc_jQK2n0wutCj6bBcAIrL6o07g",
  "billing_interval": "monthly",
  "created_at": "2025-11-01T00:00:00Z",
  "fixed_rates": [
    {
      "id": "fr_04EjnYJoQLC7gtLKI6mPzZny",
      "code": "base_rate",
      "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",
      "code": "compute_hours",
      "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.",
  "rate_catalog_id": "rcat_GlX5Tcm2HOn00CoRTFxw2Amw"
}