link_external_product
Link an external product from an integrated platform to a Rebillia product, enabling subscription billing modifiers with a display name.
Instructions
Link an external product to a product. POST /products/{productId}/external-products. Required: companyIntegrationId, productId (external), settings with modifierDisplayName.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| productId | Yes | Rebillia product ID (required) | |
| companyIntegrationId | Yes | Company integration ID (required) | |
| productIdExternal | Yes | External product ID from the integration (required) | |
| modifierDisplayName | Yes | Display name for the modifier (required, part of settings) | |
| displayStyle | No | e.g. dropdown | |
| required | No | Whether the external product is required | |
| defaultRatePlan | No | Default rate plan |
Implementation Reference
- The handler function that parses arguments via Zod schema, constructs the request body, and calls productService.linkExternalProduct to POST /products/{productId}/external-products.
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 { productId, companyIntegrationId, productIdExternal, modifierDisplayName, displayStyle, required, defaultRatePlan, } = parsed.data; const body = { companyIntegrationId, productId: productIdExternal, settings: { modifierDisplayName }, displayStyle, required, defaultRatePlan, }; return handleToolCall(() => productService.linkExternalProduct(client, productId, body)); } - Zod schema defining input validation: requires productId, companyIntegrationId, productIdExternal, modifierDisplayName; optional displayStyle, required, defaultRatePlan.
const schema = z.object({ productId: z.string().min(1, "productId is required"), companyIntegrationId: z.number().int().positive(), productIdExternal: z.string().min(1, "external productId is required"), modifierDisplayName: z.string().min(1, "modifierDisplayName is required"), displayStyle: z.string().optional(), required: z.boolean().optional(), defaultRatePlan: z.string().optional(), }); - src/tools/products/index.ts:15-25 (registration)Registration of linkExternalProductTool in the registerProductTools array, which is called by the main tool registry.
/** All 8 product tools. Register with the main tool registry. */ export function registerProductTools(): Tool[] { return [ listProductsTool, getProductTool, createProductTool, updateProductTool, deleteProductTool, updateProductStatusTool, linkExternalProductTool, unlinkExternalProductTool, - The service function that makes the actual HTTP POST call to /products/{productId}/external-products with the link body.
export async function linkExternalProduct( client: Client, productId: string, body: LinkExternalProductBody ): Promise<unknown> { return client.post<unknown>(`/products/${productId}/external-products`, body); } - TypeScript interface for the LinkExternalProductBody used in the service call.
export interface LinkExternalProductBody { companyIntegrationId: number; productId: string; settings: { modifierDisplayName: string; [k: string]: unknown }; displayStyle?: string; required?: boolean; defaultRatePlan?: string; modifierDiscountRules?: unknown; }