When to use this endpoint

Use UserWorkShift_deleteData only for callers already using the generic data-operation naming convention. CRM2’s current row action calls the shorter alias.

Authentication and permissions

The request must authenticate and HR enhancements must be enabled.

The handler does not enforce Work Shifts delete permission, Users edit permission, target ownership, or active-user state.

Parameters

ParameterTypeRequiredDescription
idSynthetic integer stringYesPositional ID from a work-shift reader. It encodes the default user and zero-based shift index.
userID / user_idInteger stringNoOptional target user override. The decoded index is retained even when the supplied user does not match the encoded user.

Example request

$result = FM_api('UserWorkShift_deleteData', [
	'id' => '18002',
]);

Example response

{
  "ok": 1
}

Errors and unusual responses

ResponseCondition
{"error":"not logged in"}No authenticated tenant context is available. Invalid signed credentials can be rejected by the dispatcher before the handler runs.
{"error":"HR enhancements are disabled"}The tenant feature disables these APIs.
{"error":"missing or invalid parameter: userID"}No positive target user can be resolved.
{"error":"missing or invalid parameter: id"}The ID is below one or decodes to a negative index.
{"error":"user does not exist"}The selected target user does not exist.
{"error":"shift does not exist"}The decoded index is absent from the user’s effective rows.

Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.

Behaviour and edge cases

  • The reader includes company fallback rows. Removing the final custom row clears the custom key and reveals the company default; attempting to remove a displayed fallback row has no durable visible effect.
  • Remaining rows are fully rebuilt and validated as version-2 work hours.

Side effects

  • Replaces/removes users.meta.work_hours, updates last_edited and edited_uuid="UserWorkShift", and invalidates the users cache.
  • Creates neither a delete-log entry nor generic audit history.

See it in Fieldmotion

CRM1

No direct CRM1 caller was found.

CRM2

No direct current caller was found; UserWorkShift_delete delegates here.

Related endpoints