Create an employee
curl --request POST \
--url https://api.usehammock.co/employees \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"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",
"hire_date": "2027-02-08",
"send_invitation": false
}
'import requests
url = "https://api.usehammock.co/employees"
payload = {
"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",
"hire_date": "2027-02-08",
"send_invitation": False
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
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',
hire_date: '2027-02-08',
send_invitation: false
})
};
fetch('https://api.usehammock.co/employees', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.usehammock.co/employees",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'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',
'hire_date' => '2027-02-08',
'send_invitation' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.usehammock.co/employees"
payload := strings.NewReader("{\n \"employer\": \"empr_1Qx8Zt2eZvKYlo2C\",\n \"external_id\": \"wrk_4821\",\n \"email\": \"jordan.lee@acmerobotics.example\",\n \"first_name\": \"Jordan\",\n \"last_name\": \"Lee\",\n \"pay_schedule\": \"ps_7Hn3Kd9sLq2W\",\n \"date_of_birth\": \"1991-06-14\",\n \"hire_date\": \"2027-02-08\",\n \"send_invitation\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.usehammock.co/employees")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"employer\": \"empr_1Qx8Zt2eZvKYlo2C\",\n \"external_id\": \"wrk_4821\",\n \"email\": \"jordan.lee@acmerobotics.example\",\n \"first_name\": \"Jordan\",\n \"last_name\": \"Lee\",\n \"pay_schedule\": \"ps_7Hn3Kd9sLq2W\",\n \"date_of_birth\": \"1991-06-14\",\n \"hire_date\": \"2027-02-08\",\n \"send_invitation\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.usehammock.co/employees")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"employer\": \"empr_1Qx8Zt2eZvKYlo2C\",\n \"external_id\": \"wrk_4821\",\n \"email\": \"jordan.lee@acmerobotics.example\",\n \"first_name\": \"Jordan\",\n \"last_name\": \"Lee\",\n \"pay_schedule\": \"ps_7Hn3Kd9sLq2W\",\n \"date_of_birth\": \"1991-06-14\",\n \"hire_date\": \"2027-02-08\",\n \"send_invitation\": false\n}"
response = http.request(request)
puts response.read_body{
"id": "emp_5Tg7Rw2nBx8P",
"object": "employee",
"employer": "empr_1Qx8Zt2eZvKYlo2C",
"external_id": "wrk_4821",
"email": "jordan.lee@acmerobotics.example",
"pay_schedule": "ps_7Hn3Kd9sLq2W",
"status": "active",
"enrollment_status": "not_started",
"metadata": {
"plan": "growth"
},
"livemode": true,
"created": "2023-11-07T05:31:56Z",
"first_name": "Jordan",
"last_name": "Lee",
"date_of_birth": "1991-06-14",
"ssn_last4": "4321",
"phone": "+14155550134",
"address": {
"line1": "500 Howard St",
"city": "San Francisco",
"state": "CA",
"postal_code": "94105",
"country": "US",
"line2": "<string>"
},
"hire_date": "2027-02-08",
"termination_date": "2023-12-25",
"invited_at": "2023-11-07T05:31:56Z"
}{
"error": {
"type": "invalid_request_error",
"code": "parameter_missing",
"message": "Missing required parameter: employer.",
"param": "employer",
"doc_url": "https://docs.usehammock.co/api/errors#parameter_missing",
"request_id": "req_9Kd2Lm5nPq8R"
}
}Employees
Create an employee
Adds an employee to an employer’s roster. Set send_invitation to have Hammock email the
employee an invitation to enroll; leave it off to show the enrollment link in your own
product.
POST
/
employees
Create an employee
curl --request POST \
--url https://api.usehammock.co/employees \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"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",
"hire_date": "2027-02-08",
"send_invitation": false
}
'import requests
url = "https://api.usehammock.co/employees"
payload = {
"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",
"hire_date": "2027-02-08",
"send_invitation": False
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
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',
hire_date: '2027-02-08',
send_invitation: false
})
};
fetch('https://api.usehammock.co/employees', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.usehammock.co/employees",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'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',
'hire_date' => '2027-02-08',
'send_invitation' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.usehammock.co/employees"
payload := strings.NewReader("{\n \"employer\": \"empr_1Qx8Zt2eZvKYlo2C\",\n \"external_id\": \"wrk_4821\",\n \"email\": \"jordan.lee@acmerobotics.example\",\n \"first_name\": \"Jordan\",\n \"last_name\": \"Lee\",\n \"pay_schedule\": \"ps_7Hn3Kd9sLq2W\",\n \"date_of_birth\": \"1991-06-14\",\n \"hire_date\": \"2027-02-08\",\n \"send_invitation\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.usehammock.co/employees")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"employer\": \"empr_1Qx8Zt2eZvKYlo2C\",\n \"external_id\": \"wrk_4821\",\n \"email\": \"jordan.lee@acmerobotics.example\",\n \"first_name\": \"Jordan\",\n \"last_name\": \"Lee\",\n \"pay_schedule\": \"ps_7Hn3Kd9sLq2W\",\n \"date_of_birth\": \"1991-06-14\",\n \"hire_date\": \"2027-02-08\",\n \"send_invitation\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.usehammock.co/employees")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"employer\": \"empr_1Qx8Zt2eZvKYlo2C\",\n \"external_id\": \"wrk_4821\",\n \"email\": \"jordan.lee@acmerobotics.example\",\n \"first_name\": \"Jordan\",\n \"last_name\": \"Lee\",\n \"pay_schedule\": \"ps_7Hn3Kd9sLq2W\",\n \"date_of_birth\": \"1991-06-14\",\n \"hire_date\": \"2027-02-08\",\n \"send_invitation\": false\n}"
response = http.request(request)
puts response.read_body{
"id": "emp_5Tg7Rw2nBx8P",
"object": "employee",
"employer": "empr_1Qx8Zt2eZvKYlo2C",
"external_id": "wrk_4821",
"email": "jordan.lee@acmerobotics.example",
"pay_schedule": "ps_7Hn3Kd9sLq2W",
"status": "active",
"enrollment_status": "not_started",
"metadata": {
"plan": "growth"
},
"livemode": true,
"created": "2023-11-07T05:31:56Z",
"first_name": "Jordan",
"last_name": "Lee",
"date_of_birth": "1991-06-14",
"ssn_last4": "4321",
"phone": "+14155550134",
"address": {
"line1": "500 Howard St",
"city": "San Francisco",
"state": "CA",
"postal_code": "94105",
"country": "US",
"line2": "<string>"
},
"hire_date": "2027-02-08",
"termination_date": "2023-12-25",
"invited_at": "2023-11-07T05:31:56Z"
}{
"error": {
"type": "invalid_request_error",
"code": "parameter_missing",
"message": "Missing required parameter: employer.",
"param": "employer",
"doc_url": "https://docs.usehammock.co/api/errors#parameter_missing",
"request_id": "req_9Kd2Lm5nPq8R"
}
}Authorizations
Headers
Body
application/json
Response
The created employee.
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.
Available options:
not_started, in_progress, pending, enrolled, not_enrolled, closed