Skip to main content
Glama

create_product_rate_plan_charge

Create a new rate plan charge for a product subscription. Define charge type, model, tiers, billing cycle, and tax settings.

Instructions

Create a rate plan charge. POST /product-rateplan-charges. Required: ratePlanId (rate plan reference, URI: /product-rateplans/{ratePlanId}), name, chargeType (oneTime|recurring|usage), chargeModel (flatFeePricing|perUnitPricing|tieredPricing|volumePricing), billCycleType, category (physical|digital), chargeTier (array of {currency ex. 'USD', price in cents, optional startingUnit, endingUnit, priceFormat, tier}), taxable, weight. Optional: billingPeriod (day|week|month|year), billingTiming (inAdvance|inArrears), description, etc.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ratePlanIdYesRate plan ID (URI: /product-rateplans/{ratePlanId})
nameYesCharge name
chargeTypeYesoneTime, recurring, or usage
chargeModelYesflatFeePricing, perUnitPricing, tieredPricing, or volumePricing
billCycleTypeYesBill cycle type (e.g. chargeTriggerDay, specificDayOfMonth)
categoryYesphysical or digital
chargeTierYesArray of {currency, price, optional startingUnit, endingUnit, priceFormat, tier}
taxableYesWhether taxable
weightYesWeight (integer)
descriptionNoDescription
billingPeriodNoday, week, month, or year (required if chargeType recurring)
billingTimingNoinAdvance or inArrears (required if chargeType recurring)
billingPeriodAlignmentNoalignToCharge, alignToSubscriptionStart, alignToTermStart
specificBillingPeriodNoSpecific billing period
allowChangeQuantityNoAllow change quantity
billCycleDayNo1-31 when billCycleType specificDayOfMonth
weeklyBillCycleDayNosunday..saturday when billCycleType specificDayOfWeek
monthlyBillCycleYearNo1-12 when billCycleType specificMonthOfYear
endDateConditionYessubscriptionEnd or fixedPeriod (required)
isFreeShippingNoFree shipping
maxQuantityNoMax quantity
minQuantityNoMin quantity
quantityNoQuantity
listPriceBaseNoperMonth, perBillingPeriod, or perWeek

Implementation Reference

  • Handler function that parses and validates input via Zod schema, constructs the request body from parsed data, then delegates to the service layer's createRatePlanCharge function via handleToolCall.
    async function handler(client: Client, args: Record<string, unknown> | undefined) {
      const parsed = schema.safeParse(args);
      if (!parsed.success) {
        return errorResult(parsed.error.errors.map((e) => `${e.path.join(".")}: ${e.message}`).join("; "));
      }
      const data = parsed.data;
      const body = {
        ratePlanId: data.ratePlanId,
        name: data.name,
        chargeType: data.chargeType,
        chargeModel: data.chargeModel,
        billCycleType: data.billCycleType,
        category: data.category,
        chargeTier: data.chargeTier,
        taxable: data.taxable,
        weight: data.weight,
        endDateCondition: data.endDateCondition,
        description: data.description,
        billingPeriod: data.billingPeriod,
        billingTiming: data.billingTiming,
        billingPeriodAlignment: data.billingPeriodAlignment,
        specificBillingPeriod: data.specificBillingPeriod,
        allowChangeQuantity: data.allowChangeQuantity,
        billCycleDay: data.billCycleDay,
        weeklyBillCycleDay: data.weeklyBillCycleDay,
        monthlyBillCycleYear: data.monthlyBillCycleYear,
        isFreeShipping: data.isFreeShipping,
        maxQuantity: data.maxQuantity,
        minQuantity: data.minQuantity,
        quantity: data.quantity,
        listPriceBase: data.listPriceBase,
      };
      return handleToolCall(() => chargeService.createRatePlanCharge(client, body));
    }
    
    export const createRatePlanChargeTool: Tool = {
      definition,
      handler,
    };
  • Zod schema defining input validation for create_product_rate_plan_charge: required fields (ratePlanId, name, chargeType, chargeModel, billCycleType, category, chargeTier, taxable, weight, endDateCondition) plus many optional fields.
    const chargeTierItemSchema = z.object({
      currency: z.string().min(1),
      startingUnit: z.string().optional(),
      endingUnit: z.string().optional(),
      price: z.number().int(),
      priceFormat: z.string().optional(),
      tier: z.number().int().optional(),
    });
    
    const schema = z.object({
      ratePlanId: z.number().int().positive("ratePlanId is required"),
      name: z.string().min(1, "name is required"),
      chargeType: z.enum(chargeTypeEnum, {
        errorMap: () => ({ message: `chargeType must be one of: ${chargeTypeEnum.join(", ")}` }),
      }),
      chargeModel: z.enum(chargeModelEnum, {
        errorMap: () => ({ message: `chargeModel must be one of: ${chargeModelEnum.join(", ")}` }),
      }),
      billCycleType: z.enum(billCycleTypeEnum, {
        errorMap: () => ({ message: `billCycleType must be one of: ${billCycleTypeEnum.join(", ")}` }),
      }),
      category: z.enum(["physical", "digital"]),
      chargeTier: z.array(chargeTierItemSchema).min(1, "chargeTier must have at least one item"),
      taxable: z.boolean(),
      weight: z.coerce.number().int().min(0, "weight must be a non-negative number"),
      description: z.string().optional(),
      billingPeriod: z.enum(billingPeriodEnum).optional(),
      billingTiming: z.enum(billingTimingEnum).optional(),
      billingPeriodAlignment: z.string().optional(),
      specificBillingPeriod: z.number().int().optional(),
      allowChangeQuantity: z.boolean().optional(),
      billCycleDay: z.number().int().min(1).max(31).optional(),
      weeklyBillCycleDay: z.string().optional(),
      monthlyBillCycleYear: z.number().int().min(1).max(12).optional(),
      endDateCondition: z.enum(["subscriptionEnd", "fixedPeriod"]),
      isFreeShipping: z.boolean().optional(),
      maxQuantity: z.number().int().optional(),
      minQuantity: z.number().int().optional(),
      quantity: z.number().int().optional(),
      listPriceBase: z.enum(["perMonth", "perBillingPeriod", "perWeek"]).optional(),
    });
  • Registration function that includes createRatePlanChargeTool in the list of product rate plan charge tools. Called from src/tools/index.ts line 30.
    export function registerProductRatePlanChargeTools(): Tool[] {
      return [
        listRatePlanChargesTool,
        getRatePlanChargeTool,
        createRatePlanChargeTool,
        updateRatePlanChargeTool,
        deleteRatePlanChargeTool,
      ];
    }
    
    export { listRatePlanChargesTool } from "./listRatePlanCharges.js";
    export { getRatePlanChargeTool } from "./getRatePlanCharge.js";
    export { createRatePlanChargeTool } from "./createRatePlanCharge.js";
    export { updateRatePlanChargeTool } from "./updateRatePlanCharge.js";
    export { deleteRatePlanChargeTool } from "./deleteRatePlanCharge.js";
  • Helper utilities used by the create handler: errorResult, successResult, and handleToolCall for wrapping service calls with try/catch.
    export function errorResult(message: string): ToolResult {
      return {
        content: [{ type: "text" as const, text: message }],
        isError: true,
      };
    }
    
    export function successResult(data: unknown): ToolResult {
      return {
        content: [
          { type: "text" as const, text: JSON.stringify(data, null, 2) },
        ],
      };
    }
    
    export async function handleToolCall<T>(fn: () => Promise<T>): Promise<ToolResult> {
      try {
        const data = await fn();
        return successResult(data);
      } catch (err) {
        const message = err instanceof Error ? err.message : String(err);
        return errorResult(`Error: ${message}`);
      }
    }
  • Service layer function that normalizes weight and chargeTier (ensuring priceFormat defaults to ''), then POSTs to /product-rateplan-charges.
    export async function createRatePlanCharge(
      client: Client,
      body: CreateRatePlanChargeBody
    ): Promise<unknown> {
      const payload = { ...body };
      if (payload.weight != null) payload.weight = Number(payload.weight);
      if (payload.chargeTier?.length) payload.chargeTier = normalizeChargeTier(payload.chargeTier);
      return client.post<unknown>("/product-rateplan-charges", payload);
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must disclose behavior. It only indicates a POST request (creation) and lists parameters. It does not mention side effects, authentication requirements, idempotency, rate limits, or the response format. The behavioral context is minimal.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with the purpose but then becomes a dense comma-separated list of parameters. It is not well-structured (e.g., bullet points) and includes 'etc.' which is vague. Adequate but not concise or well-organized.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Despite 24 parameters, the description does not explain return values, error handling, or how the charge relates to the rate plan or other entities. It also omits details on conditional requirements (e.g., billingPeriod required if chargeType recurring). Incomplete for a complex creation tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3. The description adds some value by grouping required/optional parameters and providing examples (e.g., chargeTier format). However, it largely repeats schema information and does not significantly deepen understanding.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Create a rate plan charge' and includes the HTTP endpoint. It specifies the required and optional parameters, which distinguishes it as a creation tool. However, it does not explicitly differentiate from sibling tools like create_product_rate_plan or create_subscription_rate_plan_charge, leaving some ambiguity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. There is no mention of prerequisites, when-not-to-use, or comparisons to siblings like create_subscription_rate_plan_charge. The description simply lists parameters.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/rhinosaas/rebillia-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server