delete-timesheet
Remove a payroll timesheet from Xero using its unique identifier to correct errors or update records.
Instructions
Delete an existing payroll timesheet in Xero by its ID.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| timesheetID | Yes | The ID of the timesheet to delete. |
Implementation Reference
- Core handler that deletes the payroll timesheet via Xero PayrollNZ API, handling errors and returning structured response.export async function deleteXeroPayrollTimesheet(timesheetID: string): Promise< XeroClientResponse<boolean> > { try { await deleteTimesheet(timesheetID); return { result: true, isError: false, error: null, }; } catch (error) { return { result: null, isError: true, error: formatError(error), }; } }
- Input schema for the delete-timesheet tool using Zod.{ timesheetID: z.string().describe("The ID of the timesheet to delete."), },
- src/tools/delete/delete-payroll-timesheet.tool.ts:8-38 (registration)Defines and exports the MCP tool 'delete-timesheet' with name, description, schema, and wrapper handler.const DeletePayrollTimesheetTool = CreateXeroTool( "delete-timesheet", `Delete an existing payroll timesheet in Xero by its ID.`, { timesheetID: z.string().describe("The ID of the timesheet to delete."), }, async (params: { timesheetID: string }) => { const { timesheetID } = params; const response = await deleteXeroPayrollTimesheet(timesheetID); if (response.isError) { return { content: [ { type: "text" as const, text: `Error deleting timesheet: ${response.error}`, }, ], }; } return { content: [ { type: "text" as const, text: `Successfully deleted timesheet with ID: ${timesheetID}`, }, ], }; }, );
- Low-level helper function that authenticates and calls the Xero API to delete the timesheet.async function deleteTimesheet(timesheetID: string): Promise<boolean> { await xeroClient.authenticate(); // Call the deleteTimesheet endpoint from the PayrollNZApi await xeroClient.payrollNZApi.deleteTimesheet(xeroClient.tenantId, timesheetID); return true; }