# Area 5: Run payroll

Generated 2026-12-01 from the Everee docs (branch v1.0). Part of https://files.everee.com/everee-payroll-infrastructure-explainer.md

```text
GOAL
Build the payroll-run experience: show each company's runs, add pay as items, calculate, resolve blockers, approve, and follow the funding and payouts until workers are paid.

READ FIRST (each page also has a Markdown version at the same URL with .md added; the docs index is https://developer.everee.com/llms.txt)
- https://developer.everee.com/docs/running-payroll
- https://developer.everee.com/docs/funding-payroll
- https://developer.everee.com/docs/corrections-and-off-cycle-runs
- https://developer.everee.com/docs/after-payroll
- https://developer.everee.com/reference/payroll-run-api-guide
- https://developer.everee.com/docs/gross-pay-basics
- https://developer.everee.com/reference/add-payroll-run-items
- https://developer.everee.com/reference/list-payroll-run-blockers
- https://developer.everee.com/reference/approve-payroll-run
- https://developer.everee.com/reference/retrieve-payroll-run-funding
- https://developer.everee.com/reference/net-payouts-api-guide
- https://developer.everee.com/reference/requirements-api-guide
- https://developer.everee.com/docs/payroll-run-events
- Reference implementation: the Payroll Run Simulator at https://files.everee.com/simulators/payroll-run.html. Walk it before you design the screens. Its developer console shows each call, the live run JSON, the signed webhooks and the code, and its API notes map each part of the screen to the fields behind it. Match its behavior, not its look.

BUILD
- Runs: list them (GET /payroll-runs), open a regular run with a target pay date (POST /payroll-runs/{id}/open), or create an off-cycle run (POST /payroll-runs/off-cycle). Offer only the dates from GET /payroll-runs/{id}/pay-dates (or GET /payroll-runs/off-cycle/pay-dates before creating an off-cycle run), read when the choice is shown: earliestPayDate and earliestPayDateUntil (when it moves later), options in a 30-day window (each payDate with its fundingDate and approvalDeadline, to show before the user picks), and holidays to explain missing weekdays. If opening returns 400 because the earliest date moved, read the dates again. Show dates and times in the user's own time zone; the API sends UTC.
- Pay: POST /payroll-runs/{id}/items with a body of {"items": [...]}: each item has your own externalId, the worker (externalWorkerId or workerId), label, payCode and amount, plus unitCount and unitRate for pay per unit. Everee sets type, payableModel and earningTimestamp (the run's periodEnd) and ignores them if sent. Up to 1,000 items per request, under the right pay codes. Remove an item with DELETE, or exclude a worker's payment.
- Calculate (POST /payroll-runs/{id}/calculate), then show blockers (GET /payroll-runs/{id}/blockers) with their resolutionInstructions, and the payments (GET /payroll-runs/{id}/payments) for review.
- Approve (POST /payroll-runs/{id}/approve) before the run's approvalDeadline, with a reopen action until reopenDeadline.
- Funding and payouts: the run's fundingDate (debit day) and expectedPaidDate (while PROCESSING), GET /payroll-runs/{id}/funding, a retry action (POST /payroll-runs/{id}/funding/retry) when funding needs action, and net payouts for each worker with their sendDate and expectedClearingDate. Show every date from these fields; never work one out.

OPERATIONS (all paths are under https://api.everee.com/integration/v1; each reference page, with .md added, lists its request and response fields)
- GET /payroll-runs | operationId list-payroll-runs | https://developer.everee.com/reference/list-payroll-runs.md
- GET /payroll-runs/{id} | operationId retrieve-payroll-run | https://developer.everee.com/reference/retrieve-payroll-run.md
- GET /payroll-runs/off-cycle/pay-dates | operationId list-off-cycle-pay-dates | https://developer.everee.com/reference/list-off-cycle-pay-dates.md
- POST /payroll-runs/off-cycle | operationId create-off-cycle-payroll-run | https://developer.everee.com/reference/create-off-cycle-payroll-run.md
- GET /payroll-runs/{id}/pay-dates | operationId list-payroll-run-pay-dates | https://developer.everee.com/reference/list-payroll-run-pay-dates.md
- POST /payroll-runs/{id}/open | operationId open-payroll-run | https://developer.everee.com/reference/open-payroll-run.md
- PUT /payroll-runs/{id}/pay-date | operationId update-payroll-run-pay-date | https://developer.everee.com/reference/update-payroll-run-pay-date.md
- GET /payroll-runs/{id}/items | operationId list-payroll-run-items | https://developer.everee.com/reference/list-payroll-run-items.md
- POST /payroll-runs/{id}/items | operationId add-payroll-run-items | https://developer.everee.com/reference/add-payroll-run-items.md
- DELETE /payroll-runs/{id}/items/{itemId} | operationId remove-payroll-run-item | https://developer.everee.com/reference/remove-payroll-run-item.md
- GET /payroll-runs/{id}/payments | operationId list-payroll-run-payments | https://developer.everee.com/reference/list-payroll-run-payments.md
- POST /payroll-runs/{id}/payments/{paymentId}/exclude | operationId exclude-payroll-run-payment | https://developer.everee.com/reference/exclude-payroll-run-payment.md
- POST /payroll-runs/{id}/calculate | operationId calculate-payroll-run | https://developer.everee.com/reference/calculate-payroll-run.md
- GET /payroll-runs/{id}/blockers | operationId list-payroll-run-blockers | https://developer.everee.com/reference/list-payroll-run-blockers.md
- POST /payroll-runs/{id}/approve | operationId approve-payroll-run | https://developer.everee.com/reference/approve-payroll-run.md
- POST /payroll-runs/{id}/reopen | operationId reopen-payroll-run | https://developer.everee.com/reference/reopen-payroll-run.md
- GET /payroll-runs/{id}/funding | operationId retrieve-payroll-run-funding | https://developer.everee.com/reference/retrieve-payroll-run-funding.md
- POST /payroll-runs/{id}/funding/retry | operationId retry-payroll-run-funding | https://developer.everee.com/reference/retry-payroll-run-funding.md

RULES
- Payroll runs are the only way to pay workers in Payroll Infrastructure. The Payables and Timesheets endpoints that create pay return 400.
- The externalId on an item is its idempotency key. Build it from stable data, never a timestamp or random value, and reuse it on a retry. Adding items is all-or-nothing: if any item fails, nothing is saved and the 400 lists every failing item.
- Read approvalDeadline, reopenDeadline and processingBlockedDeadline from the run. Never work deadlines out yourself. Every change sends payroll-run.status-changed: wait for it instead of polling, and calculate again after any change before approving. A request the run's status doesn't allow returns 409.
- Correct pay that has already been paid by resending the item to a later run with the same externalId, the FULL corrected amount (not the difference), and correction-authorized=true.
- Everee does not contact workers. Your product tells them about their pay (net-payout.paid carries each payout), fixes returned deposits (net-payout.returned, then update the bank account and Everee retries), and delivers pay statements (Worker Payment History API) and W-2s and 1099s (list-files with document-type=TAXES). Workers are paid by direct deposit only.
- Lists are cursor-paginated: send nextCursor as after until hasNextPage is false. Don't send page, size or sort.
- When funding needs action, show resolutionInstructions and offer the retry before processingBlockedDeadline. A returned debit after workers were paid means no run can be approved until it is repaid: tell the user to contact Everee Customer Success. Never collect bank credentials yourself.
- Build every flow as a loop around reads that tell you what is left: make a change, read the state again (readiness.missing for onboarding, a run's blockers and the requirements behind them for payroll, a funding's status and resolutionInstructions), and act on what is left. Never hard-code the steps: codes appear and disappear. Map each code you know to a screen, and show resolutionInstructions for any you don't. Use webhooks (company-onboarding.status-changed, requirement.created, payroll-run.status-changed) to know when to read again, not instead of the read. A requirement does NOT open when a worker is created or changed: it opens only when a payroll calculation or a returned deposit finds the problem, so calculate runs early.
- Base URL https://api.everee.com/integration/v1. The partner key is the HTTP Basic user name for the Company Onboarding API: the test key (zk_test_...) creates and reaches only Sandbox companies and the production key (zk_prod_...), issued after Everee approves the integration, only Production companies. A company in the other environment returns 404. The company key (tsk_...) is the HTTP Basic user name for everything else, plus an x-everee-tenant-id header holding the company's id.
- Keep every key on the server. Everee rejects browser requests. Read keys from a secrets store, never log them, never hard-code them.
- Rate limit: 100 operations per 5 seconds per key (see the RateLimit-Policy header). Back off on 429.
- Only payables and payroll run items have an idempotency key (externalId). Make other creates safe yourself: look first, keep the Everee ID next to your own record.
- Test against a sandbox instance (tsk_test_... keys) before production. Nothing in a URL selects the environment; the key does. Sandbox company creation is limited (25 alive at once, 50 created in any rolling 7 days; evaluation access before the agreement is signed: 1 and 2, 14 days, companies created without an agreement), and each Sandbox company is limited to 250 workers, 100 off-cycle runs in 7 days and 100 payroll calculations in 24 hours: a refused request returns 429 with when the next can be created, and a sandbox company you no longer need can be retired.

DONE WHEN
- In a sandbox company, I can open a run, add items, calculate, fix a blocker, approve, reopen, and see its funding, from my UI.
- Retrying an items request creates no duplicate, and every failing item in a rejected request is shown to the user.

TESTS TO WRITE
- Sending the same items twice with the same externalId results in one set of items on the run (a unit test on the externalId builder, and a call to GET /payroll-runs/{id}/items).
- The externalId is built from stable data: the same inputs always give the same id.
- A rejected items request (400) shows every failing item with its errorCode and saves nothing, so the corrected request can be resent whole.
- Any change after a calculation sends the run back to OPEN, and the screen requires a new calculation before it offers Approve.
- A 409 from a status the run doesn't allow is shown to the user, not retried blindly.
- A funding that needs action shows its resolutionInstructions, and the retry action is offered only before processingBlockedDeadline.

If a fact you need isn't in the docs, ask me. Don't guess endpoint paths, field names or business rules.
```
