manage_product
Create, update, or delete digital products on the402.ai marketplace. Manage one-time purchasable files, datasets, and templates as a provider using API authentication.
Instructions
Create, update, or delete a digital product on the402.ai as a provider. Products are one-time purchasable digital goods (files, datasets, templates). Requires API key (provider account).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | create = new product, update = modify existing, delete = remove | |
| product_id | No | Product ID (required for update/delete) | |
| name | No | Product name (required for create) | |
| description | No | Product description (required for create) | |
| price | No | Price in USD (required for create) | |
| category | No | Product category |
Implementation Reference
- src/tools/products.ts:46-116 (handler)The `manage_product` tool handles create, update, and delete actions for digital products by calling the appropriate client auth methods.
server.tool( "manage_product", "Create, update, or delete a digital product on the402.ai as a provider. Products are one-time purchasable digital goods (files, datasets, templates). Requires API key (provider account).", { action: z .enum(["create", "update", "delete"]) .describe( "create = new product, update = modify existing, delete = remove" ), product_id: z .string() .optional() .describe("Product ID (required for update/delete)"), name: z .string() .optional() .describe("Product name (required for create)"), description: z .string() .optional() .describe("Product description (required for create)"), price: z .string() .optional() .describe("Price in USD (required for create)"), category: z.string().optional().describe("Product category"), }, async ({ action, product_id, name, description, price, category }) => { if (action === "delete") { if (!product_id) throw new Error("product_id is required for delete"); const result = await client.authDelete(`/v1/products/${product_id}`); return { content: [ { type: "text" as const, text: JSON.stringify(result, null, 2) }, ], }; } if (action === "update") { if (!product_id) throw new Error("product_id is required for update"); const body: Record<string, unknown> = {}; if (name) body.name = name; if (description) body.description = description; if (price) body.price = price; if (category) body.category = category; const result = await client.authPut(`/v1/products/${product_id}`, body); return { content: [ { type: "text" as const, text: JSON.stringify(result, null, 2) }, ], }; } // create if (!name || !description || !price) throw new Error( "name, description, and price are required to create a product" ); const body: Record<string, unknown> = { name, description, price }; if (category) body.category = category; // Note: file upload requires multipart — for CLI creation, product metadata only. // File can be uploaded separately via the dashboard. const result = await client.authPost("/v1/products", body); return { content: [ { type: "text" as const, text: JSON.stringify(result, null, 2) }, ], }; } );