Official

Gusto

Let agents read payroll, employees, contractors, benefits, time off and accounting reports. Write access also permits employee and benefit changes, time sheets and draft payroll edits.

Agents cannot submit payroll or pay people directly. Changes to pay and draft payrolls affect the next payroll, including Payroll on AutoPilot.

Each connection serves one company. A primary or full-access admin must connect it; Gusto's app permissions still apply.

Connect Gusto.

Setup instructions

Connect Gusto

You need to be the primary admin or a full-access admin of the company in Gusto.

  1. Choose Read or Write for Access.
  2. Select Authorize connection and sign in with your Gusto account.
  3. If you manage several companies, pick the one to connect, then allow access.

Each connection reaches one company: add another connection for each additional company. Houston keeps the connection signed in. If requests start failing with an authorization error, select Set up again and sign in.

Advanced

Use your own Gusto app

Turn on Use your own Gusto app to connect through an app you register with Gusto. New apps work only in Gusto's demo environment, which has sample companies, until Gusto approves them for production; Gusto approves only App Integration partners.

  1. Sign up at the Gusto Developer Portal and create or join an organization.
  2. Open Applications, click Create application, and add Houston's displayed callback URL as a redirect URI.
  3. Copy the app's client ID and secret into Gusto OAuth client ID and Gusto OAuth client secret in Houston.
  4. In the Developer Portal, create a demo company. In Houston, choose Connect with your Gusto demo app under Connect using, then select Authorize connection and sign in with that demo company's admin.

Once Gusto approves the app for production, enter its production client ID and secret, select Set up again and sign in with Connect with your Gusto app. Gusto assigns the app's permissions (scopes) during its review; ask [email protected] to change them. See Gusto's app integration guide.

Troubleshooting

  • missing_oauth_scopes: the app lacks the permission that data needs, such as compensations for pay rates. The demo environment doesn't enforce scopes; production does.
  • missing_permissions: the request is a Gusto Embedded feature that app integrations can't use.
  • Unauthorized: the sign-in ended or a Gusto admin disconnected the app. Select Set up again and sign in.

Files

  • connector.luau
    -- Gusto App Integrations API, X-Gusto-API-Version 2026-06-15. Arguments and results keep Gusto's native snake_case field names.
    type Options = {[string]: any}
    type Endpoint = {
    	method: string, path: string, query: {string}?, extra: {string}?, required: {string}?, allow: {string}?,
    	access: string?, body: (boolean | string)?, doc: string, about: string,
    }
    
    local PROVIDER = "Gusto"
    local API = if auth.method == "demo" then "https://api.gusto-demo.com" else "https://api.gusto.com"
    local VERSION = "2026-06-15"
    local DOCS = "https://docs.gusto.com/app-integrations/reference/"
    local PAGE = {"page", "per"}
    
    -- The company-token operations of Gusto's App Integrations reference
    -- (https://docs.gusto.com/app-integrations/reference), checked on 2026-10-21.
    -- Path {fields} are required; listed query fields are taken from the options and the other
    -- fields form the JSON body of POST, PUT and PATCH requests, limited to allow when it is listed.
    -- Webhooks, events and salary estimate occupations need an app-level system token, so the
    -- salary estimates built on those occupations are absent too; running payroll and paying
    -- contractors are Gusto Embedded features. The company's contractor-only flag and the
    -- duplicate GET /v1/terminations/{employee_id} are left out.
    local endpoints: {[string]: Endpoint} = {
    	getTokenInfo = {method = "GET", path = "/v1/token_info",
    		doc = "get-v1-token-info", about = "{scope, resource={type='Company', uuid}, resource_owner={type, uuid}}; resource.uuid is the connected company's company_id."},
    
    	getCompany = {method = "GET", path = "/v1/companies/{company_id}", doc = "get-v1-companies", about = "Name, EIN, entity type, locations and compensation settings."},
    	listCompanyAdmins = {method = "GET", path = "/v1/companies/{company_id}/admins", query = PAGE, doc = "get-v1-companies-company_id-admins", about = ""},
    	listCompanyCustomFields = {method = "GET", path = "/v1/companies/{company_id}/custom_fields", query = PAGE, doc = "get-v1-companies-company_id-custom_fields", about = ""},
    	listLocations = {method = "GET", path = "/v1/companies/{company_id}/locations", query = PAGE, doc = "get-v1-companies-company_id-locations", about = ""},
    	createLocation = {method = "POST", path = "/v1/companies/{company_id}/locations", access = "data:write", required = {"street_1", "city", "state", "zip", "phone_number"},
    		doc = "post-v1-companies-company_id-locations", about = "Also street_2, country, mailing_address, filing_address."},
    	getLocation = {method = "GET", path = "/v1/locations/{location_id}", doc = "get-v1-locations-location_id", about = ""},
    	updateLocation = {method = "PUT", path = "/v1/locations/{location_id}", access = "data:write", required = {"version"}, doc = "put-v1-locations-location_id", about = ""},
    	listMinimumWages = {method = "GET", path = "/v1/locations/{location_id}/minimum_wages", query = {"effective_date"}, doc = "get-v1-locations-location_uuid-minimum_wages", about = ""},
    
    	listDepartments = {method = "GET", path = "/v1/companies/{company_id}/departments", doc = "get-companies-departments", about = "With their employees and contractors."},
    	createDepartment = {method = "POST", path = "/v1/companies/{company_id}/departments", access = "data:write", required = {"title"}, doc = "post-departments", about = ""},
    	getDepartment = {method = "GET", path = "/v1/departments/{department_uuid}", doc = "get-department", about = ""},
    	updateDepartment = {method = "PUT", path = "/v1/departments/{department_uuid}", access = "data:write", required = {"title", "version"}, doc = "put-departments", about = ""},
    	deleteDepartment = {method = "DELETE", path = "/v1/departments/{department_uuid}", access = "data:write", doc = "delete-department", about = "Only an empty department."},
    	addDepartmentPeople = {method = "PUT", path = "/v1/departments/{department_uuid}/add", access = "data:write", required = {"version"},
    		doc = "put-add-people-to-department", about = "Also employees={{uuid}}, contractors={{uuid}}."},
    	removeDepartmentPeople = {method = "PUT", path = "/v1/departments/{department_uuid}/remove", access = "data:write", required = {"version"},
    		doc = "put-remove-people-from-department", about = "Also employees={{uuid}}, contractors={{uuid}}."},
    
    	listEmployees = {method = "GET", path = "/v1/companies/{company_id}/employees",
    		query = {"search_term", "sort_by", "include", "location_uuid", "payroll_uuid", "onboarded", "onboarded_active", "terminated", "terminated_today", "uuids", "page", "per"},
    		doc = "get-v1-companies-company_id-employees", about = "include: all_compensations, all_home_addresses, company_name, current_home_address, custom_fields or portal_invitations."},
    	createEmployee = {method = "POST", path = "/v1/companies/{company_id}/employees", access = "data:write", required = {"first_name", "last_name"},
    		doc = "post-v1-employees", about = "Also middle_initial, preferred_first_name, email, date_of_birth, ssn, self_onboarding. Starts onboarding."},
    	getEmployee = {method = "GET", path = "/v1/employees/{employee_id}", query = {"include"}, doc = "get-v1-employees", about = "With jobs; pay rates need the compensations scope."},
    	updateEmployee = {method = "PUT", path = "/v1/employees/{employee_id}", access = "data:write", required = {"version"}, doc = "put-v1-employees", about = ""},
    	deleteEmployee = {method = "DELETE", path = "/v1/employees/{employee_id}", access = "data:write", doc = "delete-v1-employee", about = "Only an employee who hasn't finished onboarding; terminate the others."},
    	listEmployeeCustomFields = {method = "GET", path = "/v1/employees/{employee_id}/custom_fields", query = PAGE, doc = "get-v1-employees-employee_id-custom_fields", about = ""},
    	getEmploymentHistory = {method = "GET", path = "/v1/employees/{employee_id}/employment_history", doc = "get-v1-employees-employee_id-employment_history", about = "Hire and termination dates."},
    	listTerminations = {method = "GET", path = "/v1/employees/{employee_id}/terminations", doc = "get-v1-employees-employee_id-terminations", about = ""},
    	createTermination = {method = "POST", path = "/v1/employees/{employee_id}/terminations", access = "data:write", required = {"effective_date"},
    		doc = "post-v1-employees-employee_id-terminations", about = "Also run_termination_payroll. Ends the employment on that date."},
    	updateTermination = {method = "PUT", path = "/v1/terminations/{employee_id}", access = "data:write", required = {"effective_date", "version"}, doc = "put-v1-terminations-employee_id", about = ""},
    	deleteTermination = {method = "DELETE", path = "/v1/employees/{employee_id}/terminations", access = "data:write", doc = "delete-v1-employees-employee_id-terminations", about = "Cancels a termination that hasn't taken effect."},
    	getRehire = {method = "GET", path = "/v1/employees/{employee_id}/rehire", doc = "get-v1-employees-employee_id-rehire", about = "nil when no rehire is scheduled."},
    	createRehire = {method = "POST", path = "/v1/employees/{employee_id}/rehire", access = "data:write", required = {"effective_date", "file_new_hire_report", "work_location_uuid"}, doc = "post-v1-employees-employee_id-rehire", about = ""},
    	updateRehire = {method = "PUT", path = "/v1/employees/{employee_id}/rehire", access = "data:write", required = {"effective_date", "file_new_hire_report", "work_location_uuid", "version"}, doc = "put-v1-employees-employee_id-rehire", about = ""},
    	deleteRehire = {method = "DELETE", path = "/v1/employees/{employee_id}/rehire", access = "data:write", doc = "delete-v1-employees-employee_id-rehire", about = "Cancels a rehire that hasn't taken effect."},
    	listHomeAddresses = {method = "GET", path = "/v1/employees/{employee_id}/home_addresses", doc = "get-v1-employees-employee_id-home_addresses", about = ""},
    	createHomeAddress = {method = "POST", path = "/v1/employees/{employee_id}/home_addresses", access = "data:write",
    		doc = "post-v1-employees-employee_id-home_addresses", about = "Body {street_1, street_2?, city, state, zip, effective_date?, courtesy_withholding?}."},
    	getHomeAddress = {method = "GET", path = "/v1/home_addresses/{home_address_uuid}", doc = "get-v1-home_addresses-home_address_uuid", about = ""},
    	updateHomeAddress = {method = "PUT", path = "/v1/home_addresses/{home_address_uuid}", access = "data:write", required = {"version"}, doc = "put-v1-home_addresses-home_address_uuid", about = ""},
    	deleteHomeAddress = {method = "DELETE", path = "/v1/home_addresses/{home_address_uuid}", access = "data:write", doc = "delete-v1-home_addresses-home_address_uuid", about = ""},
    	listWorkAddresses = {method = "GET", path = "/v1/employees/{employee_id}/work_addresses", doc = "get-v1-employees-employee_id-work_addresses", about = ""},
    	createWorkAddress = {method = "POST", path = "/v1/employees/{employee_id}/work_addresses", access = "data:write",
    		doc = "post-v1-employees-employee_id-work_addresses", about = "Body {location_uuid, effective_date?}."},
    	getWorkAddress = {method = "GET", path = "/v1/work_addresses/{work_address_uuid}", doc = "get-v1-work_addresses-work_address_uuid", about = ""},
    	updateWorkAddress = {method = "PUT", path = "/v1/work_addresses/{work_address_uuid}", access = "data:write", required = {"version"}, doc = "put-v1-work_addresses-work_address_uuid", about = ""},
    	deleteWorkAddress = {method = "DELETE", path = "/v1/work_addresses/{work_address_uuid}", access = "data:write", doc = "delete-v1-work_addresses-work_address_uuid", about = ""},
    
    	listCompensations = {method = "GET", path = "/v1/jobs/{job_id}/compensations", query = {"include", "page", "per"},
    		doc = "get-v1-jobs-job_id-compensations", about = "job_id comes from an employee's jobs; include='all_compensations' adds past and future rates."},
    	createCompensation = {method = "POST", path = "/v1/jobs/{job_id}/compensations", access = "data:write", required = {"rate", "payment_unit", "flsa_status"},
    		doc = "post-v1-compensations-compensation_id", about = "rate is a string; payment_unit Hour, Week, Month, Year or Paycheck. Also effective_date, adjust_for_minimum_wage."},
    	getCompensation = {method = "GET", path = "/v1/compensations/{compensation_id}", doc = "get-v1-compensations-compensation_id", about = ""},
    	updateCompensation = {method = "PUT", path = "/v1/compensations/{compensation_id}", access = "data:write", required = {"version"}, doc = "put-v1-compensations-compensation_id", about = ""},
    	deleteCompensation = {method = "DELETE", path = "/v1/compensations/{compensation_id}", access = "data:write", doc = "delete-v1-compensations-compensation_id", about = "Only a compensation not yet paid on a payroll."},
    
    	listContractors = {method = "GET", path = "/v1/companies/{company_id}/contractors",
    		query = {"search_term", "sort_by", "include", "onboarded", "onboarded_active", "terminated", "terminated_today", "page", "per"}, doc = "get-v1-companies-company_uuid-contractors", about = ""},
    	createContractor = {method = "POST", path = "/v1/companies/{company_id}/contractors", access = "data:write", required = {"type", "wage_type", "start_date"},
    		doc = "post-v1-companies-company_uuid-contractors", about = "type Individual or Business; wage_type Fixed or Hourly. Also first_name, last_name, business_name, email, hourly_rate, self_onboarding."},
    	getContractor = {method = "GET", path = "/v1/contractors/{contractor_uuid}", query = {"include"}, doc = "get-v1-contractors-contractor_uuid", about = ""},
    	updateContractor = {method = "PUT", path = "/v1/contractors/{contractor_uuid}", access = "data:write", required = {"version"}, doc = "put-v1-contractors-contractor_uuid", about = ""},
    
    	listPaySchedules = {method = "GET", path = "/v1/companies/{company_id}/pay_schedules", query = PAGE, doc = "get-v1-companies-company_id-pay_schedules", about = ""},
    	getPaySchedule = {method = "GET", path = "/v1/companies/{company_id}/pay_schedules/{pay_schedule_id}", doc = "get-v1-companies-company_id-pay_schedules-pay_schedule_id", about = ""},
    	getPayScheduleAssignments = {method = "GET", path = "/v1/companies/{company_id}/pay_schedules/assignments",
    		doc = "get-v1-companies-company_id-pay_schedules-assignments", about = "Which pay schedule each employee follows."},
    	listPayPeriods = {method = "GET", path = "/v1/companies/{company_id}/pay_periods", query = {"start_date", "end_date", "payroll_types"},
    		doc = "get-v1-companies-company_id-pay_periods", about = "start_date defaults to 6 months ago; end_date at most 3 months ahead. Each period names its payroll's payroll_uuid."},
    	listUnprocessedTerminationPayPeriods = {method = "GET", path = "/v1/companies/{company_id}/pay_periods/unprocessed_termination_pay_periods", doc = "get-v1-companies-company_id-unprocessed_termination_pay_periods", about = ""},
    
    	listPayrolls = {method = "GET", path = "/v1/companies/{company_id}/payrolls",
    		query = {"processing_statuses", "payroll_types", "processed", "include_off_cycle", "include", "start_date", "end_date", "date_filter_by", "sort_order", "page", "per"},
    		doc = "get-v1-companies-company_id-payrolls", about = "Always paged (per up to 100). Defaults to processed regular payrolls of the past 6 months: pass processing_statuses={'unprocessed'} for drafts and payroll_types={'regular', 'off_cycle'} for off-cycle ones (also external). start_date and end_date span at most a year, ending at most 3 months ahead. include: totals, taxes, payroll_status_meta, risk_blockers, reversals."},
    	getPayroll = {method = "GET", path = "/v1/companies/{company_id}/payrolls/{payroll_id}", query = {"include", "sort_by", "page", "per"},
    		doc = "get-v1-companies-company_id-payrolls-payroll_id", about = "Gross and net pay, taxes and deductions per employee. Always pages employee_compensations (per default 25, up to 100) without totals: request the next page until fewer than per come back. include: benefits, deductions, taxes, payroll_taxes, payroll_status_meta, totals, risk_blockers, reversals."},
    	preparePayroll = {method = "PUT", path = "/v1/companies/{company_id}/payrolls/{payroll_id}/prepare", access = "data:write", query = {"sort_by", "page", "per"},
    		doc = "put-v1-companies-company_id-payrolls-payroll_id-prepare", about = "Readies an unprocessed payroll for editing and returns it with each employee_compensations entry's version, paged like getPayroll. Also employee_uuids (up to 100) to prepare only those employees, or add up to 25 to a Bonus, Correction or Adhoc off-cycle payroll. Clears any earlier calculation."},
    	updatePayroll = {method = "PUT", path = "/v1/companies/{company_id}/payrolls/{payroll_id}", access = "data:write", required = {"employee_compensations"},
    		doc = "put-v1-companies-company_id-payrolls", about = "employee_compensations={{employee_uuid, version, fixed_compensations?, hourly_compensations?, paid_time_off?, excluded?, memo?}}, up to 100, each version from preparePayroll. Also withholding_pay_period, skip_regular_deductions, fixed_withholding_rate. Changes the draft only; omitted entries stay."},
    	calculateAccruingTimeOffHours = {method = "POST", path = "/v1/payrolls/{payroll_id}/employees/{employee_id}/calculate_accruing_time_off_hours",
    		allow = {"regular_hours_worked", "overtime_hours_worked", "double_overtime_hours_worked", "pto_hours_used", "sick_hours_used"},
    		doc = "post-v1-payrolls-payroll_id-calculate_accruing_time_off_hours", about = "Computes only; body fields regular_hours_worked, overtime_hours_worked, double_overtime_hours_worked, pto_hours_used and sick_hours_used."},
    	listContractorPayments = {method = "GET", path = "/v1/companies/{company_id}/contractor_payments", query = {"start_date", "end_date", "contractor_uuid", "group_by_date", "page", "per"},
    		required = {"start_date", "end_date"}, doc = "get-v1-companies-company_id-contractor_payments", about = "Totals and payments in the date range."},
    	getContractorPayment = {method = "GET", path = "/v1/companies/{company_id}/contractor_payments/{contractor_payment_id}", doc = "get-v1-companies-company_id-contractor_payment-contractor-payment", about = ""},
    	listEarningTypes = {method = "GET", path = "/v1/companies/{company_id}/earning_types", doc = "get-v1-companies-company_id-earning_types", about = "{default, custom}."},
    	createEarningType = {method = "POST", path = "/v1/companies/{company_id}/earning_types", access = "data:write", required = {"name"},
    		doc = "post-v1-companies-company_id-earning_types", about = "A custom earning type for payroll fixed compensations."},
    	updateEarningType = {method = "PUT", path = "/v1/companies/{company_id}/earning_types/{earning_type_uuid}", access = "data:write",
    		doc = "put-v1-companies-company_id-earning_types-earning_type_uuid", about = "Body {name}."},
    	deleteEarningType = {method = "DELETE", path = "/v1/companies/{company_id}/earning_types/{earning_type_uuid}", access = "data:write",
    		doc = "delete-v1-companies-company_id-earning_types-earning_type_uuid", about = "Deactivates a custom earning type."},
    	createGeneralLedgerReport = {method = "POST", path = "/v1/payrolls/{payroll_uuid}/reports/general_ledger", required = {"aggregation"}, allow = {"aggregation", "integration_type"},
    		doc = "post-payrolls-payroll_uuid-reports-general_ledger", about = "aggregation default, job, department or integration, with integration_type (such as xero or qbo) for integration. Returns {request_uuid}; poll getReport until its status is succeeded or failed."},
    	getReport = {method = "GET", path = "/v1/reports/{request_uuid}",
    		doc = "get-reports-request_uuid", about = "{status, report_urls}: temporary download links; treat them as secrets."},
    
    	listTimeOffPolicies = {method = "GET", path = "/v1/companies/{company_id}/time_off_policies", doc = "get-v1-companies-company_uuid-time_off_policies", about = ""},
    	getTimeOffPolicy = {method = "GET", path = "/v1/time_off_policies/{time_off_policy_uuid}", doc = "get-v1-time_off_policies-time_off_policy_uuid", about = "With employee balances."},
    	addTimeOffPolicyEmployees = {method = "PUT", path = "/v1/time_off_policies/{time_off_policy_uuid}/add_employees", access = "data:write", required = {"employees"},
    		doc = "put-v1-time_off_policies-time_off_policy_uuid-add_employees", about = "employees={{uuid, balance?}}."},
    	listTimeOffRequests = {method = "GET", path = "/v1/companies/{company_id}/time_off_requests", query = {"start_date", "end_date"}, doc = "get-v1-companies-company_id-time_off_requests", about = ""},
    	listTimeOffActivities = {method = "GET", path = "/v1/employees/{employee_id}/time_off_activities", query = {"time_off_type"}, required = {"time_off_type"},
    		doc = "get-version-employees-time_off_activities", about = "time_off_type such as 'vacation' or 'sick'."},
    
    	listBenefits = {method = "GET", path = "/v1/benefits", doc = "get-v1-benefits", about = "Benefit types Gusto supports; benefit_id is a number."},
    	getBenefit = {method = "GET", path = "/v1/benefits/{benefit_id}", doc = "get-v1-benefits-benefit_id", about = ""},
    	getBenefitRequirements = {method = "GET", path = "/v1/benefits/{benefit_id}/requirements", doc = "get-v1-benefits-benefits_id-requirements", about = ""},
    	listCompanyBenefits = {method = "GET", path = "/v1/companies/{company_id}/company_benefits", query = {"active", "enrollment_count", "benefit_type"},
    		doc = "get-v1-companies-company_id-company_benefits", about = "benefit_type takes benefit type numbers."},
    	createCompanyBenefit = {method = "POST", path = "/v1/companies/{company_id}/company_benefits", access = "data:write", required = {"description"},
    		doc = "post-v1-companies-company_id-company_benefits", about = "Also benefit_type, active, responsible_for_employer_taxes, responsible_for_employee_w2."},
    	getCompanyBenefit = {method = "GET", path = "/v1/company_benefits/{company_benefit_id}", query = {"with_employee_benefits", "include"}, doc = "get-v1-company_benefits-company_benefit_id", about = ""},
    	updateCompanyBenefit = {method = "PUT", path = "/v1/company_benefits/{company_benefit_id}", access = "data:write", required = {"version"}, doc = "put-v1-company_benefits-company_benefit_id", about = ""},
    	deleteCompanyBenefit = {method = "DELETE", path = "/v1/company_benefits/{company_benefit_id}", access = "data:write",
    		doc = "delete-v1-company_benefits-company_benefit_id", about = "Only a benefit without employee enrollments or payroll history; otherwise set active=false."},
    	getCompanyBenefitSummary = {method = "GET", path = "/v1/company_benefits/{company_benefit_id}/summary", query = {"start_date", "end_date", "detailed"},
    		doc = "get-v1-benefits-company_benefit_id-summary", about = "Employee deductions and company contributions over the range."},
    	getContributionExclusions = {method = "GET", path = "/v1/company_benefits/{company_benefit_id}/contribution_exclusions", doc = "get-v1-company_benefits-company_benefit_id-contribution_exclusions", about = ""},
    	updateContributionExclusions = {method = "PUT", path = "/v1/company_benefits/{company_benefit_id}/contribution_exclusions", access = "data:write", required = {"contribution_exclusions"}, doc = "put-v1-company_benefits-company_benefit_id-contribution_exclusions", about = ""},
    	listCompanyBenefitEmployeeBenefits = {method = "GET", path = "/v1/company_benefits/{company_benefit_id}/employee_benefits", query = {"include", "page", "per"},
    		doc = "get-v1-company_benefits-company_benefit_id-employee_benefits", about = "Enrollments in one company benefit."},
    	updateCompanyBenefitEmployeeBenefits = {method = "PUT", path = "/v1/company_benefits/{company_benefit_id}/employee_benefits", access = "data:write", required = {"employee_benefits"},
    		doc = "put-v1-company_benefits-company_benefit_id-employee_benefits", about = "employee_benefits={{employee_uuid, ...}} creates or updates many enrollments."},
    	listEmployeeBenefits = {method = "GET", path = "/v1/employees/{employee_id}/employee_benefits", query = {"include", "page", "per"}, doc = "get-v1-employees-employee_id-employee_benefits", about = ""},
    	createEmployeeBenefit = {method = "POST", path = "/v1/employees/{employee_id}/employee_benefits", access = "data:write", required = {"company_benefit_uuid"},
    		doc = "post-v1-employees-employee_id-employee_benefits", about = "Also active, employee_deduction, company_contribution, deduct_as_percentage, effective_date and more. Enrolls the employee."},
    	getEmployeeBenefit = {method = "GET", path = "/v1/employee_benefits/{employee_benefit_id}", doc = "get-v1-employee_benefits-employee_benefit_id", about = ""},
    	updateEmployeeBenefit = {method = "PUT", path = "/v1/employee_benefits/{employee_benefit_id}", access = "data:write", required = {"version"}, doc = "put-v1-employee_benefits-employee_benefit_id", about = ""},
    	deleteEmployeeBenefit = {method = "DELETE", path = "/v1/employee_benefits/{employee_benefit_id}", access = "data:write", doc = "delete-v1-employee_benefits-employee_benefit_id", about = "Ends the enrollment."},
    	getYtdBenefitAmountsFromDifferentCompany = {method = "GET", path = "/v1/employees/{employee_id}/ytd_benefit_amounts_from_different_company", query = {"tax_year"},
    		doc = "get-employee-ytd-benefit-amounts-from-different-company", about = "Contributions made at a previous employer this year."},
    	createYtdBenefitAmountsFromDifferentCompany = {method = "POST", path = "/v1/employees/{employee_id}/ytd_benefit_amounts_from_different_company", access = "data:write",
    		required = {"benefit_type", "tax_year", "ytd_employee_deduction_amount", "ytd_company_contribution_amount"}, doc = "post-employee-ytd-benefit-amounts-from-different-company", about = ""},
    	listSection603HighEarnerStatuses = {method = "GET", path = "/v1/employees/{employee_id}/section603_high_earner_statuses",
    		doc = "get-v1-employees-employee_uuid-section603_high_earner_statuses", about = "Whether catch-up contributions must be Roth, per year."},
    	getSection603HighEarnerStatus = {method = "GET", path = "/v1/employees/{employee_id}/section603_high_earner_statuses/{effective_year}", doc = "get-v1-employees-employee_uuid-section603_high_earner_statuses-effective_year", about = ""},
    	createSection603HighEarnerStatus = {method = "POST", path = "/v1/employees/{employee_id}/section603_high_earner_statuses", access = "data:write", required = {"effective_year", "is_high_earner"}, doc = "post-v1-employees-employee_uuid-section603_high_earner_statuses", about = ""},
    	updateSection603HighEarnerStatus = {method = "PATCH", path = "/v1/employees/{employee_id}/section603_high_earner_statuses/{effective_year}", access = "data:write", required = {"is_high_earner"}, doc = "patch-v1-employees-employee_uuid-section603_high_earner_statuses-effective_year", about = ""},
    
    	listGarnishments = {method = "GET", path = "/v1/employees/{employee_id}/garnishments", query = PAGE, doc = "get-v1-employees-employee_id-garnishments", about = "Court-ordered and voluntary deductions."},
    	createGarnishment = {method = "POST", path = "/v1/employees/{employee_id}/garnishments", access = "data:write", required = {"amount", "court_ordered"},
    		doc = "post-v1-employees-employee_id-garnishments", about = "Also description, garnishment_type, recurring, deduct_as_percentage, annual_maximum and more."},
    	getGarnishment = {method = "GET", path = "/v1/garnishments/{garnishment_id}", doc = "get-v1-garnishments-garnishment_id", about = ""},
    	updateGarnishment = {method = "PUT", path = "/v1/garnishments/{garnishment_id}", access = "data:write", required = {"version"}, doc = "put-v1-garnishments-garnishment_id", about = ""},
    	getChildSupportData = {method = "GET", path = "/v1/garnishments/child_support", doc = "get-v1-garnishments-child_support", about = "Child support agencies and their required fields per state."},
    	listRecurringReimbursements = {method = "GET", path = "/v1/employees/{employee_id}/recurring_reimbursements", query = PAGE, doc = "get-v1-employees-employee_id-recurring_reimbursements", about = ""},
    	createRecurringReimbursement = {method = "POST", path = "/v1/employees/{employee_id}/recurring_reimbursements", access = "data:write", required = {"description", "amount"},
    		doc = "post-v1-employees-employee_id-recurring_reimbursements", about = "amount is a number. Paid on every regular payroll."},
    	getRecurringReimbursement = {method = "GET", path = "/v1/recurring_reimbursements/{id}", doc = "get-v1-recurring_reimbursements", about = ""},
    	updateRecurringReimbursement = {method = "PUT", path = "/v1/recurring_reimbursements/{id}", access = "data:write", required = {"version"}, doc = "put-v1-recurring_reimbursements", about = ""},
    	deleteRecurringReimbursement = {method = "DELETE", path = "/v1/recurring_reimbursements/{id}", access = "data:write", doc = "delete-v1-recurring_reimbursements", about = ""},
    
    	listTimeSheets = {method = "GET", path = "/v1/companies/{company_id}/time_tracking/time_sheets",
    		query = {"entity_type", "entity_uuids", "status", "after", "before", "sort_by", "sort_order", "page", "per"},
    		doc = "get-companies-company_uuid-time_tracking-time_sheets", about = "entity_type Employee or Contractor; status pending, approved or rejected; after/before filter created_at (ISO 8601)."},
    	createTimeSheet = {method = "POST", path = "/v1/companies/{company_id}/time_tracking/time_sheets", access = "data:write", required = {"entity_type", "entity_uuid", "shift_started_at", "time_zone"},
    		doc = "post-companies-company_uuid-time_tracking-time_sheets", about = "Also shift_ended_at, job_uuid, metadata, entries."},
    	getTimeSheet = {method = "GET", path = "/v1/time_tracking/time_sheets/{time_sheet_uuid}", doc = "get-time_tracking-time_sheets-time_sheet_uuid", about = ""},
    	updateTimeSheet = {method = "PUT", path = "/v1/time_tracking/time_sheets/{time_sheet_uuid}", access = "data:write", required = {"version"}, doc = "put-time_tracking-time_sheets-time_sheet_uuid", about = ""},
    	deleteTimeSheet = {method = "DELETE", path = "/v1/time_tracking/time_sheets/{time_sheet_uuid}", access = "data:write", query = {"version"}, required = {"version"}, doc = "delete-time_tracking-time_sheets-time_sheet_uuid", about = ""},
    	createPayrollSync = {method = "POST", path = "/v1/companies/{company_id}/time_tracking/payroll_syncs", access = "data:write", required = {"kind", "pay_schedule_uuid", "pay_period_start_date", "pay_period_end_date"},
    		doc = "post-companies-company_uuid-time_tracking-payroll_syncs", about = "Copies approved time sheets into that pay period's unprocessed payroll."},
    	getPayrollSync = {method = "GET", path = "/v1/time_tracking/payroll_syncs/{payroll_sync_uuid}", doc = "get-time_tracking-payroll_syncs-payroll_sync_uuid", about = ""},
    
    	listNotifications = {method = "GET", path = "/v1/companies/{company_id}/notifications", query = {"status", "page", "per"},
    		doc = "get-company-notifications", about = "Actions Gusto asks the company to take; status open, resolved or expired."},
    }
    
    -- Request layer shared verbatim by the endpoint-table connectors
    -- (tools/validate checks they match). It uses each connector's PROVIDER, DOCS and Endpoint type.
    local NULL = json.decode("null")
    local NONE: {string} = table.freeze({})
    
    local function options(input: Options?): Options
    	if input == nil then return {} end
    	assert(type(input) == "table", "opts must be an object")
    	for key in input do assert(type(key) == "string", "opts must have named fields") end
    	return table.clone(input)
    end
    
    local function scalar(value: any, field: string): string
    	local kind = type(value)
    	assert(kind == "string" or kind == "boolean" or kind == "number", field .. " must be a string, boolean, number or array of those")
    	return url.encode(value)
    end
    
    -- A query value's encoded parts: one for a scalar, one per item of a nonempty array. Each
    -- connector joins them as its provider expects, comma-separated or with the key repeated.
    local function queryParts(value: any, field: string): {string}
    	if type(value) ~= "table" then return {scalar(value, field)} end
    	local parts: {string} = {}
    	for index, item in value do
    		assert(type(index) == "number" and index == #parts + 1, field .. " must be an array, not an object")
    		table.insert(parts, scalar(item, field))
    	end
    	assert(#parts > 0, field .. " must not be an empty array")
    	return parts
    end
    
    -- POST, PATCH and PUT send the remaining options as the JSON body unless body is false
    -- (no body) or names the one option to send.
    local function hasBody(endpoint: Endpoint): boolean
    	return endpoint.body ~= false and (endpoint.method == "POST" or endpoint.method == "PATCH" or endpoint.method == "PUT")
    end
    
    local function fail(name: string, response: HttpResponse, message: string): never
    	return houston.fail({operation = name, layer = "upstream", upstream_status = response.statusCode,
    		retryable = response.statusCode == 429 or response.statusCode >= 500, message = message})
    end
    
    -- A successful response's JSON object, or nil when a write answers without a body. With arrays,
    -- a top-level JSON array is accepted too, and the second result tells which one came back.
    local function object(name: string, endpoint: Endpoint, response: HttpResponse, arrays: boolean?): (any, boolean)
    	local raw = await(response.body:readAll())
    	if endpoint.method ~= "GET" and endpoint.access and string.match(raw, "^%s*$") then return nil, false end
    	local ok, value = pcall(json.decode, raw)
    	local list = arrays == true and string.match(raw, "^%s*%[") ~= nil
    	if not ok or type(value) ~= "table" or not (list or string.match(raw, "^%s*{")) then
    		fail(name, response, PROVIDER .. " returned an invalid JSON object")
    	end
    	return value, list
    end
    
    -- name({path fields, query fields?, extra fields?, required body fields, ...body}) built from the
    -- endpoint itself.
    -- Extra fields are options the connector's own request consumes, such as a request header.
    local function signature(endpoint: Endpoint): string
    	local fields: {string} = {}
    	for field in string.gmatch(endpoint.path, "{([%w_]+)}") do table.insert(fields, field) end
    	for _, group in {endpoint.query or NONE, endpoint.extra or NONE} do
    		for _, field in group do
    			table.insert(fields, if table.find(endpoint.required or NONE, field) then field else field .. "?")
    		end
    	end
    	if type(endpoint.body) == "string" then
    		table.insert(fields, endpoint.body)
    	elseif hasBody(endpoint) then
    		for _, field in endpoint.required or NONE do
    			if not table.find(fields, field) then table.insert(fields, field) end
    		end
    		table.insert(fields, "...body")
    	end
    	return "({" .. table.concat(fields, ", ") .. "})"
    end
    
    -- A function for each endpoint the connection's access allows, and help listing them after intro.
    local function operations(endpoints: {[string]: Endpoint}, request: (string, Endpoint, Options?) -> any, intro: {string}): {[string]: any}
    	local exports: {[string]: any} = {}
    	for name, endpoint in endpoints do
    		if not endpoint.access or houston.allows(endpoint.access) then
    			exports[name] = function(args: Options?): any return request(name, endpoint, args) end
    		end
    	end
    	exports.help = function(): string
    		local names: {string} = {}
    		for name in exports do if name ~= "help" then table.insert(names, name) end end
    		table.sort(names)
    		local lines = table.clone(intro)
    		table.insert(lines, "Each function below names its route and reference page, " .. DOCS .. "<page>.")
    		for _, name in names do
    			local endpoint = endpoints[name]
    			table.insert(lines, name .. signature(endpoint) .. ": " .. endpoint.about .. " " .. endpoint.method .. " " .. endpoint.path .. " (" .. endpoint.doc .. ")")
    		end
    		return table.concat(lines, "\n")
    	end
    	return exports
    end
    -- End of the shared request layer.
    
    -- Gusto IDs are UUIDs; benefit types and years are numbers.
    local function identifier(value: any, field: string): string
    	if type(value) == "number" then
    		assert(value >= 0 and value % 1 == 0 and value <= 9007199254740991, field .. " must be a Gusto ID")
    		return string.format("%d", value)
    	end
    	assert(type(value) == "string" and string.match(value, "^[%w_%-]+$") and #value <= 64, field .. " must be a Gusto ID")
    	return value
    end
    
    local function header(response: HttpResponse, name: string): string?
    	local values = response.headers[name]
    	return if values then values[1] else nil
    end
    
    -- Gusto errors are {errors={{error_key, category, message, errors?}}}, where nested_errors
    -- carry per-item errors further down with metadata such as employee_uuid; a rejected token
    -- answers with an empty body and the reason in WWW-Authenticate. A create that failed with a
    -- 5xx may have been stored, so only throttling makes it retryable.
    local function failStatus(name: string, endpoint: Endpoint, response: HttpResponse): never
    	local message = "Gusto HTTP " .. tostring(response.statusCode)
    	local ok, value = pcall(json.decode, await(response.body:readPrefix(16 * 1024)))
    	local details: {string} = {}
    	local function collect(errors: any)
    		if type(errors) ~= "table" then return end
    		for _, item in errors do
    			if type(item) == "table" and #details < 5 then
    				local parts: {string} = {}
    				for _, field in {"category", "error_key", "message"} do
    					if type(item[field]) == "string" and item[field] ~= "" then table.insert(parts, string.sub(item[field], 1, 300)) end
    				end
    				if type(item.metadata) == "table" then
    					local keys: {string} = {}
    					for key, field in item.metadata do
    						if type(key) == "string" and (type(field) == "string" or type(field) == "number") then table.insert(keys, key) end
    					end
    					table.sort(keys)
    					for _, key in keys do table.insert(parts, "(" .. string.sub(key .. "=" .. tostring(item.metadata[key]), 1, 100) .. ")") end
    				end
    				if #parts > 0 then table.insert(details, table.concat(parts, " ")) end
    				collect(item.errors)
    			end
    		end
    	end
    	if ok and type(value) == "table" then collect(value.errors) end
    	local reason = header(response, "www-authenticate")
    	if #details == 0 and reason then
    		local description = string.match(reason, 'error_description="([^"]*)"')
    		if description then table.insert(details, string.sub(description, 1, 300)) end
    	end
    	if #details > 0 then message ..= ": " .. table.concat(details, "; ") end
    	local retry = header(response, "retry-after")
    	if response.statusCode == 429 and retry and string.match(retry, "^%d+$") then message ..= "; retry after " .. retry .. "s" end
    	local creates = endpoint.method == "POST" and endpoint.access ~= nil
    	return houston.fail({operation = name, layer = "upstream", upstream_status = response.statusCode,
    		retryable = response.statusCode == 429 or (response.statusCode >= 500 and not creates), message = message})
    end
    
    -- Objects return unchanged; arrays become {items, page?, per?, total_count?, total_pages?}, keeping
    -- Gusto's paging headers; a write answered without a body returns {success=true} and a read
    -- answered 204 No Content returns nil.
    local function decode(name: string, endpoint: Endpoint, response: HttpResponse): any
    	if response.statusCode == 204 and not endpoint.access then
    		response.body:close()
    		return nil
    	end
    	local value, list = object(name, endpoint, response, true)
    	if value == nil then return {success = true} end
    	if not list then return value end
    	return {items = value, page = tonumber(header(response, "x-page")), per = tonumber(header(response, "x-per-page")),
    		total_count = tonumber(header(response, "x-total-count")), total_pages = tonumber(header(response, "x-total-pages"))}
    end
    
    local function request(name: string, endpoint: Endpoint, input: Options?): any
    	local args = options(input)
    	local path = string.gsub(endpoint.path, "{([%w_]+)}", function(field: string)
    		local id = identifier(args[field], field)
    		args[field] = nil
    		return id
    	end)
    	for _, field in endpoint.required or NONE do
    		assert(args[field] ~= nil and args[field] ~= NULL, field .. " is required")
    	end
    	local query: {string} = {}
    	-- Gusto reads list filters (include, uuids, payroll_types) as comma-separated values.
    	for _, field in endpoint.query or NONE do
    		if args[field] ~= nil then table.insert(query, field .. "=" .. table.concat(queryParts(args[field], field), ",")) end
    		args[field] = nil
    	end
    	if #query > 0 then path ..= "?" .. table.concat(query, "&") end
    	local headers: HttpHeaders = {Accept = {"application/json"}, ["X-Gusto-API-Version"] = {VERSION}}
    	local body: string? = nil
    	if hasBody(endpoint) then
    		for field in args do
    			assert(endpoint.allow == nil or table.find(endpoint.allow, field), name .. " has no option " .. field)
    		end
    		headers["Content-Type"] = {"application/json"}
    		body = json.encode(args)
    		args = {}
    	end
    	local unknown = next(args)
    	assert(unknown == nil, name .. " has no option " .. tostring(unknown))
    	local response = await(http.request({method = endpoint.method, url = API .. path, headers = headers, body = body}))
    	if response.statusCode < 200 or response.statusCode >= 300 then failStatus(name, endpoint, response) end
    	return decode(name, endpoint, response)
    end
    
    local WRITES = "Updates whose signature lists version take the object's current version, read just before: a stale version fails with 409 invalid_resource_version, so read again and reapply. Payrolls are never submitted here: call preparePayroll, then updatePayroll with each employee compensation's version. Changes to pay, reimbursements and draft payrolls are paid by the next payroll, including one Gusto runs automatically for companies on Payroll on AutoPilot. Creates are not idempotent: after a timeout or 5xx, which is reported as not retryable, list or read before repeating one."
    
    return operations(endpoints, request, {
    	"Gusto App Integrations API (version " .. VERSION .. ")" .. (if auth.method == "demo" then " on Gusto's demo environment (sample data)" else "") .. ". Every function takes one named options object with Gusto's snake_case names; ? marks optional fields, required body fields follow the path and query fields, and ...body stands for the other JSON body fields. Objects return unchanged; JSON arrays return {items, page?, per?, total_count?, total_pages?}; a write answered without a body returns {success=true}. Connector calls return completed values: use them directly, without await.",
    	"A connection reaches one company. Start with local company_id = gusto.getTokenInfo().resource.uuid, then getCompany({company_id=company_id}), listEmployees({company_id=company_id}), listPayrolls(...). Employee jobs (getEmployee().jobs) give the job_id for compensations. IDs are UUID strings, except benefit_id (a number).",
    	"Pass page (1-based) and per (default 25, often at most 100) to any list and continue while total_pages is set and page < total_pages, or else while a full page came back; without page, most lists return every record, but listPayrolls always pages, and getPayroll and preparePayroll page their employee_compensations. Dates are YYYY-MM-DD; payroll amounts are decimal strings such as '1250.00'. Array filters (include, uuids, payroll_types) are sent comma-separated. A read answered 204 No Content returns nil.",
    	"Examples: local company_id = gusto.getTokenInfo().resource.uuid; gusto.listEmployees({company_id=company_id, terminated=false, include={'custom_fields'}, page=1, per=100}); gusto.listPayrolls({company_id=company_id, start_date='2026-01-01', end_date='2026-06-30', include={'totals'}}); gusto.getPayroll({company_id=company_id, payroll_id=id, include={'taxes', 'deductions'}}).",
    	"Responses include personal and pay data (birth dates, home addresses, pay rates, garnishments); share only what the task needs. Gusto's scopes for the app decide what is visible: pay rates need the compensations scope, and a missing scope fails with 403 missing_oauth_scopes.",
    	"Errors report the HTTP status and Gusto's category, error_key and message, with per-item nested errors (for example 422 invalid_attribute_value or 404 not_found). Gusto allows 200 requests per minute per connection.",
    	if houston.allows("data:write") then WRITES else "Read-only connections omit writes.",
    })
    
  • houston.json
    {
      "schema_version": 2,
      "name": "Gusto",
      "files": [
        "connector.luau"
      ],
      "icon": "icon.svg",
      "access": [
        {
          "name": "data",
          "label": "Access",
          "levels": [
            {
              "value": "read",
              "label": "Read"
            },
            {
              "value": "write",
              "label": "Write"
            }
          ],
          "default": "read"
        }
      ],
      "config": {
        "own_app": {
          "default": false,
          "label": "Use your own Gusto app",
          "order": 1,
          "type": "boolean"
        },
        "client_id": {
          "if": "{{ is config.own_app true }}",
          "label": "Gusto OAuth client ID",
          "order": 2,
          "required": true,
          "type": "string"
        },
        "client_secret": {
          "if": "{{ is config.own_app true }}",
          "label": "Gusto OAuth client secret",
          "order": 3,
          "required": true,
          "type": "secret"
        }
      },
      "auth": {
        "gusto": {
          "type": "oauth2",
          "label": "Connect with Gusto",
          "if": "{{ is config.own_app false }}",
          "authorize_url": "https://app.gusto.com/oauth/authorize",
          "token_url": "https://api.gusto.com/oauth/token",
          "client_id": "{{publisher.client_id}}",
          "client_secret": "{{publisher.client_secret}}",
          "client_auth": "body",
          "pkce": "none",
          "require_refresh": true,
          "account": {
            "url": "https://api.gusto.com/v1/token_info",
            "headers": {
              "Authorization": {
                "value": "Bearer {{auth.gusto.access_token}}"
              }
            },
            "label": "/resource/uuid"
          }
        },
        "own_app": {
          "type": "oauth2",
          "label": "Connect with your Gusto app",
          "order": 1,
          "if": "{{ is config.own_app true }}",
          "authorize_url": "https://app.gusto.com/oauth/authorize",
          "token_url": "https://api.gusto.com/oauth/token",
          "client_id": "{{config.client_id}}",
          "client_secret": "{{config.client_secret}}",
          "client_auth": "body",
          "pkce": "none",
          "require_refresh": true,
          "account": {
            "url": "https://api.gusto.com/v1/token_info",
            "headers": {
              "Authorization": {
                "value": "Bearer {{auth.own_app.access_token}}"
              }
            },
            "label": "/resource/uuid"
          }
        },
        "demo": {
          "type": "oauth2",
          "label": "Connect with your Gusto demo app",
          "order": 2,
          "if": "{{ is config.own_app true }}",
          "authorize_url": "https://app.gusto-demo.com/oauth/authorize",
          "token_url": "https://api.gusto-demo.com/oauth/token",
          "client_id": "{{config.client_id}}",
          "client_secret": "{{config.client_secret}}",
          "client_auth": "body",
          "pkce": "none",
          "require_refresh": true,
          "account": {
            "url": "https://api.gusto-demo.com/v1/token_info",
            "headers": {
              "Authorization": {
                "value": "Bearer {{auth.demo.access_token}}"
              }
            },
            "label": "/resource/uuid"
          }
        }
      },
      "publisher": {
        "client_id": {
          "label": "Gusto OAuth client ID",
          "order": 1,
          "type": "string"
        },
        "client_secret": {
          "label": "Gusto OAuth client secret",
          "order": 2,
          "type": "secret"
        }
      },
      "proxy": [
        {
          "match": {
            "protocol": "http",
            "host": [
              "api.gusto.com",
              "api.gusto-demo.com"
            ],
            "method": [
              "GET"
            ],
            "path": [
              "/v1/benefits",
              "/v1/benefits/{benefit_id}",
              "/v1/benefits/{benefit_id}/requirements",
              "/v1/companies/{company_id}",
              "/v1/companies/{company_id}/admins",
              "/v1/companies/{company_id}/company_benefits",
              "/v1/companies/{company_id}/contractor_payments",
              "/v1/companies/{company_id}/contractor_payments/{contractor_payment_id}",
              "/v1/companies/{company_id}/contractors",
              "/v1/companies/{company_id}/custom_fields",
              "/v1/companies/{company_id}/departments",
              "/v1/companies/{company_id}/earning_types",
              "/v1/companies/{company_id}/employees",
              "/v1/companies/{company_id}/locations",
              "/v1/companies/{company_id}/notifications",
              "/v1/companies/{company_id}/pay_periods",
              "/v1/companies/{company_id}/pay_periods/unprocessed_termination_pay_periods",
              "/v1/companies/{company_id}/pay_schedules",
              "/v1/companies/{company_id}/pay_schedules/assignments",
              "/v1/companies/{company_id}/pay_schedules/{pay_schedule_id}",
              "/v1/companies/{company_id}/payrolls",
              "/v1/companies/{company_id}/payrolls/{payroll_id}",
              "/v1/companies/{company_id}/time_off_policies",
              "/v1/companies/{company_id}/time_off_requests",
              "/v1/companies/{company_id}/time_tracking/time_sheets",
              "/v1/company_benefits/{company_benefit_id}",
              "/v1/company_benefits/{company_benefit_id}/contribution_exclusions",
              "/v1/company_benefits/{company_benefit_id}/employee_benefits",
              "/v1/company_benefits/{company_benefit_id}/summary",
              "/v1/compensations/{compensation_id}",
              "/v1/contractors/{contractor_uuid}",
              "/v1/departments/{department_uuid}",
              "/v1/employee_benefits/{employee_benefit_id}",
              "/v1/employees/{employee_id}",
              "/v1/employees/{employee_id}/custom_fields",
              "/v1/employees/{employee_id}/employee_benefits",
              "/v1/employees/{employee_id}/employment_history",
              "/v1/employees/{employee_id}/garnishments",
              "/v1/employees/{employee_id}/home_addresses",
              "/v1/employees/{employee_id}/recurring_reimbursements",
              "/v1/employees/{employee_id}/rehire",
              "/v1/employees/{employee_id}/section603_high_earner_statuses",
              "/v1/employees/{employee_id}/section603_high_earner_statuses/{effective_year}",
              "/v1/employees/{employee_id}/terminations",
              "/v1/employees/{employee_id}/time_off_activities",
              "/v1/employees/{employee_id}/work_addresses",
              "/v1/employees/{employee_id}/ytd_benefit_amounts_from_different_company",
              "/v1/garnishments/child_support",
              "/v1/garnishments/{garnishment_id}",
              "/v1/home_addresses/{home_address_uuid}",
              "/v1/jobs/{job_id}/compensations",
              "/v1/locations/{location_id}",
              "/v1/locations/{location_id}/minimum_wages",
              "/v1/recurring_reimbursements/{id}",
              "/v1/reports/{request_uuid}",
              "/v1/time_off_policies/{time_off_policy_uuid}",
              "/v1/time_tracking/payroll_syncs/{payroll_sync_uuid}",
              "/v1/time_tracking/time_sheets/{time_sheet_uuid}",
              "/v1/token_info",
              "/v1/work_addresses/{work_address_uuid}"
            ]
          },
          "action": {
            "headers": {
              "set": {
                "Authorization": "Bearer {{auth.gusto.access_token || auth.own_app.access_token || auth.demo.access_token}}"
              }
            }
          }
        },
        {
          "match": {
            "protocol": "http",
            "host": [
              "api.gusto.com",
              "api.gusto-demo.com"
            ],
            "method": [
              "POST"
            ],
            "path": [
              "/v1/payrolls/{payroll_id}/employees/{employee_id}/calculate_accruing_time_off_hours",
              "/v1/payrolls/{payroll_uuid}/reports/general_ledger"
            ]
          },
          "action": {
            "headers": {
              "set": {
                "Authorization": "Bearer {{auth.gusto.access_token || auth.own_app.access_token || auth.demo.access_token}}"
              }
            }
          }
        },
        {
          "if": "{{ allows access.data \"write\" }}",
          "match": {
            "protocol": "http",
            "host": [
              "api.gusto.com",
              "api.gusto-demo.com"
            ],
            "method": [
              "POST"
            ],
            "path": [
              "/v1/companies/{company_id}/company_benefits",
              "/v1/companies/{company_id}/contractors",
              "/v1/companies/{company_id}/departments",
              "/v1/companies/{company_id}/earning_types",
              "/v1/companies/{company_id}/employees",
              "/v1/companies/{company_id}/locations",
              "/v1/companies/{company_id}/time_tracking/payroll_syncs",
              "/v1/companies/{company_id}/time_tracking/time_sheets",
              "/v1/employees/{employee_id}/employee_benefits",
              "/v1/employees/{employee_id}/garnishments",
              "/v1/employees/{employee_id}/home_addresses",
              "/v1/employees/{employee_id}/recurring_reimbursements",
              "/v1/employees/{employee_id}/rehire",
              "/v1/employees/{employee_id}/section603_high_earner_statuses",
              "/v1/employees/{employee_id}/terminations",
              "/v1/employees/{employee_id}/work_addresses",
              "/v1/employees/{employee_id}/ytd_benefit_amounts_from_different_company",
              "/v1/jobs/{job_id}/compensations"
            ]
          },
          "action": {
            "headers": {
              "set": {
                "Authorization": "Bearer {{auth.gusto.access_token || auth.own_app.access_token || auth.demo.access_token}}"
              }
            }
          }
        },
        {
          "if": "{{ allows access.data \"write\" }}",
          "match": {
            "protocol": "http",
            "host": [
              "api.gusto.com",
              "api.gusto-demo.com"
            ],
            "method": [
              "PUT"
            ],
            "path": [
              "/v1/companies/{company_id}/earning_types/{earning_type_uuid}",
              "/v1/companies/{company_id}/payrolls/{payroll_id}",
              "/v1/companies/{company_id}/payrolls/{payroll_id}/prepare",
              "/v1/company_benefits/{company_benefit_id}",
              "/v1/company_benefits/{company_benefit_id}/contribution_exclusions",
              "/v1/company_benefits/{company_benefit_id}/employee_benefits",
              "/v1/compensations/{compensation_id}",
              "/v1/contractors/{contractor_uuid}",
              "/v1/departments/{department_uuid}",
              "/v1/departments/{department_uuid}/add",
              "/v1/departments/{department_uuid}/remove",
              "/v1/employee_benefits/{employee_benefit_id}",
              "/v1/employees/{employee_id}",
              "/v1/employees/{employee_id}/rehire",
              "/v1/garnishments/{garnishment_id}",
              "/v1/home_addresses/{home_address_uuid}",
              "/v1/locations/{location_id}",
              "/v1/recurring_reimbursements/{id}",
              "/v1/terminations/{employee_id}",
              "/v1/time_off_policies/{time_off_policy_uuid}/add_employees",
              "/v1/time_tracking/time_sheets/{time_sheet_uuid}",
              "/v1/work_addresses/{work_address_uuid}"
            ]
          },
          "action": {
            "headers": {
              "set": {
                "Authorization": "Bearer {{auth.gusto.access_token || auth.own_app.access_token || auth.demo.access_token}}"
              }
            }
          }
        },
        {
          "if": "{{ allows access.data \"write\" }}",
          "match": {
            "protocol": "http",
            "host": [
              "api.gusto.com",
              "api.gusto-demo.com"
            ],
            "method": [
              "PATCH"
            ],
            "path": [
              "/v1/employees/{employee_id}/section603_high_earner_statuses/{effective_year}"
            ]
          },
          "action": {
            "headers": {
              "set": {
                "Authorization": "Bearer {{auth.gusto.access_token || auth.own_app.access_token || auth.demo.access_token}}"
              }
            }
          }
        },
        {
          "if": "{{ allows access.data \"write\" }}",
          "match": {
            "protocol": "http",
            "host": [
              "api.gusto.com",
              "api.gusto-demo.com"
            ],
            "method": [
              "DELETE"
            ],
            "path": [
              "/v1/companies/{company_id}/earning_types/{earning_type_uuid}",
              "/v1/company_benefits/{company_benefit_id}",
              "/v1/compensations/{compensation_id}",
              "/v1/departments/{department_uuid}",
              "/v1/employee_benefits/{employee_benefit_id}",
              "/v1/employees/{employee_id}",
              "/v1/employees/{employee_id}/rehire",
              "/v1/employees/{employee_id}/terminations",
              "/v1/home_addresses/{home_address_uuid}",
              "/v1/recurring_reimbursements/{id}",
              "/v1/time_tracking/time_sheets/{time_sheet_uuid}",
              "/v1/work_addresses/{work_address_uuid}"
            ]
          },
          "action": {
            "headers": {
              "set": {
                "Authorization": "Bearer {{auth.gusto.access_token || auth.own_app.access_token || auth.demo.access_token}}"
              }
            }
          }
        }
      ]
    }
    
  • icon.svgicon.svg
  • README.md
    ---
    description: Read Gusto payroll, people and benefits, and keep employee records and draft payrolls up to date.
    ---
    
    # Gusto
    
    Let agents read payroll, employees, contractors, benefits, time off and accounting
    reports. **Write** access also permits employee and benefit changes, time sheets
    and draft payroll edits.
    
    > Agents cannot submit payroll or pay people directly. Changes to pay and draft
    > payrolls affect the next payroll, including Payroll on AutoPilot.
    
    Each connection serves one company. A primary or full-access admin must connect
    it; Gusto's app permissions still apply.
    
    [Connect Gusto](SETUP.md).
    
  • SETUP.md
    # Connect Gusto
    
    You need to be the primary admin or a full-access admin of the company in Gusto.
    
    1. Choose **Read** or **Write** for **Access**.
    2. Select **Authorize connection** and sign in with your Gusto account.
    3. If you manage several companies, pick the one to connect, then allow access.
    
    Each connection reaches one company: add another connection for each additional
    company. Houston keeps the connection signed in. If requests start failing with an
    authorization error, select **Set up again** and sign in.
    
    ## Advanced
    
    ### Use your own Gusto app
    
    Turn on **Use your own Gusto app** to connect through an app you register with Gusto.
    New apps work only in Gusto's demo environment, which has sample companies, until Gusto
    approves them for production; Gusto approves only App Integration partners.
    
    1. Sign up at the [Gusto Developer Portal](https://dev.gusto.com) and create or join
       an organization.
    2. Open **Applications**, click **Create application**, and add Houston's displayed
       callback URL as a redirect URI.
    3. Copy the app's client ID and secret into **Gusto OAuth client ID** and **Gusto
       OAuth client secret** in Houston.
    4. In the Developer Portal, create a demo company. In Houston, choose **Connect with
       your Gusto demo app** under **Connect using**, then select **Authorize connection**
       and sign in with that demo company's admin.
    
    Once Gusto approves the app for production, enter its production client ID and secret,
    select **Set up again** and sign in with **Connect with your Gusto app**. Gusto assigns
    the app's permissions (scopes) during its review; ask [email protected] to change them.
    See Gusto's [app integration guide](https://docs.gusto.com/app-integrations/docs/introduction).
    
    ### Troubleshooting
    
    - **missing_oauth_scopes**: the app lacks the permission that data needs, such as
      compensations for pay rates. The demo environment doesn't enforce scopes;
      production does.
    - **missing_permissions**: the request is a Gusto Embedded feature that app
      integrations can't use.
    - **Unauthorized**: the sign-in ended or a Gusto admin disconnected the app. Select
      **Set up again** and sign in.
    
  • tests
    • authentication.luau
      return {
      	contract = function(m)
      		m.authentication({
      			{
      				auth = {},
      				config = {
      					client_id = "synthetic-public-client",
      					client_secret = "synthetic-client-secret",
      					own_app = true,
      				},
      				endpoint = { "GET", "https://api.gusto.com/v1/token_info" },
      				expected = "Bearer synthetic-oauth-token",
      				header = "Authorization",
      				method = "demo",
      				oauth = true,
      				publisher = {},
      			},
      			{
      				auth = {},
      				config = {},
      				endpoint = { "GET", "https://api.gusto.com/v1/token_info" },
      				expected = "Bearer synthetic-oauth-token",
      				header = "Authorization",
      				method = "gusto",
      				oauth = true,
      				publisher = {
      					client_id = "synthetic-public-client",
      					client_secret = "synthetic-client-secret",
      				},
      			},
      			{
      				auth = {},
      				config = {
      					client_id = "synthetic-public-client",
      					client_secret = "synthetic-client-secret",
      					own_app = true,
      				},
      				endpoint = { "GET", "https://api.gusto.com/v1/token_info" },
      				expected = "Bearer synthetic-oauth-token",
      				header = "Authorization",
      				method = "own_app",
      				oauth = true,
      				publisher = {},
      			},
      		})
      	end,
      }
      
    • demo.luau
      return {
      	scenario = {publisher = {}, config = {own_app = true, client_id = "fixture-client", client_secret = "fixture-secret"}, auth_method = "demo", auth_config = {}},
      	configure = function()
      		requests = {}
      		http = {request = function(req)
      			table.insert(requests, req)
      			return fixture.operation({statusCode = 200, headers = {}, body = fixture.reader('[{"uuid":"l1","city":"Denver"}]')})
      		end}
      	end,
      	run = function(gusto)
      		assert(gusto.createLocation == nil and gusto.listLocations ~= nil, "demo read-only surface is wrong")
      		local locations = gusto.listLocations({company_id = "c1"})
      		assert(requests[1].method == "GET" and requests[1].url == "https://api.gusto-demo.com/v1/companies/c1/locations")
      		assert(locations.items[1].city == "Denver" and #requests == 1)
      	end,
      }
      
    • endpoints.luau
      return {
      	contract = function(m)
      		m.endpointRules()
      	end,
      }
      
    • errors.luau
      return {
      	scenario = {publisher = {client_id = "fixture-client", client_secret = "fixture-secret"}, access = {data = "write"}, config = {}, auth_method = "gusto", auth_config = {}},
      	configure = function()
      		calls = 0
      		status = 200
      		payload = "{}"
      		responseHeaders = {}
      		http = {request = function(req)
      			calls += 1
      			return fixture.operation({statusCode = status, headers = responseHeaders, body = fixture.reader(payload)})
      		end}
      	end,
      	run = function(gusto)
      		local function upstream(code, body, headers, expected, call)
      			status, payload, responseHeaders = code, body, headers
      			local before = calls
      			local ok, err = pcall(call or function()
      				gusto.createDepartment({company_id = "c1", title = "Engineering"})
      			end)
      			for _, text in expected do
      				assert(not ok and string.find(tostring(err), text, 1, true), "missing " .. text .. " in " .. tostring(err))
      			end
      			assert(calls == before + 1, "failed write was retried")
      			return tostring(err)
      		end
      		upstream(422, '{"errors":[{"error_key":"title","category":"invalid_attribute_value","message":"Title has already been taken"},{"error_key":"base","category":"invalid_operation"}]}', {},
      			{"Gusto HTTP 422: invalid_attribute_value title Title has already been taken; invalid_operation base", '"retryable":false'})
      		upstream(409, '{"errors":[{"error_key":"version","category":"invalid_resource_version","message":"stale"}]}', {},
      			{"Gusto HTTP 409: invalid_resource_version version stale"},
      			function() gusto.updateDepartment({department_uuid = "d1", title = "Eng", version = "old"}) end)
      		upstream(403, '{"errors":[{"error_key":"base","category":"missing_oauth_scopes","message":"Missing scope compensations:read"}]}', {},
      			{"Gusto HTTP 403: missing_oauth_scopes base Missing scope compensations:read", '"upstream_status":403', '"retryable":false'},
      			function() gusto.getCompensation({compensation_id = "k1"}) end)
      		upstream(401, "", {["www-authenticate"] = {'Bearer realm="Doorkeeper", error="invalid_token", error_description="The access token is invalid"'}},
      			{"Gusto HTTP 401: The access token is invalid", '"retryable":false'}, function() gusto.getTokenInfo() end)
      		local long = upstream(422, json.encode({errors = {{category = "invalid_parameter", message = string.rep("x", 5000)}}}), {}, {"Gusto HTTP 422: invalid_parameter xxx"})
      		assert(not string.find(long, string.rep("x", 301), 1, true), "error message not bounded")
      		upstream(404, '{"errors":[{"error_key":"employee","category":"not_found","message":"Resource not found"}]}', {}, {"Gusto HTTP 404: not_found employee Resource not found"},
      			function() gusto.getEmployee({employee_id = "missing"}) end)
      		upstream(429, '{"errors":[{"category":"rate_limit_exceeded","message":"Too many requests"}]}', {["retry-after"] = {"30"}},
      			{"Gusto HTTP 429: rate_limit_exceeded Too many requests; retry after 30s", '"retryable":true'})
      		upstream(422, json.encode({errors = {{error_key = "employee_compensations", category = "nested_errors", errors = {
      			{error_key = "fixed_compensations", category = "invalid_attribute_value", message = "Amount must be positive", metadata = {employee_uuid = "e9"}}}}}}), {},
      			{"Gusto HTTP 422: nested_errors employee_compensations; invalid_attribute_value fixed_compensations Amount must be positive (employee_uuid=e9)"},
      			function() gusto.updatePayroll({company_id = "c1", payroll_id = "p1", employee_compensations = {{employee_uuid = "e9", version = "v"}}}) end)
      		upstream(422, json.encode({errors = {{category = "nested_errors", error_key = "employee_compensations", errors = {{category = "nested_errors", error_key = "fixed_compensations",
      			errors = {{category = "invalid_attribute_value", error_key = "amount", message = "Amount must be positive"}}}}}}}), {},
      			{"nested_errors fixed_compensations; invalid_attribute_value amount Amount must be positive"})
      		local many = {}
      		for index = 1, 8 do table.insert(many, {category = "invalid_parameter", error_key = "field" .. index}) end
      		local capped = upstream(422, json.encode({errors = many}), {}, {"field5"})
      		assert(not string.find(capped, "field6", 1, true), "error list not capped")
      		local dated = upstream(429, "", {["retry-after"] = {"Wed, 21 Oct 2026 07:28:00 GMT"}}, {"Gusto HTTP 429", '"retryable":true'})
      		assert(not string.find(dated, "retry after", 1, true), "a dated Retry-After was reported as seconds")
      		-- A create that failed with a 5xx may have been stored; reads and versioned updates can be retried.
      		upstream(503, "<html>Unavailable</html>", {}, {"Gusto HTTP 503", '"retryable":false'})
      		upstream(500, '{"errors":[{"category":"internal_error","message":"Something went wrong"}]}', {}, {"Gusto HTTP 500: internal_error", '"retryable":true'},
      			function() gusto.getCompany({company_id = "c1"}) end)
      		upstream(502, "", {}, {"Gusto HTTP 502", '"retryable":true'}, function() gusto.updateDepartment({department_uuid = "d1", title = "Eng", version = "v"}) end)
      		upstream(502, "", {}, {"Gusto HTTP 502", '"retryable":true'}, function() gusto.createGeneralLedgerReport({payroll_uuid = "p1", aggregation = "job"}) end)
      		upstream(200, "<html>Maintenance</html>", {}, {"invalid JSON"})
      		upstream(200, "", {}, {"invalid JSON"}, function() gusto.listEmployees({company_id = "c1"}) end)
      		upstream(200, '"text"', {}, {"invalid JSON"}, function() gusto.getCompany({company_id = "c1"}) end)
      	end,
      }
      
    • manifest.luau
      return {
      	contract = function(m)
      		-- TestGustoAccessRoutes
      		do
      			for method, origin in { gusto = "gusto.com", own_app = "gusto.com", demo = "gusto-demo.com" } do
      				local a = m.raw.auth[method]
      				if
      					(
      						(
      							(a.authorize_url ~= "https://app." .. origin .. "/oauth/authorize")
      							or (a.token_url ~= "https://api." .. origin .. "/oauth/token")
      						) or (a.pkce ~= "none")
      					) or not a.require_refresh
      				then
      					m.fail("%s endpoints %s %s %s", method, a.authorize_url, a.token_url, a.pkce)
      				end
      				for _, access in { "read", "write" } do
      					local config = {}
      					local publisher = { client_id = "houston-client", client_secret = "houston-secret" }
      					if method ~= "gusto" then
      						config["own_app"], config["client_id"], config["client_secret"], publisher =
      							true, "fixture-client", "fixture-secret", nil
      					end
      					local r, err = m.resolve(publisher, config, nil, method, { data = access })
      					assert(not err, tostring(err))
      					if m.count(r.Scopes) ~= 0 then
      						m.fail("%s requests scopes %s", method, r.Scopes)
      					end
      					local token = "gusto-" .. method
      					r.Context.Auth[method].access_token = token
      					for _, api in { "https://api.gusto.com/v1", "https://api.gusto-demo.com/v1" } do
      						m.routes(r, "Bearer " .. token, true, {
      							"GET " .. api .. "/token_info",
      							"GET " .. api .. "/companies/c1/employees?include=custom_fields&page=1&per=100",
      							"GET " .. api .. "/companies/c1/payrolls/p1?include=taxes",
      							"GET " .. api .. "/companies/c1/pay_schedules/assignments",
      							"POST " .. api .. "/payrolls/p1/reports/general_ledger",
      							"POST " .. api .. "/payrolls/p1/employees/e1/calculate_accruing_time_off_hours",
      						})
      						m.routes(r, "Bearer " .. token, (access == "write"), {
      							"POST " .. api .. "/companies/c1/employees",
      							"PUT " .. api .. "/employees/e1",
      							"DELETE " .. api .. "/employees/e1",
      							"PUT " .. api .. "/companies/c1/payrolls/p1/prepare",
      							"PUT " .. api .. "/companies/c1/payrolls/p1",
      							"PATCH " .. api .. "/employees/e1/section603_high_earner_statuses/2026",
      							"DELETE " .. api .. "/time_tracking/time_sheets/t1?version=v1",
      						})
      						m.routes(r, "Bearer " .. token, false, {
      							"PUT " .. api .. "/companies/c1/payrolls/p1/submit",
      							"PUT " .. api .. "/companies/c1/payrolls/p1/calculate",
      							"PUT " .. api .. "/companies/c1/payrolls/p1/cancel",
      							"POST " .. api .. "/companies/c1/payrolls",
      							"POST " .. api .. "/companies/c1/contractor_payments",
      							"PUT " .. api .. "/contractor_payments/cp1/fund",
      							"GET " .. api .. "/webhook_subscriptions",
      							"GET " .. api .. "/events",
      							"POST " .. api .. "/provision",
      							"POST " .. api .. "/companies/c1/disconnect_app_integration",
      							"GET " .. api .. "/employees/e1/bank_accounts",
      							"PATCH " .. api .. "/employees/e1",
      							"PUT " .. api .. "/companies/c1",
      							"GET " .. api .. "/employees/%2e%2e/token_info",
      						})
      					end
      					m.routes(r, "Bearer " .. token, false, {
      						"POST https://api.gusto.com/oauth/token",
      						"POST https://api.gusto-demo.com/oauth/revoke",
      						"GET https://app.gusto.com/v1/token_info",
      						"GET https://mcp.api.gusto.com/v1/token_info",
      						"GET https://api.gusto.com.example.com/v1/token_info",
      						"GET https://api.gusto.com/v2/token_info",
      					})
      				end
      			end
      		end
      		-- TestGustoRoutesRejectMethodOverrides
      		do
      			local r, err = m.resolve(
      				{ client_id = "houston-client", client_secret = "houston-secret" },
      				{},
      				nil,
      				"gusto",
      				{ data = "write" }
      			)
      			assert(not err, tostring(err))
      			r.Context.Auth["gusto"].access_token = "gusto-token"
      			m.rejectOverrides(r, {
      				"GET https://api.gusto.com/v1/employees/e1",
      				"POST https://api.gusto.com/v1/payrolls/p1/reports/general_ledger",
      				"POST https://api.gusto.com/v1/companies/c1/employees",
      				"PUT https://api.gusto.com/v1/employees/e1",
      				"PATCH https://api.gusto.com/v1/employees/e1/section603_high_earner_statuses/2026",
      				"DELETE https://api.gusto.com/v1/employees/e1",
      			})
      		end
      	end,
      }
      
    • read_only.luau
      return {
      	scenario = {publisher = {client_id = "fixture-client", client_secret = "fixture-secret"}, config = {}, auth_method = "gusto", auth_config = {}},
      	configure = function()
      		requests = {}
      		status = 200
      		payload = "{}"
      		responseHeaders = {}
      		http = {request = function(req)
      			table.insert(requests, req)
      			return fixture.operation({statusCode = status, headers = responseHeaders, body = fixture.reader(payload)})
      		end}
      	end,
      	run = function(gusto)
      		local API = "https://api.gusto.com/v1"
      		local COMPANY = "c2b9a6f0-1f3e-4a5b-9c8d-7e6f5a4b3c2d"
      		local function last() return requests[#requests] end
      		local function rejected(fn, expected)
      			local before = #requests
      			local ok, err = pcall(fn)
      			assert(not ok and string.find(tostring(err), expected, 1, true), "wrong validation error: " .. tostring(err))
      			assert(#requests == before, "invalid input reached Gusto")
      		end
      
      		local names = {}
      		for name in gusto do if name ~= "help" then table.insert(names, name) end end
      		table.sort(names)
      		local READS = {
      			"calculateAccruingTimeOffHours", "createGeneralLedgerReport", "getBenefit", "getBenefitRequirements", "getChildSupportData", "getCompany",
      			"getCompanyBenefit", "getCompanyBenefitSummary", "getCompensation", "getContractor", "getContractorPayment", "getContributionExclusions",
      			"getDepartment", "getEmployee", "getEmployeeBenefit", "getEmploymentHistory", "getGarnishment", "getHomeAddress", "getLocation",
      			"getPaySchedule", "getPayScheduleAssignments", "getPayroll", "getPayrollSync", "getRecurringReimbursement", "getRehire", "getReport",
      			"getSection603HighEarnerStatus", "getTimeOffPolicy", "getTimeSheet", "getTokenInfo", "getWorkAddress",
      			"getYtdBenefitAmountsFromDifferentCompany", "listBenefits", "listCompanyAdmins", "listCompanyBenefitEmployeeBenefits",
      			"listCompanyBenefits", "listCompanyCustomFields", "listCompensations", "listContractorPayments", "listContractors", "listDepartments",
      			"listEarningTypes", "listEmployeeBenefits", "listEmployeeCustomFields", "listEmployees", "listGarnishments", "listHomeAddresses",
      			"listLocations", "listMinimumWages", "listNotifications", "listPayPeriods", "listPaySchedules", "listPayrolls",
      			"listRecurringReimbursements", "listSection603HighEarnerStatuses", "listTerminations", "listTimeOffActivities", "listTimeOffPolicies",
      			"listTimeOffRequests", "listTimeSheets", "listUnprocessedTerminationPayPeriods", "listWorkAddresses",
      		}
      		table.sort(READS)
      		assert(table.concat(names, ",") == table.concat(READS, ","), "wrong read-only surface: " .. table.concat(names, ","))
      		assert(#requests == 0, "initialization reached Gusto")
      
      		payload = '{"scope":"companies:read employees:read","resource":{"type":"Company","uuid":"' .. COMPANY .. '"},"resource_owner":{"type":"CompanyAdmin","uuid":"a1"}}'
      		assert(gusto.getTokenInfo().resource.uuid == COMPANY)
      		assert(last().method == "GET" and last().url == API .. "/token_info" and last().body == nil)
      		assert(last().headers.Accept[1] == "application/json" and last().headers["X-Gusto-API-Version"][1] == "2026-06-15")
      		assert(last().headers.Authorization == nil)
      
      		payload = '[{"uuid":"e1","first_name":"Ada","date_of_birth":null,"jobs":[]},{"uuid":"e2","first_name":"Grace","jobs":[]}]'
      		responseHeaders = {["x-page"] = {"2"}, ["x-per-page"] = {"2"}, ["x-total-count"] = {"5"}, ["x-total-pages"] = {"3"}}
      		local opts = {company_id = COMPANY, search_term = "a b&c", terminated = false, include = {"custom_fields", "all_compensations"}, page = 2, per = 2}
      		local page = gusto.listEmployees(opts)
      		assert(last().url == API .. "/companies/" .. COMPANY .. "/employees?search_term=a%20b%26c&include=custom_fields,all_compensations&terminated=false&page=2&per=2", last().url)
      		assert(opts.page == 2 and opts.include[2] == "all_compensations", "caller options were modified")
      		assert(#page.items == 2 and page.items[2].first_name == "Grace" and page.items[1].date_of_birth == json.decode("null"))
      		assert(page.page == 2 and page.per == 2 and page.total_count == 5 and page.total_pages == 3)
      
      		payload = "[]"
      		responseHeaders = {}
      		local empty = gusto.listDepartments({company_id = COMPANY})
      		assert(last().url == API .. "/companies/" .. COMPANY .. "/departments" and json.encode(empty.items) == "[]" and empty.total_pages == nil)
      
      		payload = '{"uuid":"p1","processed":true,"employee_compensations":[],"totals":{"gross_pay":"1250.00"}}'
      		local payroll = gusto.getPayroll({company_id = COMPANY, payroll_id = "p1", include = {"taxes", "totals"}})
      		assert(last().url == API .. "/companies/" .. COMPANY .. "/payrolls/p1?include=taxes,totals")
      		assert(payroll.totals.gross_pay == "1250.00" and json.encode(payroll.employee_compensations) == "[]")
      		gusto.listPayrolls({company_id = COMPANY, processing_statuses = {"processed"}, start_date = "2026-01-01", end_date = "2026-06-30", page = 1, per = 100})
      		assert(last().url == API .. "/companies/" .. COMPANY .. "/payrolls?processing_statuses=processed&start_date=2026-01-01&end_date=2026-06-30&page=1&per=100", last().url)
      		gusto.listContractorPayments({company_id = COMPANY, start_date = "2026-01-01", end_date = "2026-03-31"})
      		assert(last().url == API .. "/companies/" .. COMPANY .. "/contractor_payments?start_date=2026-01-01&end_date=2026-03-31")
      		gusto.getBenefit({benefit_id = 5})
      		assert(last().url == API .. "/benefits/5")
      		gusto.getSection603HighEarnerStatus({employee_id = "e1", effective_year = 2026})
      		assert(last().url == API .. "/employees/e1/section603_high_earner_statuses/2026")
      		gusto.listTimeOffActivities({employee_id = "e1", time_off_type = "vacation"})
      		assert(last().url == API .. "/employees/e1/time_off_activities?time_off_type=vacation")
      
      		payload = '{"request_uuid":"r1","status":"pending"}'
      		local report = gusto.createGeneralLedgerReport({payroll_uuid = "p1", aggregation = "department"})
      		assert(last().method == "POST" and last().url == API .. "/payrolls/p1/reports/general_ledger" and last().headers["Content-Type"][1] == "application/json")
      		local body = json.decode(last().body)
      		assert(body.aggregation == "department" and body.payroll_uuid == nil, "path field leaked into the body")
      		assert(report.request_uuid == "r1")
      		payload = ""
      		local blank, blankErr = pcall(function() gusto.createGeneralLedgerReport({payroll_uuid = "p1", aggregation = "default"}) end)
      		assert(not blank and string.find(tostring(blankErr), "invalid JSON", 1, true), "an empty read is not a success")
      		payload = '{"accruing_time_off_hours":[]}'
      		gusto.calculateAccruingTimeOffHours({payroll_id = "p1", employee_id = "e1", regular_hours_worked = 40})
      		assert(last().method == "POST" and last().url == API .. "/payrolls/p1/employees/e1/calculate_accruing_time_off_hours" and last().body == '{"regular_hours_worked":40}')
      		status, payload = 204, "\n"
      		assert(gusto.getRehire({employee_id = "e1"}) == nil and last().url == API .. "/employees/e1/rehire", "a 204 read is not nil")
      		status = 200
      		local count = #requests
      
      		rejected(function() gusto.getEmployee() end, "employee_id must be a Gusto ID")
      		rejected(function() gusto.getEmployee({employee_id = "../token_info"}) end, "employee_id must be a Gusto ID")
      		rejected(function() gusto.getEmployee({employee_id = "e1/jobs"}) end, "employee_id must be a Gusto ID")
      		rejected(function() gusto.getEmployee({employee_id = "e1?x=1"}) end, "employee_id must be a Gusto ID")
      		rejected(function() gusto.getEmployee({employee_id = ""}) end, "employee_id must be a Gusto ID")
      		rejected(function() gusto.getBenefit({benefit_id = 1.5}) end, "benefit_id must be a Gusto ID")
      		rejected(function() gusto.getBenefit({benefit_id = -1}) end, "benefit_id must be a Gusto ID")
      		rejected(function() gusto.getEmployee({employee_id = string.rep("a", 65)}) end, "employee_id must be a Gusto ID")
      		rejected(function() gusto.listContractorPayments({company_id = COMPANY, start_date = "2026-01-01"}) end, "end_date is required")
      		rejected(function() gusto.listTimeOffActivities({employee_id = "e1"}) end, "time_off_type is required")
      		rejected(function() gusto.listEmployees({company_id = COMPANY, limit = 10}) end, "listEmployees has no option limit")
      		rejected(function() gusto.listEmployees({company_id = COMPANY, uuids = json.decode("[]")}) end, "uuids must not be an empty array")
      		rejected(function() gusto.listEmployees({company_id = COMPANY, include = {a = "x"}}) end, "array, not an object")
      		rejected(function() gusto.listEmployees("all") end, "opts must be an object")
      		rejected(function() gusto.calculateAccruingTimeOffHours({payroll_id = "p1", employee_id = "e1", _method = "PUT"}) end, "calculateAccruingTimeOffHours has no option _method")
      		rejected(function() gusto.createGeneralLedgerReport({payroll_uuid = "p1", aggregation = "job", payroll_id = "p2"}) end, "createGeneralLedgerReport has no option payroll_id")
      		assert(#requests == count)
      	end,
      }
      
    • writes.luau
      return {
      	scenario = {publisher = {}, access = {data = "write"}, config = {own_app = true, client_id = "fixture-client", client_secret = "fixture-secret"},
      		auth_method = "own_app", auth_config = {}},
      	configure = function()
      		requests = {}
      		status = 200
      		payload = "{}"
      		http = {request = function(req)
      			table.insert(requests, req)
      			return fixture.operation({statusCode = status, headers = {}, body = fixture.reader(payload)})
      		end}
      	end,
      	run = function(gusto)
      		local API = "https://api.gusto.com/v1"
      		local COMPANY = "c2b9a6f0-1f3e-4a5b-9c8d-7e6f5a4b3c2d"
      		local function last() return requests[#requests] end
      		local function sent() return json.decode(last().body) end
      		local function same(a, b)
      			if type(a) ~= "table" or type(b) ~= "table" then return a == b end
      			for key, value in a do if not same(value, b[key]) then return false end end
      			for key in b do if a[key] == nil then return false end end
      			return true
      		end
      		local function rejected(fn, expected)
      			local before = #requests
      			local ok, err = pcall(fn)
      			assert(not ok and string.find(tostring(err), expected, 1, true), "wrong validation error: " .. tostring(err))
      			assert(#requests == before, "invalid input reached Gusto")
      		end
      
      		local names = {}
      		for name in gusto do if name ~= "help" then table.insert(names, name) end end
      		table.sort(names)
      		local WRITES = {
      			"addDepartmentPeople", "addTimeOffPolicyEmployees", "createCompanyBenefit", "createCompensation", "createContractor", "createDepartment",
      			"createEarningType", "createEmployee", "createEmployeeBenefit", "createGarnishment", "createHomeAddress", "createLocation",
      			"createPayrollSync", "createRecurringReimbursement", "createRehire", "createSection603HighEarnerStatus", "createTermination",
      			"createTimeSheet", "createWorkAddress", "createYtdBenefitAmountsFromDifferentCompany", "deleteCompanyBenefit", "deleteCompensation",
      			"deleteDepartment", "deleteEarningType", "deleteEmployee", "deleteEmployeeBenefit", "deleteHomeAddress", "deleteRecurringReimbursement",
      			"deleteRehire", "deleteTermination", "deleteTimeSheet", "deleteWorkAddress", "preparePayroll", "removeDepartmentPeople",
      			"updateCompanyBenefit", "updateCompanyBenefitEmployeeBenefits", "updateCompensation", "updateContractor", "updateContributionExclusions",
      			"updateDepartment", "updateEarningType", "updateEmployee", "updateEmployeeBenefit", "updateGarnishment", "updateHomeAddress",
      			"updateLocation", "updatePayroll", "updateRecurringReimbursement", "updateRehire", "updateSection603HighEarnerStatus", "updateTermination",
      			"updateTimeSheet", "updateWorkAddress"
      		}
      		local exported = {}
      		for _, name in names do exported[name] = true end
      		for _, name in WRITES do assert(exported[name], "write missing: " .. name) end
      		assert(#names == 62 + #WRITES, "wrong read-write surface: " .. table.concat(names, ","))
      
      		payload = '{"uuid":"e9","first_name":"Ada","last_name":"Lovelace","version":"v1"}'
      		local employee = gusto.createEmployee({company_id = COMPANY, first_name = "Ada", last_name = "Lovelace", email = "[email protected]", self_onboarding = true})
      		assert(last().method == "POST" and last().url == API .. "/companies/" .. COMPANY .. "/employees")
      		assert(last().headers["Content-Type"][1] == "application/json" and last().headers["X-Gusto-API-Version"][1] == "2026-06-15")
      		assert(last().headers.Accept[1] == "application/json" and last().headers.Authorization == nil)
      		assert(same(sent(), {first_name = "Ada", last_name = "Lovelace", email = "[email protected]", self_onboarding = true}), last().body)
      		assert(employee.uuid == "e9")
      
      		gusto.updateEmployee({employee_id = "e9", version = "v1", preferred_first_name = "Countess", middle_initial = json.decode("null")})
      		assert(last().method == "PUT" and last().url == API .. "/employees/e9")
      		assert(same(sent(), {version = "v1", preferred_first_name = "Countess", middle_initial = json.decode("null")}), last().body)
      
      		payload = '{"payroll_uuid":"p1","processing_status":"unprocessed","employee_compensations":[{"employee_uuid":"e9","version":"ev2"}]}'
      		local draft = gusto.preparePayroll({company_id = COMPANY, payroll_id = "p1", per = 100})
      		assert(last().method == "PUT" and last().url == API .. "/companies/" .. COMPANY .. "/payrolls/p1/prepare?per=100" and last().body == "{}")
      		gusto.preparePayroll({company_id = COMPANY, payroll_id = "p1", employee_uuids = {"e9"}})
      		assert(same(sent(), {employee_uuids = {"e9"}}), last().body)
      		local line = draft.employee_compensations[1]
      		gusto.updatePayroll({company_id = COMPANY, payroll_id = "p1",
      			employee_compensations = {{employee_uuid = line.employee_uuid, version = line.version, fixed_compensations = {{name = "Bonus", amount = "500.00"}}}}})
      		assert(last().method == "PUT" and last().url == API .. "/companies/" .. COMPANY .. "/payrolls/p1")
      		assert(same(sent(), {employee_compensations = {{employee_uuid = "e9", version = "ev2", fixed_compensations = {{name = "Bonus", amount = "500.00"}}}}}), last().body)
      
      		payload = '{"uuid":"t1","effective_date":"2026-11-30","version":"tv1"}'
      		gusto.createTermination({employee_id = "e9", effective_date = "2026-11-30", run_termination_payroll = false})
      		assert(last().method == "POST" and last().url == API .. "/employees/e9/terminations")
      		assert(same(sent(), {effective_date = "2026-11-30", run_termination_payroll = false}), last().body)
      		gusto.updateSection603HighEarnerStatus({employee_id = "e9", effective_year = 2026, is_high_earner = true})
      		assert(last().method == "PATCH" and last().url == API .. "/employees/e9/section603_high_earner_statuses/2026" and same(sent(), {is_high_earner = true}))
      
      		payload = ""
      		status = 204
      		local deleted = gusto.deleteTimeSheet({time_sheet_uuid = "ts1", version = "tsv3"})
      		assert(last().method == "DELETE" and last().url == API .. "/time_tracking/time_sheets/ts1?version=tsv3" and last().body == nil)
      		assert(last().headers["Content-Type"] == nil and deleted.success == true)
      		assert(gusto.deleteEmployee({employee_id = "e9"}).success == true and last().method == "DELETE" and last().url == API .. "/employees/e9")
      		status = 200
      
      		payload = "[]"
      		local cleared = gusto.updateCompanyBenefitEmployeeBenefits({company_benefit_id = "cb1", employee_benefits = json.decode("[]")})
      		assert(last().method == "PUT" and last().body == '{"employee_benefits":[]}' and json.encode(cleared.items) == "[]")
      
      		rejected(function() gusto.updateEmployee({employee_id = "e9", first_name = "Ada"}) end, "version is required")
      		rejected(function() gusto.updatePayroll({company_id = COMPANY, payroll_id = "p1"}) end, "employee_compensations is required")
      		rejected(function() gusto.updateTermination({employee_id = "e9", effective_date = "2026-12-01", version = json.decode("null")}) end, "version is required")
      		rejected(function() gusto.deleteTimeSheet({time_sheet_uuid = "ts1"}) end, "version is required")
      		rejected(function() gusto.deleteTimeSheet({time_sheet_uuid = "ts1", version = "v", force = true}) end, "deleteTimeSheet has no option force")
      		rejected(function() gusto.createTermination({employee_id = "e9"}) end, "effective_date is required")
      		rejected(function() gusto.updatePayroll({company_id = COMPANY, payroll_id = "p1/submit", employee_compensations = json.decode("[]")}) end, "payroll_id must be a Gusto ID")
      		rejected(function() gusto.deleteEmployee({employee_id = "e9/terminations"}) end, "employee_id must be a Gusto ID")
      		rejected(function() gusto.preparePayroll({company_id = "..", payroll_id = "p1"}) end, "company_id must be a Gusto ID")
      	end,
      }