Skip to main content
POST
← Own Workforce API Record your employees’ absences and accidents at work. A record is a row of the accidents and absenteeism import template: an absence, an accident, or an accident and the absence it caused. It belongs to an employee, by the id that Create Workforce Employees (v2) answers. Nothing is calculated, so the request is synchronous (see how bulk ingestion works): it answers 201 Created with what each record created. It also records an ingest job, born completed, that sends no webhook.
Beta. Part of the bulk ingest API, in beta. The contract may still change before general availability.

How it works

Every record is checked as the file import checks a row:
  • An absence must not overlap another absence of the employee, counting both start and end days. An absence without an end date is ongoing and overlaps every later one. The check covers the absences already stored and the other records of the request.
  • An accident cannot be the employee’s second on the same day, against the stored accidents and the request’s.
  • Hours left out of an absence with an end date are derived as the import derives them: 8 per day of the absence, both ends included, times the working hours ratio of the employee’s contract on its first day (1 when no contract covers it). Without absence_hours, an absence of 1,250,000 days or more is refused, since 8 hours a day would reach the 10,000,000 limit: send its hours, or leave absence_end_date out if it is ongoing.
If any record is invalid the whole request is rejected with 422 and nothing is written; rejected is the number of invalid records and errors lists them (up to 100). Otherwise everything is created at once.

Request

Headers

string
required
Your API key (see Authentication).
string
required
Your organization. The employees of its perimeter can take absences and accidents; each belongs to its employee’s organization.
string
required
1 to 255 characters, one per batch, looked up per organization across every v2 bulk route. Within 24 hours, the same key with the same route and body answers the same records (with Idempotent-Replayed: true) instead of creating them again; the same key with another body or on another route is 422 IDEMPOTENCY_KEY_REUSED, and while the first request is still being processed 409 IDEMPOTENCY_KEY_IN_PROGRESS. After 24 hours the key is free, and a request with it is a new one. See The Idempotency-Key.

Query Parameters

boolean
default:"false"
Check only: the same 422 for invalid records, nothing written; 200 with {"dry_run": true, "submitted": n, "valid": n} when every record is valid. The Idempotency-Key header is still required, but a dry run does not check or store it.

Body Parameters

array[object]
required
The absences and accidents to create, 1 to 1,000. Each record needs an absence (absence_start_date), an accident (accident_date) or both. A field not listed here is rejected (SCHEMA_INVALID).

Response

201 Created with items: one per record, in the order sent, with its source_row_index, client_row_id and the created absence (absence and accident fields; those the record did not have are null). Its id is the one Delete Workforce Absences (v2) takes.

Errors

Problem details. Per-record codes in errors[].error_code of a 422 BULK_RECORDS_REJECTED: Request-level errors: 401 for a missing or invalid API key, 403 LOGGED_USER_NOT_MEMBER when the key’s user is not a member of the organization, 422 REQUEST_VALIDATION_FAILED for a malformed body (no records, more than 1,000, no Idempotency-Key), 422 IDEMPOTENCY_KEY_REUSED, 409 IDEMPOTENCY_KEY_IN_PROGRESS, and 429 beyond the rate limits.

Limits

Delete Workforce Absences (v2)

Delete absences and accidents by id

Create Workforce Employees (v2)

The employees, and their ids

List Workforce Absences

The absences stored