Skip to main content
Glama
XeroAPI

Xero MCP Server

Official

create-timesheet

Create payroll timesheets in Xero by specifying employee details, calendar periods, and work hours to track and manage employee time for accurate payroll processing.

Instructions

Create a new payroll timesheet in Xero. This allows you to specify details such as the employee ID, payroll calendar ID, start and end dates, and timesheet lines.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
payrollCalendarIDYesThe ID of the payroll calendar.
employeeIDYesThe ID of the employee.
startDateYesThe start date of the timesheet period (YYYY-MM-DD).
endDateYesThe end date of the timesheet period (YYYY-MM-DD).
timesheetLinesNoThe lines of the timesheet.

Implementation Reference

  • The primary handler function that handles the creation of a Xero payroll timesheet, including error handling and calling the inner API function.
    export async function createXeroPayrollTimesheet(timesheet: Timesheet): Promise< XeroClientResponse<Timesheet | null> > { try { const newTimesheet = await createTimesheet(timesheet); return { result: newTimesheet, isError: false, error: null, }; } catch (error) { return { result: null, isError: true, error: formatError(error), }; } }
  • Zod schema defining the input parameters for the 'create-timesheet' tool.
    { payrollCalendarID: z.string().describe("The ID of the payroll calendar."), employeeID: z.string().describe("The ID of the employee."), startDate: z.string().describe("The start date of the timesheet period (YYYY-MM-DD)."), endDate: z.string().describe("The end date of the timesheet period (YYYY-MM-DD)."), timesheetLines: z .array( 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)."), }) ) .optional() .describe("The lines of the timesheet."), },
  • The 'create-timesheet' tool is registered by including CreatePayrollTimesheetTool in the CreateTools export array.
    export const CreateTools = [ CreateContactTool, CreateCreditNoteTool, CreateManualJournalTool, CreateInvoiceTool, CreateQuoteTool, CreatePaymentTool, CreateItemTool, CreateBankTransactionTool, CreatePayrollTimesheetTool, CreateTrackingCategoryTool, CreateTrackingOptionsTool ];
  • Tool definition using CreateXeroTool helper, naming it 'create-timesheet', providing schema, description, and wrapper logic around the handler.
    const CreatePayrollTimesheetTool = CreateXeroTool( "create-timesheet", `Create a new payroll timesheet in Xero. This allows you to specify details such as the employee ID, payroll calendar ID, start and end dates, and timesheet lines.`, { payrollCalendarID: z.string().describe("The ID of the payroll calendar."), employeeID: z.string().describe("The ID of the employee."), startDate: z.string().describe("The start date of the timesheet period (YYYY-MM-DD)."), endDate: z.string().describe("The end date of the timesheet period (YYYY-MM-DD)."), timesheetLines: z .array( 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)."), }) ) .optional() .describe("The lines of the timesheet."), }, async (params: Timesheet) => { const response = await createXeroPayrollTimesheet(params); if (response.isError) { return { content: [ { type: "text" as const, text: `Error creating timesheet: ${response.error}`, }, ], }; } const timesheet = response.result; return { content: [ { type: "text" as const, text: `Successfully created timesheet with ID: ${timesheet?.timesheetID}`, }, ], }; }, );

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