Skip to main content
Glama
XeroAPI

Xero MCP Server

Official

update-timesheet-line

Modify an existing payroll timesheet line in Xero by updating details like earnings rate, units worked, and date for accurate time tracking.

Instructions

Update an existing timesheet line in a payroll timesheet in Xero.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
timesheetIDYesThe ID of the timesheet to update.
timesheetLineIDYesThe ID of the timesheet line to update.
timesheetLineYesThe details of the timesheet line to update.

Implementation Reference

  • The primary handler function that wraps the API call, handles errors, and returns a standardized response.
    export async function updateXeroPayrollTimesheetUpdateLine( timesheetID: string, timesheetLineID: string, timesheetLine: TimesheetLine ): Promise<XeroClientResponse<TimesheetLine | null>> { try { const updatedLine = await updateTimesheetLine(timesheetID, timesheetLineID, timesheetLine); return { result: updatedLine, isError: false, error: null, }; } catch (error) { return { result: null, isError: true, error: formatError(error), }; } }
  • Helper function that authenticates the Xero client and performs the actual API call to update the timesheet line.
    async function updateTimesheetLine( timesheetID: string, timesheetLineID: string, timesheetLine: TimesheetLine ): Promise<TimesheetLine | null> { await xeroClient.authenticate(); // Call the updateTimesheetLine endpoint from the PayrollNZApi const updatedLine = await xeroClient.payrollNZApi.updateTimesheetLine( xeroClient.tenantId, timesheetID, timesheetLineID, timesheetLine, ); return updatedLine.body.timesheetLine ?? null; }
  • Zod schema defining the input parameters: timesheetID, timesheetLineID, and timesheetLine object.
    timesheetID: z.string().describe("The ID of the timesheet to update."), timesheetLineID: z.string().describe("The ID of the timesheet line to update."), timesheetLine: z.object({ earningsRateID: z.string().describe("The ID of the earnings rate."), numberOfUnits: z.number().describe("The number of units for the timesheet line."), date: z.string().describe("The date for the timesheet line (YYYY-MM-DD)."), }).describe("The details of the timesheet line to update."), },
  • Registers the tool by including UpdatePayrollTimesheetLineTool in the UpdateTools array, which is later registered to the MCP server.
    export const UpdateTools = [ UpdateContactTool, UpdateCreditNoteTool, UpdateInvoiceTool, UpdateManualJournalTool, UpdateQuoteTool, UpdateItemTool, UpdateBankTransactionTool, ApprovePayrollTimesheetTool, AddTimesheetLineTool, UpdatePayrollTimesheetLineTool, RevertPayrollTimesheetTool, UpdateTrackingCategoryTool, UpdateTrackingOptionsTool ];
  • Final MCP server registration: calls server.tool for each tool in UpdateTools, including 'update-timesheet-line'.
    UpdateTools.map((tool) => tool()).forEach((tool) => server.tool(tool.name, tool.description, tool.schema, tool.handler), );

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/XeroAPI/xero-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server