deleteProduct
Remove products from the Omnisend catalog using unique identifiers to maintain accurate product listings and inventory management.
Instructions
Remove a product from the Omnisend catalog by its unique identifier.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/products/index.ts:182-200 (handler)The handler function for the 'deleteProduct' MCP tool. It invokes the underlying deleteProduct API helper with the provided productId and returns a success or error message.async (args) => { try { const success = await deleteProduct(args.productId); return { content: [ { type: "text", text: success ? "Product deleted successfully" : "Failed to delete product" } ] }; } catch (error) { if (error instanceof Error) { return { content: [{ type: "text", text: `Error: ${error.message}` }] }; } return { content: [{ type: "text", text: "An unknown error occurred" }] }; } }
- src/tools/products/index.ts:174-181 (schema)The input schema definition for the 'deleteProduct' tool, specifying the required 'productId' parameter.{ additionalProperties: false, properties: { productId: { description: "Product ID", type: "string" } }, required: ["productId"], type: "object" },
- src/tools/products/index.ts:171-201 (registration)The registration of the 'deleteProduct' tool using server.tool(), including name, description, schema, and handler.server.tool( "deleteProduct", "Remove a product from the Omnisend catalog by its unique identifier.", { additionalProperties: false, properties: { productId: { description: "Product ID", type: "string" } }, required: ["productId"], type: "object" }, async (args) => { try { const success = await deleteProduct(args.productId); return { content: [ { type: "text", text: success ? "Product deleted successfully" : "Failed to delete product" } ] }; } catch (error) { if (error instanceof Error) { return { content: [{ type: "text", text: `Error: ${error.message}` }] }; } return { content: [{ type: "text", text: "An unknown error occurred" }] }; } } );
- Helper function that performs the actual DELETE API call to Omnisend's /products/{productId} endpoint and returns true if status is 204.export const deleteProduct = async (productId: string): Promise<boolean> => { try { const response = await omnisendApi.delete(`/products/${productId}`); return response.status === 204; } catch (error) { if (error instanceof Error) { throw new Error(`Error deleting product: ${error.message}`); } else { throw new Error('Unknown error occurred when deleting product'); } } };