Developer-friendly & type-safe Typescript SDK specifically catered to leverage gusto-embedded API.
[!IMPORTANT] This SDK is not yet ready for production use. To complete setup please follow the steps outlined in your workspace. Delete this section before > publishing to a package manager.
Gusto API: Welcome to Gusto's Embedded Payroll API documentation!
The SDK can be installed with either npm, pnpm, bun or yarn package managers.
npm add @gusto/embedded-api
# Install optional peer dependencies if you plan to use React hooks
npm add @tanstack/react-query react react-dom
pnpm add @gusto/embedded-api
# Install optional peer dependencies if you plan to use React hooks
pnpm add @tanstack/react-query react react-dom
bun add @gusto/embedded-api
# Install optional peer dependencies if you plan to use React hooks
bun add @tanstack/react-query react react-dom
yarn add @gusto/embedded-api zod
# Install optional peer dependencies if you plan to use React hooks
yarn add @tanstack/react-query react react-dom
# Note that Yarn does not install peer dependencies automatically. You will need
# to install zod as shown above.
[!NOTE] This package is published as an ES Module (ESM) only. For applications using CommonJS, use
await import("@gusto/embedded-api")
to import and use this package.
For supported JavaScript runtimes, please consult RUNTIMES.md.
import { GustoEmbedded } from "@gusto/embedded-api";
const gustoEmbedded = new GustoEmbedded({
companyAccessAuth: process.env["GUSTOEMBEDDED_COMPANY_ACCESS_AUTH"] ?? "",
});
async function run() {
const result = await gustoEmbedded.introspection.getInfo({});
console.log(result);
}
run();
This SDK supports the following security scheme globally:
Name | Type | Scheme | Environment Variable |
---|---|---|---|
companyAccessAuth |
http | HTTP Bearer | GUSTOEMBEDDED_COMPANY_ACCESS_AUTH |
To authenticate with the API the companyAccessAuth
parameter must be set when initializing the SDK client instance. For example:
import { GustoEmbedded } from "@gusto/embedded-api";
const gustoEmbedded = new GustoEmbedded({
companyAccessAuth: process.env["GUSTOEMBEDDED_COMPANY_ACCESS_AUTH"] ?? "",
});
async function run() {
const result = await gustoEmbedded.introspection.getInfo({});
console.log(result);
}
run();
Some operations in this SDK require the security scheme to be specified at the request level. For example:
import { GustoEmbedded } from "@gusto/embedded-api";
const gustoEmbedded = new GustoEmbedded();
async function run() {
const result = await gustoEmbedded.companies.createPartnerManaged({
systemAccessAuth: process.env["GUSTOEMBEDDED_SYSTEM_ACCESS_AUTH"] ?? "",
}, {
requestBody: {
user: {
firstName: "Frank",
lastName: "Ocean",
email: "frank@example.com",
phone: "2345558899",
},
company: {
name: "Frank's Ocean, LLC",
tradeName: "Frank’s Ocean",
ein: "123456789",
contractorOnly: false,
},
},
});
console.log(result);
}
run();
Available methods
- getAll - Get all ACH transactions for a company
- get - Get all company bank accounts
- create - Create a company bank account
- verify - Verify a company bank account
- createFromPlaidToken - Create a bank account from a plaid processor token
- deleteV1CompaniesCompanyIdBankAccountsBankAccountId - Delete a company bank account
- createPartnerManaged - Create a partner managed company
- get - Get a company
- update - Update a company
- migrate - Migrate company to embedded payroll
- acceptTermsOfService - Accept terms of service for a company user
- retrieveTermsOfService - Retrieve terms of service status for a company user
- createAdmin - Create an admin for the company
- listAdmins - Get all the admins at a company
- getOnboardingStatus - Get the company's onboarding status
- finishOnboarding - Finish company onboarding
- getCustomFields - Get the custom fields of a company
- getDownloadUrl - Get a temporary url to download the Company Attachment file
- getDetails - Get Company Attachment Details
- getList - Get List of Company Attachments
- create - Create Company Attachment and Upload File
- create - Create a company benefit
- list - Get benefits for a company
- get - Get a company benefit
- update - Update a company benefit
- delete - Delete a company benefit
- getAll - Get all benefits supported by Gusto
- getSupported - Get a supported benefit by ID
- getSummary - Get company benefit summary by company benefit id.
- getEmployeeBenefits - Get all employee benefits for a company benefit
- updateEmployeeBenefits - Bulk update employee benefits for a company benefit
- getRequirements - Get benefit fields requirements by ID
- getV1CompanyBenefitsCompanyBenefitIdContributionExclusions - Get contribution exclusions for a company benefit
- putV1CompanyBenefitsCompanyBenefitIdContributionExclusions - Update contribution exclusions for a company benefit
- getAll - Get all company forms
- get - Get a company form
- getPdf - Get a company form pdf
- sign - Sign a company form
- getAll - Get all contractor documents
- get - Get a contractor document
- getPdf - Get the contractor document pdf
- sign - Sign a contractor document
- list - Get all contractor forms
- get - Get a contractor form
- getPdf - Get the contractor form pdf
- generate1099 - Generate a 1099 form [DEMO]
- getList - Get contractor payment groups for a company
- create - Create a contractor payment group
- preview - Preview a contractor payment group
- get - Get a contractor payment group
- delete - Cancel a contractor payment group
- fund - Fund a contractor payment group [DEMO]
- getV1ContractorPaymentGroupsIdPartnerDisbursements - Get partner disbursements for a contractor payment group
- patchV1ContractorPaymentGroupsIdPartnerDisbursements - Update partner disbursements for a contractor payment group
- getBankAccounts - Get all contractor bank accounts
- get - Get a contractor's payment method
- update - Update a contractor's payment method
- createBankAccount - Create a contractor bank account
- getReceipt - Get a single contractor payment receipt
- fund - Fund a contractor payment [DEMO]
- create - Create a contractor payment
- list - Get contractor payments for a company
- get - Get a single contractor payment
- delete - Cancel a contractor payment
- create - Create a contractor
- list - Get contractors of a company
- get - Get a contractor
- update - Update a contractor
- delete - Delete a contractor
- getOnboardingStatus - Get the contractor's onboarding status
- updateOnboardingStatus - Change the contractor's onboarding status
- getAddress - Get a contractor address
- updateAddress - Update a contractor's address
- getV1CompaniesCompanyIdContractorsPaymentDetails - List contractor payment details
- create - Create a department
- getAll - Get all departments of a company
- get - Get a department
- update - Update a department
- delete - Delete a department
- addPeople - Add people to a department
- removePeople - Remove people from a department
- create - Create a custom earning type
- list - Get all earning types for a company
- update - Update an earning type
- delete - Deactivate an earning type
- get - Get an employee's home addresses
- create - Create an employee's home address
- retrieveHomeAddress - Get an employee's home address
- update - Update an employee's home address
- delete - Delete an employee's home address
- getWorkAddresses - Get an employee's work addresses
- createWorkAddress - Create an employee work address
- retrieveWorkAddress - Get an employee work address
- updateWorkAddress - Update an employee work address
- deleteWorkAddress - Delete an employee's work address
- create - Create an employee benefit
- get - Get all benefits for an employee
- retrieve - Get an employee benefit
- update - Update an employee benefit
- delete - Delete an employee benefit
- getYtdBenefitAmountsFromDifferentCompany - Get year-to-date benefit amounts from a different company
- createYtdBenefitAmountsFromDifferentCompany - Create year-to-date benefit amounts from a different company
- createTermination - Create an employee termination
- getTerminations - Get terminations for an employee
- deleteTermination - Delete an employee termination
- updateTermination - Update an employee termination
- createRehire - Create an employee rehire
- rehire - Update an employee rehire
- getRehire - Get an employee rehire
- deleteRehire - Delete an employee rehire
- getHistory - Get employment history for an employee
- generateW2 - Generate a W2 form [DEMO]
- list - Get all employee forms
- get - Get an employee form
- getPdf - Get the employee form pdf
- sign - Sign an employee form
- create - Create an employee bank account
- deleteBankAccount - Delete an employee bank account
- updateBankAccount - Update an employee bank account
- get - Get an employee's payment method
- update - Update an employee's payment method
- getBankAccounts - Get all employee bank accounts
- list - Get employees of a company
- create - Create an employee
- getV1CompaniesCompanyIdEmployeesPaymentDetails - Get employee payment details for a company
- createHistorical - Create a historical employee
- get - Get an employee
- update - Update an employee.
- delete - Delete an onboarding employee
- getCustomFields - Get an employee's custom fields
- updateOnboardingDocumentsConfig - Update an employee's onboarding documents config
- getOnboardingStatus - Get the employee's onboarding status
- updateOnboardingStatus - Update the employee's onboarding status
- getTimeOffActivities - Get employee time off activities
- getFederalTaxes - Get an employee's federal taxes
- updateFederalTaxes - Update an employee's federal taxes
- getStateTaxes - Get an employee's state taxes
- updateStateTaxes - Update an employee's state taxes
- get - Get all events
- create - Create a new external payroll for a company
- get - Get external payrolls for a company
- retrieve - Get an external payroll
- delete - Delete an external payroll
- update - Update an external payroll
- calculateTaxes - Get tax suggestions for an external payroll
- listTaxLiabilities - Get tax liabilities
- updateTaxLiabilities - Update tax liabilities
- finalizeTaxLiabilities - Finalize tax liabilities options and convert into processed payrolls
- create - Create a flow
- create - Create a garnishment
- list - Get garnishments for an employee
- get - Get a garnishment
- update - Update a garnishment
- getChildSupportData - Get child support garnishment data
- get - Get a generated document
- update - Update a historical employee
- get - Get a company's holiday pay policy
- create - Create a holiday pay policy for a company
- update - Update a company's holiday pay policy
- delete - Delete a company's holiday pay policy
- addEmployees - Add employees to a company's holiday pay policy
- removeEmployees - Remove employees from a company's holiday pay policy
- getAuthorization - Get an employee's I-9 authorization
- update - Create or update an employee's I-9 authorization
- getDocumentOptions - Get an employee's I-9 verification document options
- getDocuments - Get an employee's I-9 verification documents
- createDocuments - Create an employee's I-9 authorization verification documents
- deleteDocument - Delete an employee's I-9 verification document
- employerSign - Employer sign an employee's Form I-9
- getInformationRequests - Get all information requests for a company
- getInfo - Get info about the current access token
- refreshToken - Refresh access token
- get - Retrieve invoicing data for companies
- createJob - Create a job
- getJobs - Get jobs for an employee
- getJob - Get a job
- update - Update a job
- delete - Delete an individual job
- getCompensations - Get compensations for a job
- createCompensation - Create a compensation
- getCompensation - Get a compensation
- updateCompensation - Update a compensation
- deleteCompensation - Delete a compensation
- create - Create a company location
- get - Get company locations
- retrieve - Get a location
- update - Update a location
- getMinimumWages - Get minimum wages for a location
- getDetails - Get a notification's details
- getCompanyNotifications - Get notifications for company
- list - Get all payrolls for a company
- createOffCycle - Create an off-cycle payroll
- getApprovedReversals - Get approved payroll reversals
- get - Get a single payroll
- update - Update a payroll by ID
- delete - Delete a payroll
- prepare - Prepare a payroll for update
- getReceipt - Get a single payroll receipt
- getBlockers - Get all payroll blockers for a company
- skip - Skip a payroll
- calculateGrossUp - Calculate gross up
- calculate - Calculate a payroll
- submit - Submit payroll
- cancel - Cancel a payroll
- getPayStub - Get an employee pay stub (pdf)
- getPayStubs - Get an employee's pay stubs
- generatePrintableChecks - Generate printable payroll checks (pdf)
- getV1CompaniesCompanyIdPayrollsIdPartnerDisbursements - Get partner disbursements for a payroll
- patchV1CompaniesCompanyIdPayrollsIdPartnerDisbursements - Update partner disbursements for a payroll
- create - Create a new pay schedule
- getAll - Get the pay schedules for a company
- getPreview - Preview pay schedule dates
- get - Get a pay schedule
- update - Update a pay schedule
- getPayPeriods - Get pay periods for a company
- getUnprocessedTerminationPeriods - Get termination pay periods for a company
- getAssignments - Get pay schedule assignments for a company
- previewAssignment - Preview pay schedule assignments for a company
- assign - Assign pay schedules for a company
- createCustom - Create a custom report
- postPayrollsPayrollUuidReportsGeneralLedger - Create a general ledger report
- getReportsRequestUuid - Get a report
- getTemplate - Get a report template
- create - Create a signatory
- list - Get all company signatories
- invite - Invite a signatory
- update - Update a signatory
- delete - Delete a signatory
- get - Get State Tax Requirements
- updateState - Update State Tax Requirements
- getAll - Get All Tax Requirement States
- calculateAccruingTimeOffHours - Calculate accruing time off hours
- get - Get a time off policy
- update - Update a time off policy
- getAll - Get all time off policies
- create - Create a time off policy
- addEmployees - Add employees to a time off policy
- removeEmployees - Remove employees from a time off policy
- updateBalance - Update employee time off hour balances
- deactivate - Deactivate a time off policy
- createSubscription - Create a webhook subscription
- listSubscriptions - List webhook subscriptions
- updateSubscription - Update a webhook subscription
- getSubscription - Get a webhook subscription
- deleteSubscription - Delete a webhook subscription
- verify - Verify the webhook subscription
- requestVerificationToken - Request the webhook subscription verification_token
All the methods listed above are available as standalone functions. These functions are ideal for use in applications running in the browser, serverless runtimes or other environments where application bundle size is a primary concern. When using a bundler to build your application, all unused functionality will be either excluded from the final bundle or tree-shaken away.
To read more about standalone functions, check FUNCTIONS.md.
Available standalone functions
-
achTransactionsGetAll
- Get all ACH transactions for a company -
bankAccountsCreate
- Create a company bank account -
bankAccountsCreateFromPlaidToken
- Create a bank account from a plaid processor token -
bankAccountsDeleteV1CompaniesCompanyIdBankAccountsBankAccountId
- Delete a company bank account -
bankAccountsGet
- Get all company bank accounts -
bankAccountsVerify
- Verify a company bank account -
companiesAcceptTermsOfService
- Accept terms of service for a company user -
companiesCreateAdmin
- Create an admin for the company -
companiesCreatePartnerManaged
- Create a partner managed company -
companiesFinishOnboarding
- Finish company onboarding -
companiesGet
- Get a company -
companiesGetCustomFields
- Get the custom fields of a company -
companiesGetOnboardingStatus
- Get the company's onboarding status -
companiesListAdmins
- Get all the admins at a company -
companiesMigrate
- Migrate company to embedded payroll -
companiesRetrieveTermsOfService
- Retrieve terms of service status for a company user -
companiesSuspensionsGet
- Get suspensions for this company -
companiesSuspensionsSuspend
- Suspend a company's account -
companiesUpdate
- Update a company -
companyAttachmentGetDownloadUrl
- Get a temporary url to download the Company Attachment file -
companyAttachmentsCreate
- Create Company Attachment and Upload File -
companyAttachmentsGetDetails
- Get Company Attachment Details -
companyAttachmentsGetList
- Get List of Company Attachments -
companyBenefitsCreate
- Create a company benefit -
companyBenefitsDelete
- Delete a company benefit -
companyBenefitsGet
- Get a company benefit -
companyBenefitsGetAll
- Get all benefits supported by Gusto -
companyBenefitsGetEmployeeBenefits
- Get all employee benefits for a company benefit -
companyBenefitsGetRequirements
- Get benefit fields requirements by ID -
companyBenefitsGetSummary
- Get company benefit summary by company benefit id. -
companyBenefitsGetSupported
- Get a supported benefit by ID -
companyBenefitsGetV1CompanyBenefitsCompanyBenefitIdContributionExclusions
- Get contribution exclusions for a company benefit -
companyBenefitsList
- Get benefits for a company -
companyBenefitsPutV1CompanyBenefitsCompanyBenefitIdContributionExclusions
- Update contribution exclusions for a company benefit -
companyBenefitsUpdate
- Update a company benefit -
companyBenefitsUpdateEmployeeBenefits
- Bulk update employee benefits for a company benefit -
companyFormsGet
- Get a company form -
companyFormsGetAll
- Get all company forms -
companyFormsGetPdf
- Get a company form pdf -
companyFormsSign
- Sign a company form -
contractorDocumentsGet
- Get a contractor document -
contractorDocumentsGetAll
- Get all contractor documents -
contractorDocumentsGetPdf
- Get the contractor document pdf -
contractorDocumentsSign
- Sign a contractor document -
contractorFormsGenerate1099
- Generate a 1099 form [DEMO] -
contractorFormsGet
- Get a contractor form -
contractorFormsGetPdf
- Get the contractor form pdf -
contractorFormsList
- Get all contractor forms -
contractorPaymentGroupsCreate
- Create a contractor payment group -
contractorPaymentGroupsDelete
- Cancel a contractor payment group -
contractorPaymentGroupsFund
- Fund a contractor payment group [DEMO] -
contractorPaymentGroupsGet
- Get a contractor payment group -
contractorPaymentGroupsGetList
- Get contractor payment groups for a company -
contractorPaymentGroupsGetV1ContractorPaymentGroupsIdPartnerDisbursements
- Get partner disbursements for a contractor payment group -
contractorPaymentGroupsPatchV1ContractorPaymentGroupsIdPartnerDisbursements
- Update partner disbursements for a contractor payment group -
contractorPaymentGroupsPreview
- Preview a contractor payment group -
contractorPaymentMethodGet
- Get a contractor's payment method -
contractorPaymentMethodGetBankAccounts
- Get all contractor bank accounts -
contractorPaymentMethodsCreateBankAccount
- Create a contractor bank account -
contractorPaymentMethodUpdate
- Update a contractor's payment method -
contractorPaymentsCreate
- Create a contractor payment -
contractorPaymentsDelete
- Cancel a contractor payment -
contractorPaymentsFund
- Fund a contractor payment [DEMO] -
contractorPaymentsGet
- Get a single contractor payment -
contractorPaymentsGetReceipt
- Get a single contractor payment receipt -
contractorPaymentsList
- Get contractor payments for a company -
contractorsCreate
- Create a contractor -
contractorsDelete
- Delete a contractor -
contractorsGet
- Get a contractor -
contractorsGetAddress
- Get a contractor address -
contractorsGetOnboardingStatus
- Get the contractor's onboarding status -
contractorsGetV1CompaniesCompanyIdContractorsPaymentDetails
- List contractor payment details -
contractorsList
- Get contractors of a company -
contractorsUpdate
- Update a contractor -
contractorsUpdateAddress
- Update a contractor's address -
contractorsUpdateOnboardingStatus
- Change the contractor's onboarding status -
departmentsAddPeople
- Add people to a department -
departmentsCreate
- Create a department -
departmentsDelete
- Delete a department -
departmentsGet
- Get a department -
departmentsGetAll
- Get all departments of a company -
departmentsRemovePeople
- Remove people from a department -
departmentsUpdate
- Update a department -
earningTypesCreate
- Create a custom earning type -
earningTypesDelete
- Deactivate an earning type -
earningTypesList
- Get all earning types for a company -
earningTypesUpdate
- Update an earning type -
employeeAddressesCreate
- Create an employee's home address -
employeeAddressesCreateWorkAddress
- Create an employee work address -
employeeAddressesDelete
- Delete an employee's home address -
employeeAddressesDeleteWorkAddress
- Delete an employee's work address -
employeeAddressesGet
- Get an employee's home addresses -
employeeAddressesGetWorkAddresses
- Get an employee's work addresses -
employeeAddressesRetrieveHomeAddress
- Get an employee's home address -
employeeAddressesRetrieveWorkAddress
- Get an employee work address -
employeeAddressesUpdate
- Update an employee's home address -
employeeAddressesUpdateWorkAddress
- Update an employee work address -
employeeBenefitsCreate
- Create an employee benefit -
employeeBenefitsCreateYtdBenefitAmountsFromDifferentCompany
- Create year-to-date benefit amounts from a different company -
employeeBenefitsDelete
- Delete an employee benefit -
employeeBenefitsGet
- Get all benefits for an employee -
employeeBenefitsGetYtdBenefitAmountsFromDifferentCompany
- Get year-to-date benefit amounts from a different company -
employeeBenefitsRetrieve
- Get an employee benefit -
employeeBenefitsUpdate
- Update an employee benefit -
employeeEmploymentsCreateRehire
- Create an employee rehire -
employeeEmploymentsCreateTermination
- Create an employee termination -
employeeEmploymentsDeleteRehire
- Delete an employee rehire -
employeeEmploymentsDeleteTermination
- Delete an employee termination -
employeeEmploymentsGetHistory
- Get employment history for an employee -
employeeEmploymentsGetRehire
- Get an employee rehire -
employeeEmploymentsGetTerminations
- Get terminations for an employee -
employeeEmploymentsRehire
- Update an employee rehire -
employeeEmploymentsUpdateTermination
- Update an employee termination -
employeeFormsGenerateW2
- Generate a W2 form [DEMO] -
employeeFormsGet
- Get an employee form -
employeeFormsGetPdf
- Get the employee form pdf -
employeeFormsList
- Get all employee forms -
employeeFormsSign
- Sign an employee form -
employeePaymentMethodCreate
- Create an employee bank account -
employeePaymentMethodDeleteBankAccount
- Delete an employee bank account -
employeePaymentMethodGet
- Get an employee's payment method -
employeePaymentMethodsGetBankAccounts
- Get all employee bank accounts -
employeePaymentMethodUpdate
- Update an employee's payment method -
employeePaymentMethodUpdateBankAccount
- Update an employee bank account -
employeesCreate
- Create an employee -
employeesCreateHistorical
- Create a historical employee -
employeesDelete
- Delete an onboarding employee -
employeesGet
- Get an employee -
employeesGetCustomFields
- Get an employee's custom fields -
employeesGetOnboardingStatus
- Get the employee's onboarding status -
employeesGetTimeOffActivities
- Get employee time off activities -
employeesGetV1CompaniesCompanyIdEmployeesPaymentDetails
- Get employee payment details for a company -
employeesList
- Get employees of a company -
employeesUpdate
- Update an employee. -
employeesUpdateOnboardingDocumentsConfig
- Update an employee's onboarding documents config -
employeesUpdateOnboardingStatus
- Update the employee's onboarding status -
employeeTaxSetupGetFederalTaxes
- Get an employee's federal taxes -
employeeTaxSetupGetStateTaxes
- Get an employee's state taxes -
employeeTaxSetupUpdateFederalTaxes
- Update an employee's federal taxes -
employeeTaxSetupUpdateStateTaxes
- Update an employee's state taxes -
eventsGet
- Get all events -
externalPayrollsCalculateTaxes
- Get tax suggestions for an external payroll -
externalPayrollsCreate
- Create a new external payroll for a company -
externalPayrollsDelete
- Delete an external payroll -
externalPayrollsFinalizeTaxLiabilities
- Finalize tax liabilities options and convert into processed payrolls -
externalPayrollsGet
- Get external payrolls for a company -
externalPayrollsListTaxLiabilities
- Get tax liabilities -
externalPayrollsRetrieve
- Get an external payroll -
externalPayrollsUpdate
- Update an external payroll -
externalPayrollsUpdateTaxLiabilities
- Update tax liabilities -
federalTaxDetailsGet
- Get Federal Tax Details -
federalTaxDetailsUpdate
- Update Federal Tax Details -
flowsCreate
- Create a flow -
garnishmentsCreate
- Create a garnishment -
garnishmentsGet
- Get a garnishment -
garnishmentsGetChildSupportData
- Get child support garnishment data -
garnishmentsList
- Get garnishments for an employee -
garnishmentsUpdate
- Update a garnishment -
generatedDocumentsGet
- Get a generated document -
historicalEmployeesUpdate
- Update a historical employee -
holidayPayPoliciesAddEmployees
- Add employees to a company's holiday pay policy -
holidayPayPoliciesCreate
- Create a holiday pay policy for a company -
holidayPayPoliciesDelete
- Delete a company's holiday pay policy -
holidayPayPoliciesGet
- Get a company's holiday pay policy -
holidayPayPoliciesRemoveEmployees
- Remove employees from a company's holiday pay policy -
holidayPayPoliciesUpdate
- Update a company's holiday pay policy -
i9VerificationCreateDocuments
- Create an employee's I-9 authorization verification documents -
i9VerificationDeleteDocument
- Delete an employee's I-9 verification document -
i9VerificationEmployerSign
- Employer sign an employee's Form I-9 -
i9VerificationGetAuthorization
- Get an employee's I-9 authorization -
i9VerificationGetDocumentOptions
- Get an employee's I-9 verification document options -
i9VerificationGetDocuments
- Get an employee's I-9 verification documents -
i9VerificationUpdate
- Create or update an employee's I-9 authorization -
industrySelectionGet
- Get a company industry selection -
industrySelectionUpdate
- Update a company industry selection -
informationRequestsGetInformationRequests
- Get all information requests for a company -
introspectionGetInfo
- Get info about the current access token -
introspectionRefreshToken
- Refresh access token -
invoicesGet
- Retrieve invoicing data for companies -
jobsAndCompensationsCreateCompensation
- Create a compensation -
jobsAndCompensationsCreateJob
- Create a job -
jobsAndCompensationsDelete
- Delete an individual job -
jobsAndCompensationsDeleteCompensation
- Delete a compensation -
jobsAndCompensationsGetCompensation
- Get a compensation -
jobsAndCompensationsGetCompensations
- Get compensations for a job -
jobsAndCompensationsGetJob
- Get a job -
jobsAndCompensationsGetJobs
- Get jobs for an employee -
jobsAndCompensationsUpdate
- Update a job -
jobsAndCompensationsUpdateCompensation
- Update a compensation -
locationsCreate
- Create a company location -
locationsGet
- Get company locations -
locationsGetMinimumWages
- Get minimum wages for a location -
locationsRetrieve
- Get a location -
locationsUpdate
- Update a location -
notificationsGetCompanyNotifications
- Get notifications for company -
notificationsGetDetails
- Get a notification's details -
paymentConfigsGet
- Get a company's payment configs -
paymentConfigsUpdate
- Update a company's payment configs -
payrollsCalculate
- Calculate a payroll -
payrollsCalculateGrossUp
- Calculate gross up -
payrollsCancel
- Cancel a payroll -
payrollsCreateOffCycle
- Create an off-cycle payroll -
payrollsDelete
- Delete a payroll -
payrollsGeneratePrintableChecks
- Generate printable payroll checks (pdf) -
payrollsGet
- Get a single payroll -
payrollsGetApprovedReversals
- Get approved payroll reversals -
payrollsGetBlockers
- Get all payroll blockers for a company -
payrollsGetPayStub
- Get an employee pay stub (pdf) -
payrollsGetPayStubs
- Get an employee's pay stubs -
payrollsGetReceipt
- Get a single payroll receipt -
payrollsGetV1CompaniesCompanyIdPayrollsIdPartnerDisbursements
- Get partner disbursements for a payroll -
payrollsList
- Get all payrolls for a company -
payrollsPatchV1CompaniesCompanyIdPayrollsIdPartnerDisbursements
- Update partner disbursements for a payroll -
payrollsPrepare
- Prepare a payroll for update -
payrollsSkip
- Skip a payroll -
payrollsSubmit
- Submit payroll -
payrollsUpdate
- Update a payroll by ID -
paySchedulesAssign
- Assign pay schedules for a company -
paySchedulesCreate
- Create a new pay schedule -
paySchedulesGet
- Get a pay schedule -
paySchedulesGetAll
- Get the pay schedules for a company -
paySchedulesGetAssignments
- Get pay schedule assignments for a company -
paySchedulesGetPayPeriods
- Get pay periods for a company -
paySchedulesGetPreview
- Preview pay schedule dates -
paySchedulesGetUnprocessedTerminationPeriods
- Get termination pay periods for a company -
paySchedulesPreviewAssignment
- Preview pay schedule assignments for a company -
paySchedulesUpdate
- Update a pay schedule -
recoveryCasesGet
- Get all recovery cases for a company -
recoveryCasesRedebit
- Initiate a redebit for a recovery case -
reportsCreateCustom
- Create a custom report -
reportsGetReportsRequestUuid
- Get a report -
reportsGetTemplate
- Get a report template -
reportsPostPayrollsPayrollUuidReportsGeneralLedger
- Create a general ledger report -
signatoriesCreate
- Create a signatory -
signatoriesDelete
- Delete a signatory -
signatoriesInvite
- Invite a signatory -
signatoriesList
- Get all company signatories -
signatoriesUpdate
- Update a signatory -
taxRequirementsGet
- Get State Tax Requirements -
taxRequirementsGetAll
- Get All Tax Requirement States -
taxRequirementsUpdateState
- Update State Tax Requirements -
timeOffPoliciesAddEmployees
- Add employees to a time off policy -
timeOffPoliciesCalculateAccruingTimeOffHours
- Calculate accruing time off hours -
timeOffPoliciesCreate
- Create a time off policy -
timeOffPoliciesDeactivate
- Deactivate a time off policy -
timeOffPoliciesGet
- Get a time off policy -
timeOffPoliciesGetAll
- Get all time off policies -
timeOffPoliciesRemoveEmployees
- Remove employees from a time off policy -
timeOffPoliciesUpdate
- Update a time off policy -
timeOffPoliciesUpdateBalance
- Update employee time off hour balances -
webhooksCreateSubscription
- Create a webhook subscription -
webhooksDeleteSubscription
- Delete a webhook subscription -
webhooksGetSubscription
- Get a webhook subscription -
webhooksListSubscriptions
- List webhook subscriptions -
webhooksRequestVerificationToken
- Request the webhook subscription verification_token -
webhooksUpdateSubscription
- Update a webhook subscription -
webhooksVerify
- Verify the webhook subscription -
wireInRequestsGet
- Get a single Wire In Request -
wireInRequestsList
- Get all Wire In Requests for a company -
wireInRequestsSubmit
- Submit a wire in request
React hooks built on TanStack Query are included in this SDK. These hooks and the utility functions provided alongside them can be used to build rich applications that pull data from the API using one of the most popular asynchronous state management library.
To learn about this feature and how to get started, check REACT_QUERY.md.
[!WARNING]
This feature is currently in preview and is subject to breaking changes within the current major version of the SDK as we gather user feedback on it.
Available React hooks
-
useAchTransactionsGetAll
- Get all ACH transactions for a company -
useBankAccountsCreateFromPlaidTokenMutation
- Create a bank account from a plaid processor token -
useBankAccountsCreateMutation
- Create a company bank account -
useBankAccountsDeleteV1CompaniesCompanyIdBankAccountsBankAccountIdMutation
- Delete a company bank account -
useBankAccountsGet
- Get all company bank accounts -
useBankAccountsVerifyMutation
- Verify a company bank account -
useCompaniesAcceptTermsOfServiceMutation
- Accept terms of service for a company user -
useCompaniesCreateAdminMutation
- Create an admin for the company -
useCompaniesCreatePartnerManagedMutation
- Create a partner managed company -
useCompaniesFinishOnboardingMutation
- Finish company onboarding -
useCompaniesGet
- Get a company -
useCompaniesGetCustomFields
- Get the custom fields of a company -
useCompaniesGetOnboardingStatus
- Get the company's onboarding status -
useCompaniesListAdmins
- Get all the admins at a company -
useCompaniesMigrateMutation
- Migrate company to embedded payroll -
useCompaniesRetrieveTermsOfServiceMutation
- Retrieve terms of service status for a company user -
useCompaniesSuspensionsGet
- Get suspensions for this company -
useCompaniesSuspensionsSuspendMutation
- Suspend a company's account -
useCompaniesUpdateMutation
- Update a company -
useCompanyAttachmentGetDownloadUrl
- Get a temporary url to download the Company Attachment file -
useCompanyAttachmentsCreateMutation
- Create Company Attachment and Upload File -
useCompanyAttachmentsGetDetails
- Get Company Attachment Details -
useCompanyAttachmentsGetList
- Get List of Company Attachments -
useCompanyBenefitsCreateMutation
- Create a company benefit -
useCompanyBenefitsDeleteMutation
- Delete a company benefit -
useCompanyBenefitsGet
- Get a company benefit -
useCompanyBenefitsGetAll
- Get all benefits supported by Gusto -
useCompanyBenefitsGetEmployeeBenefits
- Get all employee benefits for a company benefit -
useCompanyBenefitsGetRequirements
- Get benefit fields requirements by ID -
useCompanyBenefitsGetSummary
- Get company benefit summary by company benefit id. -
useCompanyBenefitsGetSupported
- Get a supported benefit by ID -
useCompanyBenefitsGetV1CompanyBenefitsCompanyBenefitIdContributionExclusions
- Get contribution exclusions for a company benefit -
useCompanyBenefitsList
- Get benefits for a company -
useCompanyBenefitsPutV1CompanyBenefitsCompanyBenefitIdContributionExclusionsMutation
- Update contribution exclusions for a company benefit -
useCompanyBenefitsUpdateEmployeeBenefitsMutation
- Bulk update employee benefits for a company benefit -
useCompanyBenefitsUpdateMutation
- Update a company benefit -
useCompanyFormsGet
- Get a company form -
useCompanyFormsGetAll
- Get all company forms -
useCompanyFormsGetPdf
- Get a company form pdf -
useCompanyFormsSignMutation
- Sign a company form -
useContractorDocumentsGet
- Get a contractor document -
useContractorDocumentsGetAll
- Get all contractor documents -
useContractorDocumentsGetPdf
- Get the contractor document pdf -
useContractorDocumentsSignMutation
- Sign a contractor document -
useContractorFormsGenerate1099Mutation
- Generate a 1099 form [DEMO] -
useContractorFormsGet
- Get a contractor form -
useContractorFormsGetPdf
- Get the contractor form pdf -
useContractorFormsList
- Get all contractor forms -
useContractorPaymentGroupsCreateMutation
- Create a contractor payment group -
useContractorPaymentGroupsDeleteMutation
- Cancel a contractor payment group -
useContractorPaymentGroupsFundMutation
- Fund a contractor payment group [DEMO] -
useContractorPaymentGroupsGet
- Get a contractor payment group -
useContractorPaymentGroupsGetList
- Get contractor payment groups for a company -
useContractorPaymentGroupsGetV1ContractorPaymentGroupsIdPartnerDisbursements
- Get partner disbursements for a contractor payment group -
useContractorPaymentGroupsPatchV1ContractorPaymentGroupsIdPartnerDisbursementsMutation
- Update partner disbursements for a contractor payment group -
useContractorPaymentGroupsPreviewMutation
- Preview a contractor payment group -
useContractorPaymentMethodGet
- Get a contractor's payment method -
useContractorPaymentMethodGetBankAccounts
- Get all contractor bank accounts -
useContractorPaymentMethodsCreateBankAccountMutation
- Create a contractor bank account -
useContractorPaymentMethodUpdateMutation
- Update a contractor's payment method -
useContractorPaymentsCreateMutation
- Create a contractor payment -
useContractorPaymentsDeleteMutation
- Cancel a contractor payment -
useContractorPaymentsFundMutation
- Fund a contractor payment [DEMO] -
useContractorPaymentsGet
- Get a single contractor payment -
useContractorPaymentsGetReceipt
- Get a single contractor payment receipt -
useContractorPaymentsList
- Get contractor payments for a company -
useContractorsCreateMutation
- Create a contractor -
useContractorsDeleteMutation
- Delete a contractor -
useContractorsGet
- Get a contractor -
useContractorsGetAddress
- Get a contractor address -
useContractorsGetOnboardingStatus
- Get the contractor's onboarding status -
useContractorsGetV1CompaniesCompanyIdContractorsPaymentDetails
- List contractor payment details -
useContractorsList
- Get contractors of a company -
useContractorsUpdateAddressMutation
- Update a contractor's address -
useContractorsUpdateMutation
- Update a contractor -
useContractorsUpdateOnboardingStatusMutation
- Change the contractor's onboarding status -
useDepartmentsAddPeopleMutation
- Add people to a department -
useDepartmentsCreateMutation
- Create a department -
useDepartmentsDeleteMutation
- Delete a department -
useDepartmentsGet
- Get a department -
useDepartmentsGetAll
- Get all departments of a company -
useDepartmentsRemovePeopleMutation
- Remove people from a department -
useDepartmentsUpdateMutation
- Update a department -
useEarningTypesCreateMutation
- Create a custom earning type -
useEarningTypesDeleteMutation
- Deactivate an earning type -
useEarningTypesList
- Get all earning types for a company -
useEarningTypesUpdateMutation
- Update an earning type -
useEmployeeAddressesCreateMutation
- Create an employee's home address -
useEmployeeAddressesCreateWorkAddressMutation
- Create an employee work address -
useEmployeeAddressesDeleteMutation
- Delete an employee's home address -
useEmployeeAddressesDeleteWorkAddressMutation
- Delete an employee's work address -
useEmployeeAddressesGet
- Get an employee's home addresses -
useEmployeeAddressesGetWorkAddresses
- Get an employee's work addresses -
useEmployeeAddressesRetrieveHomeAddress
- Get an employee's home address -
useEmployeeAddressesRetrieveWorkAddress
- Get an employee work address -
useEmployeeAddressesUpdateMutation
- Update an employee's home address -
useEmployeeAddressesUpdateWorkAddressMutation
- Update an employee work address -
useEmployeeBenefitsCreateMutation
- Create an employee benefit -
useEmployeeBenefitsCreateYtdBenefitAmountsFromDifferentCompanyMutation
- Create year-to-date benefit amounts from a different company -
useEmployeeBenefitsDeleteMutation
- Delete an employee benefit -
useEmployeeBenefitsGet
- Get all benefits for an employee -
useEmployeeBenefitsGetYtdBenefitAmountsFromDifferentCompany
- Get year-to-date benefit amounts from a different company -
useEmployeeBenefitsRetrieve
- Get an employee benefit -
useEmployeeBenefitsUpdateMutation
- Update an employee benefit -
useEmployeeEmploymentsCreateRehireMutation
- Create an employee rehire -
useEmployeeEmploymentsCreateTerminationMutation
- Create an employee termination -
useEmployeeEmploymentsDeleteRehireMutation
- Delete an employee rehire -
useEmployeeEmploymentsDeleteTerminationMutation
- Delete an employee termination -
useEmployeeEmploymentsGetHistory
- Get employment history for an employee -
useEmployeeEmploymentsGetRehire
- Get an employee rehire -
useEmployeeEmploymentsGetTerminations
- Get terminations for an employee -
useEmployeeEmploymentsRehireMutation
- Update an employee rehire -
useEmployeeEmploymentsUpdateTerminationMutation
- Update an employee termination -
useEmployeeFormsGenerateW2Mutation
- Generate a W2 form [DEMO] -
useEmployeeFormsGet
- Get an employee form -
useEmployeeFormsGetPdf
- Get the employee form pdf -
useEmployeeFormsList
- Get all employee forms -
useEmployeeFormsSignMutation
- Sign an employee form -
useEmployeePaymentMethodCreateMutation
- Create an employee bank account -
useEmployeePaymentMethodDeleteBankAccountMutation
- Delete an employee bank account -
useEmployeePaymentMethodGet
- Get an employee's payment method -
useEmployeePaymentMethodsGetBankAccounts
- Get all employee bank accounts -
useEmployeePaymentMethodUpdateBankAccountMutation
- Update an employee bank account -
useEmployeePaymentMethodUpdateMutation
- Update an employee's payment method -
useEmployeesCreateHistoricalMutation
- Create a historical employee -
useEmployeesCreateMutation
- Create an employee -
useEmployeesDeleteMutation
- Delete an onboarding employee -
useEmployeesGet
- Get an employee -
useEmployeesGetCustomFields
- Get an employee's custom fields -
useEmployeesGetOnboardingStatus
- Get the employee's onboarding status -
useEmployeesGetTimeOffActivities
- Get employee time off activities -
useEmployeesGetV1CompaniesCompanyIdEmployeesPaymentDetails
- Get employee payment details for a company -
useEmployeesList
- Get employees of a company -
useEmployeesUpdateMutation
- Update an employee. -
useEmployeesUpdateOnboardingDocumentsConfigMutation
- Update an employee's onboarding documents config -
useEmployeesUpdateOnboardingStatusMutation
- Update the employee's onboarding status -
useEmployeeTaxSetupGetFederalTaxes
- Get an employee's federal taxes -
useEmployeeTaxSetupGetStateTaxes
- Get an employee's state taxes -
useEmployeeTaxSetupUpdateFederalTaxesMutation
- Update an employee's federal taxes -
useEmployeeTaxSetupUpdateStateTaxesMutation
- Update an employee's state taxes -
useEventsGet
- Get all events -
useExternalPayrollsCalculateTaxes
- Get tax suggestions for an external payroll -
useExternalPayrollsCreateMutation
- Create a new external payroll for a company -
useExternalPayrollsDeleteMutation
- Delete an external payroll -
useExternalPayrollsFinalizeTaxLiabilitiesMutation
- Finalize tax liabilities options and convert into processed payrolls -
useExternalPayrollsGet
- Get external payrolls for a company -
useExternalPayrollsListTaxLiabilities
- Get tax liabilities -
useExternalPayrollsRetrieve
- Get an external payroll -
useExternalPayrollsUpdateMutation
- Update an external payroll -
useExternalPayrollsUpdateTaxLiabilitiesMutation
- Update tax liabilities -
useFederalTaxDetailsGet
- Get Federal Tax Details -
useFederalTaxDetailsUpdateMutation
- Update Federal Tax Details -
useFlowsCreateMutation
- Create a flow -
useGarnishmentsCreateMutation
- Create a garnishment -
useGarnishmentsGet
- Get a garnishment -
useGarnishmentsGetChildSupportData
- Get child support garnishment data -
useGarnishmentsList
- Get garnishments for an employee -
useGarnishmentsUpdateMutation
- Update a garnishment -
useGeneratedDocumentsGet
- Get a generated document -
useHistoricalEmployeesUpdateMutation
- Update a historical employee -
useHolidayPayPoliciesAddEmployeesMutation
- Add employees to a company's holiday pay policy -
useHolidayPayPoliciesCreateMutation
- Create a holiday pay policy for a company -
useHolidayPayPoliciesDeleteMutation
- Delete a company's holiday pay policy -
useHolidayPayPoliciesGet
- Get a company's holiday pay policy -
useHolidayPayPoliciesRemoveEmployeesMutation
- Remove employees from a company's holiday pay policy -
useHolidayPayPoliciesUpdateMutation
- Update a company's holiday pay policy -
useI9VerificationCreateDocumentsMutation
- Create an employee's I-9 authorization verification documents -
useI9VerificationDeleteDocumentMutation
- Delete an employee's I-9 verification document -
useI9VerificationEmployerSignMutation
- Employer sign an employee's Form I-9 -
useI9VerificationGetAuthorization
- Get an employee's I-9 authorization -
useI9VerificationGetDocumentOptions
- Get an employee's I-9 verification document options -
useI9VerificationGetDocuments
- Get an employee's I-9 verification documents -
useI9VerificationUpdateMutation
- Create or update an employee's I-9 authorization -
useIndustrySelectionGet
- Get a company industry selection -
useIndustrySelectionUpdateMutation
- Update a company industry selection -
useInformationRequestsGetInformationRequests
- Get all information requests for a company -
useIntrospectionGetInfo
- Get info about the current access token -
useIntrospectionRefreshTokenMutation
- Refresh access token -
useInvoicesGet
- Retrieve invoicing data for companies -
useJobsAndCompensationsCreateCompensationMutation
- Create a compensation -
useJobsAndCompensationsCreateJobMutation
- Create a job -
useJobsAndCompensationsDeleteCompensationMutation
- Delete a compensation -
useJobsAndCompensationsDeleteMutation
- Delete an individual job -
useJobsAndCompensationsGetCompensation
- Get a compensation -
useJobsAndCompensationsGetCompensations
- Get compensations for a job -
useJobsAndCompensationsGetJob
- Get a job -
useJobsAndCompensationsGetJobs
- Get jobs for an employee -
useJobsAndCompensationsUpdateCompensationMutation
- Update a compensation -
useJobsAndCompensationsUpdateMutation
- Update a job -
useLocationsCreateMutation
- Create a company location -
useLocationsGet
- Get company locations -
useLocationsGetMinimumWages
- Get minimum wages for a location -
useLocationsRetrieve
- Get a location -
useLocationsUpdateMutation
- Update a location -
useNotificationsGetCompanyNotifications
- Get notifications for company -
useNotificationsGetDetails
- Get a notification's details -
usePaymentConfigsGet
- Get a company's payment configs -
usePaymentConfigsUpdateMutation
- Update a company's payment configs -
usePayrollsCalculateGrossUpMutation
- Calculate gross up -
usePayrollsCalculateMutation
- Calculate a payroll -
usePayrollsCancelMutation
- Cancel a payroll -
usePayrollsCreateOffCycleMutation
- Create an off-cycle payroll -
usePayrollsDeleteMutation
- Delete a payroll -
usePayrollsGeneratePrintableChecksMutation
- Generate printable payroll checks (pdf) -
usePayrollsGet
- Get a single payroll -
usePayrollsGetApprovedReversals
- Get approved payroll reversals -
usePayrollsGetBlockers
- Get all payroll blockers for a company -
usePayrollsGetPayStub
- Get an employee pay stub (pdf) -
usePayrollsGetPayStubs
- Get an employee's pay stubs -
usePayrollsGetReceipt
- Get a single payroll receipt -
usePayrollsGetV1CompaniesCompanyIdPayrollsIdPartnerDisbursements
- Get partner disbursements for a payroll -
usePayrollsList
- Get all payrolls for a company -
usePayrollsPatchV1CompaniesCompanyIdPayrollsIdPartnerDisbursementsMutation
- Update partner disbursements for a payroll -
usePayrollsPrepareMutation
- Prepare a payroll for update -
usePayrollsSkipMutation
- Skip a payroll -
usePayrollsSubmitMutation
- Submit payroll -
usePayrollsUpdateMutation
- Update a payroll by ID -
usePaySchedulesAssignMutation
- Assign pay schedules for a company -
usePaySchedulesCreateMutation
- Create a new pay schedule -
usePaySchedulesGet
- Get a pay schedule -
usePaySchedulesGetAll
- Get the pay schedules for a company -
usePaySchedulesGetAssignments
- Get pay schedule assignments for a company -
usePaySchedulesGetPayPeriods
- Get pay periods for a company -
usePaySchedulesGetPreview
- Preview pay schedule dates -
usePaySchedulesGetUnprocessedTerminationPeriods
- Get termination pay periods for a company -
usePaySchedulesPreviewAssignmentMutation
- Preview pay schedule assignments for a company -
usePaySchedulesUpdateMutation
- Update a pay schedule -
useRecoveryCasesGet
- Get all recovery cases for a company -
useRecoveryCasesRedebitMutation
- Initiate a redebit for a recovery case -
useReportsCreateCustomMutation
- Create a custom report -
useReportsGetReportsRequestUuid
- Get a report -
useReportsGetTemplate
- Get a report template -
useReportsPostPayrollsPayrollUuidReportsGeneralLedgerMutation
- Create a general ledger report -
useSignatoriesCreateMutation
- Create a signatory -
useSignatoriesDeleteMutation
- Delete a signatory -
useSignatoriesInviteMutation
- Invite a signatory -
useSignatoriesList
- Get all company signatories -
useSignatoriesUpdateMutation
- Update a signatory -
useTaxRequirementsGet
- Get State Tax Requirements -
useTaxRequirementsGetAll
- Get All Tax Requirement States -
useTaxRequirementsUpdateStateMutation
- Update State Tax Requirements -
useTimeOffPoliciesAddEmployeesMutation
- Add employees to a time off policy -
useTimeOffPoliciesCalculateAccruingTimeOffHoursMutation
- Calculate accruing time off hours -
useTimeOffPoliciesCreateMutation
- Create a time off policy -
useTimeOffPoliciesDeactivateMutation
- Deactivate a time off policy -
useTimeOffPoliciesGet
- Get a time off policy -
useTimeOffPoliciesGetAll
- Get all time off policies -
useTimeOffPoliciesRemoveEmployeesMutation
- Remove employees from a time off policy -
useTimeOffPoliciesUpdateBalanceMutation
- Update employee time off hour balances -
useTimeOffPoliciesUpdateMutation
- Update a time off policy -
useWebhooksCreateSubscriptionMutation
- Create a webhook subscription -
useWebhooksDeleteSubscriptionMutation
- Delete a webhook subscription -
useWebhooksGetSubscription
- Get a webhook subscription -
useWebhooksListSubscriptions
- List webhook subscriptions -
useWebhooksRequestVerificationToken
- Request the webhook subscription verification_token -
useWebhooksUpdateSubscriptionMutation
- Update a webhook subscription -
useWebhooksVerifyMutation
- Verify the webhook subscription -
useWireInRequestsGet
- Get a single Wire In Request -
useWireInRequestsList
- Get all Wire In Requests for a company -
useWireInRequestsSubmitMutation
- Submit a wire in request
Certain SDK methods accept files as part of a multi-part request. It is possible and typically recommended to upload files as a stream rather than reading the entire contents into memory. This avoids excessive memory consumption and potentially crashing with out-of-memory errors when working with very large files. The following example demonstrates how to attach a file stream to a request.
[!TIP]
Depending on your JavaScript runtime, there are convenient utilities that return a handle to a file without reading the entire contents into memory:
- Node.js v20+: Since v20, Node.js comes with a native
openAsBlob
function innode:fs
.- Bun: The native
Bun.file
function produces a file handle that can be used for streaming file uploads.- Browsers: All supported browsers return an instance to a
File
when reading the value from an<input type="file">
element.- Node.js v18: A file stream can be created using the
fileFrom
helper fromfetch-blob/from.js
.
import { GustoEmbedded } from "@gusto/embedded-api";
import { openAsBlob } from "node:fs";
const gustoEmbedded = new GustoEmbedded({
companyAccessAuth: process.env["GUSTOEMBEDDED_COMPANY_ACCESS_AUTH"] ?? "",
});
async function run() {
const result = await gustoEmbedded.companyAttachments.create({
companyId: "<id>",
requestBody: {
document: await openAsBlob("example.file"),
category: "gep_notice",
},
});
console.log(result);
}
run();
Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
To change the default retry strategy for a single API call, simply provide a retryConfig object to the call:
import { GustoEmbedded } from "@gusto/embedded-api";
const gustoEmbedded = new GustoEmbedded({
companyAccessAuth: process.env["GUSTOEMBEDDED_COMPANY_ACCESS_AUTH"] ?? "",
});
async function run() {
const result = await gustoEmbedded.introspection.getInfo({}, {
retries: {
strategy: "backoff",
backoff: {
initialInterval: 1,
maxInterval: 50,
exponent: 1.1,
maxElapsedTime: 100,
},
retryConnectionErrors: false,
},
});
console.log(result);
}
run();
If you'd like to override the default retry strategy for all operations that support retries, you can provide a retryConfig at SDK initialization:
import { GustoEmbedded } from "@gusto/embedded-api";
const gustoEmbedded = new GustoEmbedded({
retryConfig: {
strategy: "backoff",
backoff: {
initialInterval: 1,
maxInterval: 50,
exponent: 1.1,
maxElapsedTime: 100,
},
retryConnectionErrors: false,
},
companyAccessAuth: process.env["GUSTOEMBEDDED_COMPANY_ACCESS_AUTH"] ?? "",
});
async function run() {
const result = await gustoEmbedded.introspection.getInfo({});
console.log(result);
}
run();
GustoEmbeddedError
is the base class for all HTTP error responses. It has the following properties:
Property | Type | Description |
---|---|---|
error.message |
string |
Error message |
error.httpMeta.response |
Response |
HTTP response. Access to headers and more. |
error.httpMeta.request |
Request |
HTTP request. Access to headers and more. |
error.data$ |
Optional. Some errors may contain structured data. See Error Classes. |
import { GustoEmbedded } from "@gusto/embedded-api";
import { GustoEmbeddedError } from "@gusto/embedded-api/models/errors/gustoembeddederror.js.js";
import { UnprocessableEntityErrorObject } from "@gusto/embedded-api/models/errors/unprocessableentityerrorobject.js";
const gustoEmbedded = new GustoEmbedded();
async function run() {
try {
const result = await gustoEmbedded.companies.createPartnerManaged({
systemAccessAuth: process.env["GUSTOEMBEDDED_SYSTEM_ACCESS_AUTH"] ?? "",
}, {
requestBody: {
user: {
firstName: "Frank",
lastName: "Ocean",
email: "frank@example.com",
phone: "2345558899",
},
company: {
name: "Frank's Ocean, LLC",
tradeName: "Frank’s Ocean",
ein: "123456789",
contractorOnly: false,
},
},
});
console.log(result);
} catch (error) {
// The base class for HTTP error responses
if (error instanceof GustoEmbeddedError) {
console.log(error.message);
console.log(error.httpMeta.response.status);
console.log(error.httpMeta.response.headers);
console.log(error.httpMeta.request);
// Depending on the method different errors may be thrown
if (error instanceof UnprocessableEntityErrorObject) {
console.log(error.data$.errors); // EntityErrorObject[]
}
}
}
}
run();
Primary error:
-
GustoEmbeddedError
: The base class for HTTP error responses.
Less common errors (12)
Network errors:
-
ConnectionError
: HTTP client was unable to make a request to a server. -
RequestTimeoutError
: HTTP request timed out due to an AbortSignal signal. -
RequestAbortedError
: HTTP request was aborted by the client. -
InvalidRequestError
: Any input used to create a request is invalid. -
UnexpectedClientError
: Unrecognised or unexpected error.
Inherit from GustoEmbeddedError
:
-
UnprocessableEntityErrorObject
: Unprocessable Entity This may happen when the body of your request contains errors such asinvalid_attribute_value
, or the request fails due to aninvalid_operation
. See the Errors Categories guide for more details. Applicable to 139 of 260 methods.* -
NotFoundErrorObject
: Not Found The requested resource does not exist. Make sure the provided ID/UUID is valid. Status code404
. Applicable to 4 of 260 methods.* -
UnprocessableEntityErrorObject1
: Unprocessable Entity This may happen when the body of your request contains errors such asinvalid_attribute_value
, or the request fails due to aninvalid_operation
. See the Errors Categories guide for more details. Status code422
. Applicable to 4 of 260 methods.* -
PayrollBlockersError
: Payroll Blockers Error For detailed information, see the Payroll Blockers guide. Status code422
. Applicable to 4 of 260 methods.* -
DeleteV1CompanyBenefitsCompanyBenefitIdResponseBody
: Unprocessable Entity. Status code422
. Applicable to 1 of 260 methods.* -
CompanySuspensionCreationErrors
: Unprocessable Entity This may happen when the body of your request contains errors such asinvalid_attribute_value
, or the request fails due to aninvalid_operation
. See the Errors Categories guide for more details. Status code422
. Applicable to 1 of 260 methods.* -
ResponseValidationError
: Type mismatch between the data returned from the server and the structure expected by the SDK. Seeerror.rawValue
for the raw value anderror.pretty()
for a nicely formatted multi-line string.
* Check the method documentation to see if the error is applicable.
You can override the default server globally by passing a server name to the server: keyof typeof ServerList
optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the names associated with the available servers:
Name | Server | Description |
---|---|---|
demo |
https://api.gusto-demo.com |
Demo |
prod |
https://api.gusto.com |
Prod |
import { GustoEmbedded } from "@gusto/embedded-api";
const gustoEmbedded = new GustoEmbedded({
server: "prod",
companyAccessAuth: process.env["GUSTOEMBEDDED_COMPANY_ACCESS_AUTH"] ?? "",
});
async function run() {
const result = await gustoEmbedded.introspection.getInfo({});
console.log(result);
}
run();
The default server can also be overridden globally by passing a URL to the serverURL: string
optional parameter when initializing the SDK client instance. For example:
import { GustoEmbedded } from "@gusto/embedded-api";
const gustoEmbedded = new GustoEmbedded({
serverURL: "https://api.gusto-demo.com",
companyAccessAuth: process.env["GUSTOEMBEDDED_COMPANY_ACCESS_AUTH"] ?? "",
});
async function run() {
const result = await gustoEmbedded.introspection.getInfo({});
console.log(result);
}
run();
The TypeScript SDK makes API calls using an HTTPClient
that wraps the native
Fetch API. This
client is a thin wrapper around fetch
and provides the ability to attach hooks
around the request lifecycle that can be used to modify the request or handle
errors and response.
The HTTPClient
constructor takes an optional fetcher
argument that can be
used to integrate a third-party HTTP client or when writing tests to mock out
the HTTP client and feed in fixtures.
The following example shows how to use the "beforeRequest"
hook to to add a
custom header and a timeout to requests and how to use the "requestError"
hook
to log errors:
import { GustoEmbedded } from "@gusto/embedded-api";
import { HTTPClient } from "@gusto/embedded-api/lib/http";
const httpClient = new HTTPClient({
// fetcher takes a function that has the same signature as native `fetch`.
fetcher: (request) => {
return fetch(request);
}
});
httpClient.addHook("beforeRequest", (request) => {
const nextRequest = new Request(request, {
signal: request.signal || AbortSignal.timeout(5000)
});
nextRequest.headers.set("x-custom-header", "custom value");
return nextRequest;
});
httpClient.addHook("requestError", (error, request) => {
console.group("Request Error");
console.log("Reason:", `${error}`);
console.log("Endpoint:", `${request.method} ${request.url}`);
console.groupEnd();
});
const sdk = new GustoEmbedded({ httpClient });
You can setup your SDK to emit debug logs for SDK requests and responses.
You can pass a logger that matches console
's interface as an SDK option.
[!WARNING] Beware that debug logging will reveal secrets, like API tokens in headers, in log messages printed to a console or files. It's recommended to use this feature only during local development and not in production.
import { GustoEmbedded } from "@gusto/embedded-api";
const sdk = new GustoEmbedded({ debugLogger: console });
You can also enable a default debug logger by setting an environment variable GUSTOEMBEDDED_DEBUG
to true.
This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.
While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation. We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.