en
Bookings›Commit emergency insert + cascade reschedule

Commit emergency insert + cascade reschedule

Applies the cascade previewed by /emergency/preview: assigns the emergency job to the technician and pushes the displaced jobs back (or, with `displacement_mode=reassign`, re-staffs them onto their previewed alternates first), atomically. Supports Idempotency-Key. The server recomputes the plan under a lock and fences each job on its status_version — if anything changed since the preview it returns 409 EMERGENCY_RESCHEDULE_PLAN_DRIFTED (re-preview). Same body as preview + optional `emergency_expected_version`. `after_hours_override=true` must match the preview it followed — it drops the non-working-day rejection (this endpoint never runs the technician's working-hours/time-off feasibility check; that only happens on /candidates), and the response carries an AFTER_HOURS warning; the committed job's activity feed also records who authorized the after-hours placement. Isolated feature (see EMERGENCY_RESCHEDULE_DESIGN.md). 409 NEXT STEPS: EMERGENCY_RESCHEDULE_PLAN_DRIFTED — the schedule changed between your preview and this commit (another booking/move won a lane); `data.drifted[]` names the job(s) whose status_version moved when the fence can attribute it (absent, never empty, when only a length mismatch is known): call /preview again, show the fresh plan, then commit. EMERGENCY_RESCHEDULE_SLOT_OCCUPIED — landing window blocked by an immovable anchor (P0/crew/multi-day); `data.conflicts[]` names it: another tech or time. Other codes — same remedies and `data` shapes as /candidates. EMERGENCY_RESCHEDULE_NO_WORKING_DAY does NOT fire when after_hours_override=true.

Arguments

Idempotency-Keystringheaderoptional
Unique key making retries safe: a repeat send with the same key replays the original response (header Idempotent-Replayed: true) instead of re-running the operation. Reusing a key with a different body returns 422 IDEMPOTENCY_KEY_REUSE.
after_hours_overridebooleanbodyoptional
Place this P0 outside working hours / approved time-off — you have phoned the technician and they agreed. Drops the non-working-day rejection; the response then carries an AFTER_HOURS warning. Double-booking, service area, required skills and the lead-tier rule still reject.
displacement_modeenumbodyoptional
Fate of displaced jobs: reschedule (default) or reassign — must match the preview.
emergency_expected_versionintegerbodyoptional
Optimistic-lock fence from the previewed job (0 = fence on the server-read version).
emergency_job_idstringbodyrequired
ID of the P0 job to insert.
expected_move_idsarray<string>bodyoptional
ExpectedMoveIDs — the displaced job IDs the preview returned (echo BOTH data.days[].moves[].job_id AND data.reassignments[].job_id). RECOMMENDED: if the recomputed cascade would touch a different set (a job booked onto the lane since the preview), the commit is rejected with EMERGENCY_RESCHEDULE_PLAN_DRIFTED instead of displacing a job the coordinator never saw. Omit to opt out.
modeenumbodyrequired
Cascade mode: overtime | next_day (must match the preview).
start_atstringbodyrequired
Desired start — business-local naive datetime, no offset. Must be in the future and match the preview.
technician_idstringbodyrequired
Target technician (must belong to the business).
POST/v1/job-requests/emergency/commit
curl -X POST "https://api.crisphive.com/v1/job-requests/emergency/commit" \
  -H "Authorization: Bearer chsk_test_4eC8xQ9mZ2pL7Ka0rT" \
  -H "Content-Type: application/json" \
  -d '{
  "after_hours_override": true,
  "displacement_mode": "reschedule",
  "emergency_expected_version": 1,
  "emergency_job_id": "9b2f6c3e-1a4d-4f0a-8f2e-7c5d1b3a9e01",
  "expected_move_ids": [
    "9b2f6c3e-1a4d-4f0a-8f2e-7c5d1b3a9e01"
  ],
  "mode": "overtime",
  "start_at": "2030-06-14T09:00:00",
  "technician_id": "9b2f6c3e-1a4d-4f0a-8f2e-7c5d1b3a9e01"
}'
Request body
{
"after_hours_override": ,
"displacement_mode": ,
"emergency_expected_version": ,
"emergency_job_id": ,
"expected_move_ids": [
],
"mode": ,
"start_at": ,
"technician_id":
}

Responses