create_product_rate_plan
Create a product rate plan by specifying name, type (contract/ongoing/prepaid), and optional details like effective dates and commitment.
Instructions
Create a rate plan. POST /product-rateplans. Required: productId (product reference, URI: /products/{productId}), name, type (contract|ongoing|prepaid). Optional: description, effectiveStartDate, effectiveEndDate, minimumCommitment, image.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| productId | Yes | Product ID (URI: /products/{productId}) | |
| name | Yes | Rate plan name | |
| type | Yes | Type: contract, ongoing, or prepaid | |
| description | No | Description | |
| effectiveStartDate | No | Effective start date | |
| effectiveEndDate | No | Effective end date | |
| minimumCommitment | No | Minimum commitment | |
| minimumCommitmentLength | No | Minimum commitment length | |
| minimumCommitmentUnit | No | Minimum commitment unit | |
| changeStatusBasedOnCharge | No | Change status based on charge | |
| sourceTemplateId | No | Source template ID | |
| image | No | Image |
Implementation Reference
- Handler function for the create_product_rate_plan tool. Parses input args with Zod schema, then calls ratePlanService.createRatePlan() to POST /product-rateplans.
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("; ")); } return handleToolCall(() => ratePlanService.createRatePlan(client, parsed.data)); } export const createRatePlanTool: Tool = { definition, handler, }; - Zod schema and inputSchema definition for create_product_rate_plan. Defines required fields: productId, name, type (contract|ongoing|prepaid). Optional fields: description, effectiveStartDate, effectiveEndDate, minimumCommitment, minimumCommitmentLength, minimumCommitmentUnit, changeStatusBasedOnCharge, sourceTemplateId, image.
const schema = z.object({ productId: z.number().int().positive("productId is required"), name: z.string().min(1, "name is required"), type: z.enum(["contract", "ongoing", "prepaid"], { errorMap: () => ({ message: "type must be contract, ongoing, or prepaid" }), }), description: z.string().optional(), effectiveStartDate: z.string().optional(), effectiveEndDate: z.string().optional(), minimumCommitment: z.boolean().optional(), minimumCommitmentLength: z.number().optional(), minimumCommitmentUnit: z.string().optional(), changeStatusBasedOnCharge: z.boolean().optional(), sourceTemplateId: z.number().optional(), image: z.string().optional(), }); const definition = { name: "create_product_rate_plan", description: "Create a rate plan. POST /product-rateplans. Required: productId (product reference, URI: /products/{productId}), name, type (contract|ongoing|prepaid). Optional: description, effectiveStartDate, effectiveEndDate, minimumCommitment, image.", inputSchema: { type: "object" as const, properties: { productId: { type: "number", description: "Product ID (URI: /products/{productId})" }, name: { type: "string", description: "Rate plan name" }, type: { type: "string", description: "Type: contract, ongoing, or prepaid" }, description: { type: "string", description: "Description" }, effectiveStartDate: { type: "string", description: "Effective start date" }, effectiveEndDate: { type: "string", description: "Effective end date" }, minimumCommitment: { type: "boolean", description: "Minimum commitment" }, minimumCommitmentLength: { type: "number", description: "Minimum commitment length" }, minimumCommitmentUnit: { type: "string", description: "Minimum commitment unit" }, changeStatusBasedOnCharge: { type: "boolean", description: "Change status based on charge" }, sourceTemplateId: { type: "number", description: "Source template ID" }, image: { type: "string", description: "Image" }, }, required: ["productId", "name", "type"], }, }; - src/tools/product_rate_plans/index.ts:14-25 (registration)Registration: registerProductRatePlanTools() returns an array including createRatePlanTool. The tool is exported from createRatePlan.ts and aggregated here.
/** All 7 product rate plan tools. */ export function registerProductRatePlanTools(): Tool[] { return [ listRatePlansTool, getRatePlanTool, createRatePlanTool, updateRatePlanTool, deleteRatePlanTool, updateRatePlanStatusTool, syncRatePlanTool, ]; } - src/tools/index.ts:26-57 (registration)Top-level tool registry: create_product_rate_plan is registered via registerProductRatePlanTools() which includes createRatePlanTool.
const tools: Tool[] = [ ...registerCustomerTools(), ...registerProductTools(), ...registerProductRatePlanTools(), ...registerProductRatePlanChargeTools(), ...registerSubscriptionTools(), ...registerInvoiceTools(), ...registerTransactionTools(), ...registerBillRunTools(), ...registerGatewayTools(), ...registerCurrencyTools(), ...registerIntegrationTools(), ...registerShippingTools(), ...registerFilterTools(), ...registerDocsTools(), ]; /** All tool definitions for tools/list */ export function getToolDefinitions(): ToolDefinition[] { return tools.map((t) => t.definition); } /** Execute a tool by name. Returns result or undefined if tool not found. */ export async function executeTool( name: string, args: Record<string, unknown> | undefined, client: RebilliaClient ): Promise<ToolResult | undefined> { const tool = tools.find((t) => t.definition.name === name); if (!tool) return undefined; return tool.handler(client, args); } - Service function createRatePlan() that POSTs to /product-rateplans with the CreateRatePlanBody payload. This is the underlying API call.
export async function createRatePlan( client: Client, body: CreateRatePlanBody ): Promise<unknown> { return client.post<unknown>("/product-rateplans", body); }