Payroll
API reference for payroll connections, runs, employees, tax forms, and calculator.
Payroll connections, runs, employees, pay stubs, tax forms, and the payroll calculator. All endpoints require tenant context via entityId unless noted.
Authentication
- Session cookie — set when signed in via the web app
- API key — pass via the
x-api-keyheader
All endpoints require authentication and entity access.
Endpoints
Connections and runs
| Method | Endpoint | Description |
|---|---|---|
GET | /api/payroll?entityId= | List connections and runs for the entity |
POST | /api/payroll | Actions: create-connection, manual-run, sync |
PATCH | /api/payroll | Update connection settings |
DELETE | /api/payroll?connectionId= | Delete a connection |
GET /api/payroll
Query parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
entityId | string | Yes | Entity ID for tenant context |
Response: Array of connections and runs, or a single run depending on query.
POST /api/payroll
Request body:
{
"entityId": "string",
"action": "create-connection" | "manual-run" | "sync",
"connectionId": "string",
"provider": "gusto" | "adp" | "deel" | "remote",
"credentials": { }
}PATCH /api/payroll
Request body: Connection fields to update (e.g., sync frequency, credentials).
DELETE /api/payroll
Query parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
connectionId | string | Yes | Connection to delete |
entityId | string | Yes | Entity ID for tenant context |
Employees
| Method | Endpoint | Description |
|---|---|---|
GET | /api/payroll/employees?entityId= | List employees for the entity |
POST | /api/payroll/employees | Create employee |
PATCH | /api/payroll/employees/[id] | Update employee |
DELETE | /api/payroll/employees/[id] | Terminate employee |
GET | /api/payroll/employees/[id]/stubs | Pay stub history for employee |
GET /api/payroll/employees
Query parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
entityId | string | Yes | Entity ID for tenant context |
Response: Array of employee records with name, status, compensation, and tax info.
POST /api/payroll/employees
Request body:
{
"entityId": "string",
"name": "string",
"email": "string",
"employeeType": "employee" | "contractor",
"compensation": { "amount": 0, "currency": "USD", "period": "monthly" },
"taxInfo": { }
}PATCH /api/payroll/employees/[id]
Request body: Employee fields to update.
DELETE /api/payroll/employees/[id]
Terminates the employee. Request body may include termination date and reason.
GET /api/payroll/employees/[id]/stubs
Response: Array of pay stubs with gross pay, withholdings, net pay, and period.
Runs
| Method | Endpoint | Description |
|---|---|---|
GET | /api/payroll/runs/[id]?entityId= | Run detail with line items |
PATCH | /api/payroll/runs/[id] | Approve run |
GET /api/payroll/runs/[id]
Query parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
entityId | string | Yes | Entity ID for tenant context |
Response: Run with status, period, total amounts, and per-employee line items.
PATCH /api/payroll/runs/[id]
Request body:
{
"action": "approve"
}Calculator
| Method | Endpoint | Description |
|---|---|---|
POST | /api/payroll/calculate | Preview or submit calculated payroll |
POST /api/payroll/calculate
Request body:
{
"entityId": "string",
"mode": "preview" | "submit",
"runDate": "YYYY-MM-DD",
"employees": [
{
"employeeId": "string",
"grossPay": 0,
"deductions": [ ],
"employerTaxes": [ ]
}
]
}Response: For preview, returns net pay and tax withholdings per employee. For submit, creates the payroll run and returns the run ID.
Tax forms
| Method | Endpoint | Description |
|---|---|---|
GET | /api/payroll/tax-forms?form=&entityId=&year= | W-2, 1099, 941, 940 |
GET /api/payroll/tax-forms
Query parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
form | string | Yes | w2, 1099, 941, or 940 |
entityId | string | Yes | Entity ID for tenant context |
year | number | Yes | Tax year (e.g., 2024) |
quarter | number | No | For 941 only: 1, 2, 3, or 4 |
Response: Tax form data in the format required for filing (SSA/IRS) or distribution to recipients.