> ## Documentation Index
> Fetch the complete documentation index at: https://partners.usehammock.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Apply deductions

> Standing instructions for what to withhold and contribute on each paycheck.

A deduction is a standing instruction: withhold this much from this employee, and have the
employer contribute this much, on every payday until told otherwise. Hammock creates one when an
employee elects a benefit that runs through payroll, and updates it when the amounts change. You
mirror it in your payroll engine.

```json theme={null}
{
  "id": "ded_2Lp9Xc4vNm7K",
  "object": "deduction",
  "employer": "empr_1Qx8Zt2eZvKYlo2C",
  "employee": "emp_5Tg7Rw2nBx8P",
  "benefit": "ben_4Df8Gh2jKl6M",
  "election": "elec_3Sd6Fg9hJk2L",
  "benefit_type": "hsa",
  "category": "contribution",
  "tax_treatment": "pre_tax",
  "status": "active",
  "employee_amount": 15000,
  "employer_amount": 5000,
  "currency": "usd",
  "effective_date": "2027-03-19",
  "end_date": null,
  "upcoming_change": null,
  "variable": false
}
```

| Field | How to use it |
| - | - |
| `employee_amount` | Withhold this many cents from the employee on each payday. |
| `employer_amount` | Record this many cents as the employer's contribution on each payday. |
| `tax_treatment` | `pre_tax` or `post_tax`. Map it to the matching deduction type in your payroll. |
| `effective_date` | The first pay date the current amounts apply to. |
| `end_date` | The last pay date to withhold on, or `null` while open-ended. |
| `upcoming_change` | New amounts that take over from their own `effective_date`. |
| `variable` | Whether the amounts are recalculated before each lock date. |

## Two ways to stay current

**React to events.** Subscribe to `deduction.created`, `deduction.updated` and `deduction.ended`,
retrieve the deduction each time, and write it to your payroll engine.

**Read before each payroll.** Ask for the deductions that apply to one payday. Hammock resolves
`upcoming_change` and end dates for you, and leaves out anything that doesn't apply that day.

```bash theme={null}
curl "https://api.usehammock.co/deductions?employer=empr_1Qx8Zt2eZvKYlo2C&pay_date=2027-03-19" \
  -H "Authorization: Bearer hmk_live_..."
```

We recommend both: events keep your product current between payrolls, and the read on the lock
date is the final word on what to withhold. For a `variable` deduction the lock-date read is
required.

## When a change takes effect

A change takes effect on the payday of the first pay period that hasn't locked. Until then it
sits in `upcoming_change`.

```mermaid theme={null}
sequenceDiagram
  participant M as Employee
  participant H as Hammock
  participant P as Your platform
  M->>H: Raises HSA contribution on Mar 18
  Note over H: The Mar 19 payday locked on Mar 17
  H-->>P: Event deduction.updated
  P->>H: GET /deductions/ded_2Lp9Xc4vNm7K
  H-->>P: Current 15000, upcoming_change 17500 from Apr 2
  P->>P: Withhold 15000 on Mar 19 and 17500 from Apr 2
```

On the upcoming change's `effective_date`, its amounts become the current ones and
`upcoming_change` returns to `null`. A deduction has at most one upcoming change: a second change
before it takes effect replaces it.

## Variable deductions

Some employees set their HSA to reach the annual limit. Hammock then works out each paycheck's
amount from the limit, what has already gone in this year, and the paydays left. These deductions
have `"variable": true`.

Hammock publishes the amount for a payday before that pay period's lock date, as an
`upcoming_change` with a `deduction.updated` event. Read deductions with `pay_date` on the lock
date and you always have the right figure. The last paycheck of the year is often smaller than
the rest.

## Employer contributions

`employer_amount` covers employer money that goes in with each paycheck: a fixed amount per pay
period, or a match on what the employee contributes. Record it in payroll so year-end reporting
is right.

Some employers contribute once a year instead. Those never run through payroll and appear as
[employer contributions](#one-time-employer-contributions) for you to record.

## ICHRA premium deductions

When an employee picks a health plan that costs more than their ICHRA allowance, Hammock pays the
full premium and the employee's share comes out of their paycheck. That share is a deduction with
`"category": "premium"` and no employer amount.

| Plan type | `tax_treatment` |
| - | - |
| Off-exchange plan | `pre_tax` |
| On-exchange plan | `post_tax` |

These deductions exist only for employees who enroll in a plan through Hammock. Employees who
bring their own plan have none. The money withheld stays with the employer: it repays what
Hammock already pulled from the employer for the premium, so it never changes a
[pull](https://partners.usehammock.co/guides/funding.md).

> [!NOTE]
>
> Premium deductions are still in development and will arrive after the first release.

## One-time employer contributions

An employer contribution made outside payroll, such as an annual HSA contribution funded at the
start of the plan year, is an `employer_contribution` object. It never appears on a paycheck.
Record it against the employee so their W-2 includes it.

```bash theme={null}
curl "https://api.usehammock.co/employer_contributions?employer=empr_1Qx8Zt2eZvKYlo2C&tax_year=2027" \
  -H "Authorization: Bearer hmk_live_..."
```

You receive `employer_contribution.posted` when the money reaches the employee's account, and
`employer_contribution.reversed` if it's later taken back.

## When a deduction ends

A deduction ends when the employee is terminated, waives the benefit, or the plan year ends. It
gets an `end_date`, and you receive `deduction.ended`. A new plan year brings a new election and
a new deduction with its own ID.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.