Skip to navigation

Create Shift

Creates a shift in Attendance — fixed (the same weekly schedule every week) or rotating (a repeating pattern of work and rest blocks) — exactly as an administrator would from Crehana, and returns its id. Built for HR and workforce-planning systems that own the schedules. Step-by-step guide: Create shifts.

shift_type decides the body: NON_ROTATING takes weekly_schedule, ROTATING takes cycles. The answer carries the id of the shift and, for a rotating one, the id of each cycle: the shift_id and start_cycle_id that Assign Shift needs.

  • Times are HH:MM. An exit earlier than the entry means the day ends the next day (night shift).
  • Days not sent in weekly_schedule are rest days.
  • Breaks go in break_config (type and deduction) plus, per working day or work cycle, break_time_slots (FIXED_SCHEDULE) or break_duration_minutes (FIXED_DURATION).
  • Worked minutes are calculated by Crehana unless edit_worked_minutes is true.
  • A schedule that breaks a rule of Attendance (no working day, a break outside the day, a rotating shift without a rest block, …) is a 400 with the rule in the message.
  • The name is unique among the active shifts of the organization: sending it again is a 409 with the id of the existing shift, so a retry never creates a duplicate.
  • Requires credentials of an administrator of the organization.

Authentication

Api-Keystring

API key of the organization. Always sent together with the Secret-Access header.

Path parameters

organization_slugstringRequired

Headers

Secret-AccessstringRequired

Request

This endpoint expects an object.
NON_ROTATINGobjectRequired
A shift with the same weekly schedule every week.
OR
ROTATINGobjectRequired
A shift that repeats a pattern of work and rest blocks, e.g. 4 x 2.

Response

Shift created
successboolean
True when the shift is stored.
messagestring
Human readable result.
codestring

attendance-005 when the shift was created. Not an HTTP status.

datetimestring
Datetime of the API in ISO Format
dataobject

A shift as stored in Attendance. weekly_schedule only for a fixed one, cycles only for a rotating one.

Errors

400
Bad Request Error
401
Unauthorized Error
403
Forbidden Error
409
Conflict Error
422
Unprocessable Entity Error