deleteCategory
Remove a product category from the Omnisend catalog using its unique identifier to maintain organized product listings.
Instructions
Remove a product category from the Omnisend catalog by its unique identifier.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/categories/index.ts:176-195 (handler)Handler function that executes the deleteCategory tool: invokes the API deleteCategory with the provided categoryId and returns a textual success or error response.async (args) => { try { const success = await deleteCategory(args.categoryId); return { content: [ { type: "text", text: success ? "Category deleted successfully" : "Failed to delete category" } ] }; } catch (error) { if (error instanceof Error) { return { content: [{ type: "text", text: `Error: ${error.message}` }] }; } return { content: [{ type: "text", text: "An unknown error occurred" }] }; } } );
- Input schema for the deleteCategory tool, specifying the required categoryId parameter.{ additionalProperties: false, properties: { categoryId: { description: "Category ID", type: "string" } }, required: ["categoryId"], type: "object" },
- src/tools/categories/index.ts:166-195 (registration)Registration of the deleteCategory MCP tool using server.tool(), including name, description, input schema, and handler function."deleteCategory", "Remove a product category from the Omnisend catalog by its unique identifier.", { additionalProperties: false, properties: { categoryId: { description: "Category ID", type: "string" } }, required: ["categoryId"], type: "object" }, async (args) => { try { const success = await deleteCategory(args.categoryId); return { content: [ { type: "text", text: success ? "Category deleted successfully" : "Failed to delete category" } ] }; } catch (error) { if (error instanceof Error) { return { content: [{ type: "text", text: `Error: ${error.message}` }] }; } return { content: [{ type: "text", text: "An unknown error occurred" }] }; } } );
- API helper function implementing the core delete logic by sending a DELETE request to the Omnisend /product-categories/{categoryId} endpoint.export const deleteCategory = async (categoryId: string): Promise<boolean> => { try { const response = await omnisendApi.delete(`/product-categories/${categoryId}`); return response.status === 204; } catch (error) { if (error instanceof Error) { throw new Error(`Error deleting category: ${error.message}`); } else { throw new Error('Unknown error occurred when deleting category'); } } };