> ## 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.

# Sync employees and enrollment

> Keep an employer's roster current, and link employees into hosted enrollment.

You are the system of record for the roster. Create an employee in Hammock when a
benefit-eligible worker joins, update them when their details change, and set a termination date
when they leave.

## Create an employee

```bash theme={null}
curl https://api.usehammock.co/employees \
  -H "Authorization: Bearer hmk_live_..." \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 0d9e8c7b-6a5f-4e3d-2c1b-0a9f8e7d6c5b" \
  -d '{
    "employer": "empr_1Qx8Zt2eZvKYlo2C",
    "external_id": "wrk_4821",
    "email": "jordan.lee@acmerobotics.example",
    "first_name": "Jordan",
    "last_name": "Lee",
    "pay_schedule": "ps_7Hn3Kd9sLq2W",
    "date_of_birth": "1991-06-14",
    "ssn": "123454321",
    "hire_date": "2027-02-08",
    "address": {
      "line1": "18 Elm Court",
      "city": "Oakland",
      "state": "CA",
      "postal_code": "94607",
      "country": "US"
    },
    "send_invitation": false
  }'
```

* **`external_id`** is your worker ID. It's unique within the employer, and Hammock rejects a
  second employee with the same one (`external_id_taken`). Look an employee up with
  `GET /employees?employer=...&external_id=...`.
* **`email`** must be unique within the employer.
* **`date_of_birth`, `ssn` and `address`** are optional. Opening an account requires them, so
  sending them saves the employee from typing them again. `ssn` is write-only: Hammock returns
  `ssn_last4` and never the full number.

Only send workers who are eligible for benefits. Contractors and ineligible workers don't belong
on the roster.

## Invitations

`send_invitation` decides who tells the employee about their benefits.

| `send_invitation` | What happens |
| - | - |
| `false` (default) | Hammock sends nothing. You show an enrollment link in your product. |
| `true` | Hammock emails the employee an invitation, and reminders while enrollment is open. |

You can combine them: invite by email and also link from your product. To send an invitation
later, update the employee with `"send_invitation": true`.

## Link an employee into enrollment

Enrollment is hosted by Hammock. It covers eligibility questions, the elections themselves, and
the signatures and identity details that opening an account requires.

```bash theme={null}
curl https://api.usehammock.co/enrollment_links \
  -H "Authorization: Bearer hmk_live_..." \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: cae23e13-3fc3-4731-9e19-f876857a89d4" \
  -d '{
    "employee": "emp_5Tg7Rw2nBx8P",
    "return_url": "https://partner.example/me/benefits"
  }'
```

Create the link when the employee clicks, then redirect them to its `url`. The link signs them in
as that employee, so treat it like a credential: it's single-use, it expires within minutes, and
it must only be created for the signed-in worker it belongs to.

The same call works after enrollment. An enrolled employee who follows a new link lands on their
benefits, where they can change an election when the plan allows it.

## Track enrollment

Each employee has an `enrollment_status`:

| Status | Meaning |
| - | - |
| `not_started` | The employee hasn't opened enrollment. |
| `in_progress` | They opened it and haven't elected anything. |
| `pending` | They elected, and their accounts are being opened. |
| `enrolled` | At least one benefit is active. |
| `not_enrolled` | The enrollment window closed without an election. |
| `closed` | Every enrollment has ended. |

When an employee elects a benefit you receive `election.created`, and `deduction.created` when
that benefit withholds from payroll. See [benefits and elections](https://partners.usehammock.co/guides/benefits-and-elections.md).

## Update and terminate

Send only the fields that changed.

```bash theme={null}
curl https://api.usehammock.co/employees/emp_5Tg7Rw2nBx8P \
  -H "Authorization: Bearer hmk_live_..." \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 9f5527d9-76f4-45aa-85ae-c20ced076cba" \
  -d '{ "termination_date": "2027-06-30" }'
```

Setting `termination_date` has these effects:

* The employee's `status` becomes `terminated` on that date.
* Their deductions get an `end_date` and you receive `deduction.ended`. Withhold through the last
  payday on or before the end date.
* They keep access to the money already in their accounts.

Send `"termination_date": null` to reinstate someone. Employees are never deleted.


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