# Staff and payroll

Employees, hours, leave and payslips.

## PUT /v1/employees/{externalRef}

**Create or update an employee**

PUT, not POST: you name the person, so the same call repeated is the same person and no Idempotency-Key is needed. null leaves a field alone — a caller that does not hold salaries sends a null gross on every sync, and a null that overwrote would zero the payroll.

Parameters:

- `externalRef` (path, required): Your own id for this person, e.g. TM-4471.

Body:

- `name` string: Required on first push. A later change is recorded as a dated rename, so a payslip already issued keeps the name it was issued in.
- `email` string
- `employeeNo` string: A label, printed on the payslip. Not the key: companies renumber staff.
- `startedOn` string (date): Leave cycles run from this date, not from January.
- `endedOn` string (date)
- `gross` number: Per period. Omit if you do not hold salaries.
- `periods` integer: 12, 13, 26, 52: Default 12.
- `employmentType` string: EMPLOYEE, DIRECTOR, CONTRACTOR
- `sourceSystem` string: Your system's name, the same on every call (for example shop). Identifies your references.

```json
{
  "name": "string",
  "email": "string",
  "employeeNo": "string",
  "startedOn": "2026-12-01"
}
```

Answers:

- `200` employeeId, partyId, accountCode, created
- `409` This API key has no default company
- `422` Refused, with the reason in words

## GET /v1/leave-types

**The kinds of leave this company has**

ReconSmith's codes, not yours. Seeded from the company's country — for South Africa, the BCEA minimums — and editable, because a contract may give more and never less.

Answers:

- `200` leaveTypes: [{ code, name, unit, daysPerCycle, cycleMonths, accrues, minServiceMonths, tracksBalance, isPaid, basis }]

## GET /v1/employees/{externalRef}/leave

**What this person has left**

Worked out every time from accrual, adjustments and leave taken. Never a stored number. Cycles run from the person's start date: somebody who started in March has an annual cycle ending in February.

Parameters:

- `externalRef` (path, required)
- `asAt` (query): Defaults to today in the company's own time zone.
- `sourceSystem` (query): Your system's name, the same on every call (for example shop). Identifies your references.

Answers:

- `200` employeeRef, asAt, balances: [{ code, name, unit, cycleStart, cycleEnd, entitlement, accrued, adjustments, taken, balance, availableFrom, basis }]. balance is null where the type tracks none, such as unpaid leave.
- `404` Nobody here is known by that reference

## POST /v1/employees/{externalRef}/leave

**Record approved leave**

You own the request and the approval; this records what was taken. Idempotent on externalRef, so a retry after a timeout cannot deduct the same week twice — the second post returns the same leaveId with created = false. days is sent, never derived: ReconSmith does not know your working week, shift patterns or public holidays.

unpaid_days (136): with code ANNUAL, days - unpaid_days come off the annual balance and unpaid_days are recorded as unpaid leave (external_ref + '-UNPAID'). The answer carries annual_days, unpaid_days, recounted and recount_note.

Parameters:

- `externalRef` (path, required)

Body:

- `externalRef` string, required: Your id for the leave request, e.g. APP-LR-9912. The idempotency key.
- `code` string, required: From GET /v1/leave-types.
- `firstDay` string (date), required
- `lastDay` string (date), required
- `days` number, required: Working days, as you count them.
- `halfDay` boolean: Default false.
- `note` string
- `sourceSystem` string: Your system's name, the same on every call (for example shop). Identifies your references.
- `unpaid_days` number: Annual leave only (136). How many of days went over the annual balance when the person applied; recorded as unpaid leave and taken off the pay. The balance is counted again when the leave is posted, and if it allows a different split the answer says so (recounted, recount_note).

```json
{
  "externalRef": "string",
  "code": "string",
  "firstDay": "2026-12-01",
  "lastDay": "2026-12-01",
  "days": 100
}
```

Answers:

- `200` leaveId, created, balanceAfter
- `404` Nobody here is known by that reference
- `422` Refused: no such leave type, service not yet served, or the balance would go negative

## POST /v1/employees/{externalRef}/leave/{leaveRef}/reverse

**An approval that was withdrawn**

Reversed, never deleted. The person asked, it was approved, and then it was cancelled — all three happened and all three stay on the record. Safe to repeat.

Parameters:

- `externalRef` (path, required)
- `leaveRef` (path, required): The externalRef you posted the leave under.

Body:

- `reason` string, required
- `sourceSystem` string: Your system's name, the same on every call (for example shop). Identifies your references.

```json
{
  "reason": "string"
}
```

Answers:

- `200` leaveId, reversed, balanceAfter. reversed is false if it was already reversed.
- `422` No reason given, or no leave recorded under that reference

## GET /v1/employees/{externalRef}/payslips

**Which payslips this person has**

Only issued ones. A draft pay run has no payslip, deliberately: it would put a figure in somebody's hands that the ledger has never seen.

Parameters:

- `externalRef` (path, required)
- `limit` (query)
- `sourceSystem` (query): Your system's name, the same on every call (for example shop). Identifies your references.

Answers:

- `200` employeeRef, payslips: [{ id, periodStart, periodEnd, payDate, period, ccy, gross, deductions, net }]
- `404` Nobody here is known by that reference

## GET /v1/payslips/{id}/file

**The payslip as a PDF**

The official one, on the company's letterhead, carrying the leave balances as they stood at the end of that period. Proxied to the single renderer for the same reason the tax invoice is: a payslip somebody may have to show a bank or a landlord must not have two appearances.

Parameters:

- `id` (path, required): The id from GET /v1/employees/{externalRef}/payslips.

Answers:

- `200` application/pdf
- `404` Not an issued payslip here
- `502` The renderer is unreachable or refused
- `503` No renderer configured

## PUT /v1/employees/{externalRef}/hours/{periodRef}

**One person's hours for one pay period**

PUT, so idempotent: the same period sent again replaces it (an office correction). Once a posted pay run covers any of its dates, it is refused with 409.

How the pay run uses the days (South Africa, BCEA): the standing pay covers the ordinary hours of rostered days. On top of it: hours over the ordinary day (9) on a rostered day at 1.5x, or the day's multiplier if higher; the ordinary hours of a rostered Sunday or public holiday carry the extra (multiplier - 1); every hour of a rest day worked (rostered = false or rest_day_worked = true) at 1.5x or the multiplier if higher. Hourly rate = standing pay x periods a year / 52 / 45.

Unknown fields on a day are kept, not refused.

Parameters:

- `externalRef` (path, required): TM-{team member id}
- `periodRef` (path, required): APP-HOURS-{from}-{to}

Body:

- `period_from` string (date), required
- `period_to` string (date), required
- `total_hours` number
- `on_truck_hours` number
- `off_truck_hours` number
- `source_system` string: Your system's name, the same on every call (for example shop). Identifies your references.
- `days` array of object, required
- `days[].date` string (date), required
- `days[].hours` number, required: Decimal hours, 0 to 16.
- `days[].on_truck_hours` number
- `days[].off_truck_hours` number
- `days[].corrected` boolean: Default false.
- `days[].day_type` string: ORDINARY, SATURDAY, SUNDAY, PUBLIC_HOLIDAY: Default "ORDINARY".
- `days[].rate_multiplier` number: 1.0 to 3.0. Sunday 1.5, public holiday 2.0. Default 1.0.
- `days[].rostered` boolean: Default true.
- `days[].rest_day_worked` boolean: Not rostered and worked anyway: every hour is overtime. Default false.

```json
{
  "period_from": "2026-12-01",
  "period_to": "2026-12-01",
  "days": [
    {
      "date": "2026-12-01",
      "hours": 100
    }
  ]
}
```

Answers:

- `201` Stored for the first time
- `200` Replaced
- `404` Employee not known: PUT /v1/employees/{externalRef} first
- `409` A posted pay run covers this period
- `422` A day outside the period, hours over 16, or an unknown day_type
