π§Ύ Retrieve Paystub Data
Endpoint: GET /paystubs
Used to fetch paystub records for a given employee or payroll period. Each record includes gross pay, deductions, net pay, benefits, and the corresponding pay cycle.
Introduction
Once youβve submitted payroll using the π΅ Submit Payroll endpoint, individual paystubs become available for employees included in that payroll batch. These paystubs serve as detailed records of each employeeβs earnings, deductions, and payment information for a given period.
The GET /paystubs Endpoint lets you retrieve this data either by employee ID, payroll batch ID, or date range. If you're unfamiliar with how employees are added or payroll is submitted, we strongly recommend reviewing β Add Employee and π΅ Submit Payroll before continuing. These sections explain where to get valid employee IDs and payroll batch references.
In this section, weβll walk through several retrieval scenarios and explore how to interpret the returned data structure. Weβll also cover common edge cases, such as what to do if your response is empty or missing expected data.
Filtering and Query Options
You can request paystub data in multiple ways depending on the context of your application. A typical call might look like this:
bashCopyEditGET /paystubs?employee_id=EMP123This retrieves all available pay stubs for employee EMP123. Alternatively, you can request all pay stubs from a specific payroll run:
bashCopyEditGET /paystubs?payroll_id=PR456You may also choose to filter by a date range using from and to parameters:
vbnetCopyEditGET /paystubs?from=2024-01-01&to=2024-01-31Each of these methods supports pagination and filtering to avoid large or excessive payloads.

Above is an example of how the standard two-employee payroll submission works in the FlexPay app.
When the request is successful, FlexPay returns a JSON object containing one or more paystub records. Each record includes key values like gross and net pay, breakdowns of deductions, and issue dates.
If pagination is required, a next_page_token will also be included in the response, so you can continue fetching results in batches.
Understanding the Response Format
Each paystub contains nested sections, including:
employee_id
payroll_id
period_start / period_end
gross_pay and net_pay
deductions object (with
taxes,benefits, etc.)issued_date
Hereβs what a typical JSON response might look like:
Figure 2. Example paystub JSON response with gross-to-net breakdown
Common Pitfalls and Edge Cases
If your query returns no results, there are a few likely causes:
The employee ID is invalid or not yet associated with a submitted payroll
The payroll run did not complete successfully (see π΅ Submit Payroll for validation checks)
Your date range does not overlap with any processed pay periods
The pay stubs havenβt been generated yet (there may be a short delay after submission)
In many of these cases, simply adjusting your query can resolve the issue. For example, removing or relaxing filters will return more data. Double-checking employee IDs from the β Add Employee section ensures youβre querying valid records.
β οΈ Warning: Relying only on date ranges without anchoring your search to
employee_idorpayroll_idcan increase load and lead to incomplete results in multi-tenant systems. Use identifiers whenever possible.
Also, note that data is read-only β you cannot edit, regenerate, or revoke paystubs from this endpoint. If somethingβs wrong, youβll need to cancel and re-run the payroll using the proper tools.
Tips for Implementation
Always store employee IDs returned from β Add Employee locally, so you can retrieve pay stubs without additional lookups
Display key paystub info (gross, net, issued date) in a user dashboard to reduce support requests
Use
next_page_tokento lazily load large datasets for reporting or internal admin portals
β
Summary
This section explained how to access paystub data via GET /paystubs. You learned how to filter by employee, batch ID, or date range β and how to handle missing or paginated data. With this information, you can build an employee-facing pay history UI or plug into internal reporting workflows.
π Whatβs Next: π₯ Webhooks Overview
Retrieving pay stubs manually is useful, but wouldnβt it be better to get notified as soon as new ones are available? Thatβs where webhooks come in. In the next section, weβll walk through how to set up secure, real-time webhooks so your app can:
Detect when a paystub is generated
Respond automatically to payroll events
Eliminate the need to constantly poll the API
π£ Hint: FlexPay will attempt to deliver each webhook event up to three times. Acknowledge delivery with a
200 OKor your system may be marked unreliable. We'll walk through all of this next.
β‘οΈ Continue to π₯ Webhooks Overview
Last updated
Was this helpful?