create_product_set
Create a product set within a catalog by providing a name and optional JSON filter rules to organize products.
Instructions
Create a new product set within a catalog.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| catalog_id | Yes | Product catalog ID | |
| name | Yes | Product set name | |
| filter | No | JSON string of filter rules for the product set |
Implementation Reference
- src/tools/catalogs.ts:99-116 (handler)The handler function that creates a new product set by POSTing to /{catalog_id}/product_sets with name and optional filter parameters.
// ─── create_product_set ──────────────────────────────────── server.tool( "create_product_set", "Create a new product set within a catalog.", { catalog_id: z.string().describe("Product catalog ID"), name: z.string().describe("Product set name"), filter: z.string().optional().describe("JSON string of filter rules for the product set"), }, async ({ catalog_id, ...params }) => { try { const { data, rateLimit } = await client.post(`/${catalog_id}/product_sets`, { ...params }); return { content: [{ type: "text" as const, text: JSON.stringify({ ...data as object, _rateLimit: rateLimit }, null, 2) }] }; } catch (error) { return { content: [{ type: "text" as const, text: `Failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } ); - src/tools/catalogs.ts:103-107 (schema)Zod schema defining the input parameters for create_product_set: catalog_id (required), name (required), filter (optional JSON string).
{ catalog_id: z.string().describe("Product catalog ID"), name: z.string().describe("Product set name"), filter: z.string().optional().describe("JSON string of filter rules for the product set"), }, - src/tools/catalogs.ts:100-116 (registration)Registration of the tool via server.tool() call inside registerCatalogTools function.
server.tool( "create_product_set", "Create a new product set within a catalog.", { catalog_id: z.string().describe("Product catalog ID"), name: z.string().describe("Product set name"), filter: z.string().optional().describe("JSON string of filter rules for the product set"), }, async ({ catalog_id, ...params }) => { try { const { data, rateLimit } = await client.post(`/${catalog_id}/product_sets`, { ...params }); return { content: [{ type: "text" as const, text: JSON.stringify({ ...data as object, _rateLimit: rateLimit }, null, 2) }] }; } catch (error) { return { content: [{ type: "text" as const, text: `Failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } ); - src/index.ts:8-21 (registration)Import of registerCatalogTools from catalogs.ts, which registers create_product_set among other catalog tools.
// --- Tool imports --- import { registerCampaignTools } from "./tools/campaigns.js"; import { registerAdsetTools } from "./tools/adsets.js"; import { registerAdTools } from "./tools/ads.js"; import { registerCreativeTools } from "./tools/creatives.js"; import { registerImageTools } from "./tools/images.js"; import { registerVideoTools } from "./tools/videos.js"; import { registerCanvasTools } from "./tools/canvas.js"; import { registerAudienceTools } from "./tools/audiences.js"; import { registerTargetingTools } from "./tools/targeting.js"; import { registerInsightTools } from "./tools/insights.js"; import { registerLeadTools } from "./tools/leads.js"; import { registerCatalogTools } from "./tools/catalogs.js"; - src/index.ts:71-71 (registration)Invocation of registerCatalogTools during server initialization, making create_product_set available.
registerCatalogTools(server, client);