Events
Your agency sends an event to Stafflion when a shift you work on changes. Each request carries one event, identified by event_name. The endpoint, its schemas, code samples, and examples are in the API tab under Send events.
Flow
shift_request: a clinician asks to work a shift Stafflion published to your agency. Stafflion accepts requests only for shifts it published. Stafflion approves the request by calling your partner API. The response says whether it was approved automatically (auto_approved) or is waiting for approval (pending_approval). The request stays pending until the matchingshift_claimedarrives.shift_claimed: a clinician claims the shift. Stafflion adds it to its schedule. For a shift Stafflion did not publish, the claim creates the shift, so the event must includeshift_start_timeandshift_end_time.shift_update: the time of a taken shift changes. Send it only after theshift_claimedfor that shift.shift_call_out: a clinician calls out or will no longer work the shift. Stafflion removes the clinician from its schedule.
Identifiers
partner_shift_ididentifies the shift in your system. Send it with every event.shift_idis the Stafflion shift ID. Send it only if you map it.partner_secondary_shift_idis a second identifier for the same shift in your system, when you use one.- The clinician is identified in two ways, depending on the event.
shift_requestandshift_claimedsendpartner_clinicianwithidand the clinician’s details.shift_updateandshift_call_outsendpartner_clinician_id. - Stafflion maps your identifiers to its own records.
Times
shift_start_time, shift_end_time, and occurred_at are RFC 3339 timestamps. Send Z or an offset such as +00:00. Stafflion stores them in UTC and returns them in UTC.
shift_end_time must be after shift_start_time. If it is not, the event is rejected with 422.
Pay details
compensation is optional. When you send it, it belongs to one shift and one clinician, and the amounts are in USD. Stafflion stores it for that assignment only: an event for another shift does not change it, and a later shift_request or shift_claimed for the same shift and clinician replaces it.
base_hourly_rateandovertime_hourly_rateare required whencompensationis sent.bonusis optional. Omit it when there is no bonus.bonus.typeisfixed(an amount in USD) orpercentage. A percentage is in points:10means 10%.- Stafflion stores the bonus as sent. It also computes the bonus amount from
base_hourly_rateover the length of the shift. clinician_tieris a property of the clinician, not of the pay. Send it inpartner_clinician.
Pay details are not returned by any endpoint.
Repeated events
Sending the same event again is safe. A repeat is the same event_name, partner_shift_id, partner_facility_id, and clinician. Stafflion responds with the same result as the first time and does not create a second shift or a second pending request.
Order and dependencies
Stafflion applies events as they arrive, and each event must fit the state of the shift. For example, a shift_update before its shift_claimed, or a shift_call_out for a shift no clinician holds, is rejected with a 4xx. Resend the event after the event it depends on is accepted.
occurred_at records when the event happened. Stafflion does not use it to order events.
After a shift_call_out
What happens to the shift depends on how your agency is set up with Stafflion:
- If your agency supports reopening, the shift reopens under the facility’s rules.
- If your agency does not support it and Stafflion closes the shift, Stafflion cancels the shift.
- If your agency closes the shift on its own, Stafflion takes no action.
Retries
Retry a 5xx response or a timeout with backoff. Do not retry a 4xx response, with one exception: an event that arrives before the event it depends on is rejected with a 4xx, and you resend it after that event is accepted.
Errors
Every error returns a message that states the reason and a code you can match in your code. Match on code; the message text can change.
Notes on errors
shift_not_found(404) onshift_claimed: the shift is not available to your agency. It was removed, it was taken by another agency, or it is unknown and the event has no shift times. A 404 is final: do not retry. Stafflion creates a shift it did not publish only when the event includesshift_start_timeandshift_end_time.ambiguous_shift(400): more than one shift or slot matches. Send the clinician identifier so Stafflion can choose the shift:partner_clinician.idonshift_requestandshift_claimed, orpartner_clinician_idonshift_updateandshift_call_out.shift_not_taken(400): ashift_call_outneeds a shift that a clinician holds.shift_time_unknown(422): Stafflion cannot determine the time of the shift from the event. Sendshift_start_timeandshift_end_time.facility_not_found(404): thepartner_facility_idis not linked to a Stafflion facility. Ask your Stafflion contact to link it.validation_failed(422):errorslists each invalid field. Fix the field and resend.