delete_invoice
Delete an invoice by its ID. Use this to remove incorrect or unwanted invoices from the billing system.
Instructions
Delete an invoice. DELETE /invoices/{invoiceId}.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| invoiceId | Yes | Invoice ID (required) |
Implementation Reference
- The handler function for delete_invoice. Parses args via Zod schema, then calls invoiceService.deleteInvoice.
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.message).join("; ")); } return handleToolCall(() => invoiceService.deleteInvoice(client, parsed.data.invoiceId)); } - Zod input schema requiring invoiceId (string, min length 1).
const schema = z.object({ invoiceId: z.string().min(1, "invoiceId is required"), }); - Tool definition/inputSchema for delete_invoice, declaring invoiceId as required string.
const definition = { name: "delete_invoice", description: "Delete an invoice. DELETE /invoices/{invoiceId}.", inputSchema: { type: "object" as const, properties: { invoiceId: { type: "string", description: "Invoice ID (required)" }, }, required: ["invoiceId"], }, }; - src/tools/invoices/index.ts:9-37 (registration)Import and export of deleteInvoiceTool in the invoices index. Registered at line 22 in registerInvoiceTools().
import { deleteInvoiceTool } from "./deleteInvoice.js"; import { getInvoiceTool } from "./getInvoice.js"; import { listInvoicesTool } from "./listInvoices.js"; import { updateInvoiceTool } from "./updateInvoice.js"; import { voidInvoiceTool } from "./voidInvoice.js"; /** All 8 invoice tools. */ export function registerInvoiceTools(): Tool[] { return [ listInvoicesTool, getInvoiceTool, createInvoiceTool, updateInvoiceTool, deleteInvoiceTool, chargeInvoiceTool, chargeInvoiceExternalTool, voidInvoiceTool, ]; } export { listInvoicesTool } from "./listInvoices.js"; export { getInvoiceTool } from "./getInvoice.js"; export { createInvoiceTool } from "./createInvoice.js"; export { updateInvoiceTool } from "./updateInvoice.js"; export { deleteInvoiceTool } from "./deleteInvoice.js"; export { chargeInvoiceTool } from "./chargeInvoice.js"; export { chargeInvoiceExternalTool } from "./chargeInvoiceExternal.js"; export { voidInvoiceTool } from "./voidInvoice.js"; - deleteInvoice service function: sends DELETE /invoices/{invoiceId} and returns result or fallback success message.
export async function deleteInvoice( client: Client, invoiceId: string ): Promise<Record<string, unknown>> { const result = await client.delete<Record<string, unknown>>(`/invoices/${invoiceId}`); return Object.keys(result ?? {}).length ? result : { success: true, message: "Invoice deleted" }; }