When to use this endpoint

Use UserClockins_getDT only when reproducing the CRM1 table contract. CRM2 uses the named-field data-table endpoint.

Authentication and permissions

The request must authenticate with signed API-key fields or a logged-in CRM session. The handler performs no additional page or role-permission check.

The lookup and any write use the authenticated tenant; an ID from another tenant cannot be addressed through this call.

Parameters

ParameterTypeRequiredDescription
drawInteger stringYesDataTables sequence echoed after integer conversion. Presence is required; the value need not be positive.
start / lengthInteger stringsNoSQL offset and page size. Offset defaults to 0; missing/nonpositive length becomes 100, so DataTables -1 does not mean unlimited.
idInteger stringNoWhen positive, exact-ID mode is used and every other list filter is ignored.
flagInteger stringNoFlag equality filter. Values below zero mean all; nonnumeric text becomes 0.
days_from / days_toSigned integersNoInclusive stored-date bounds relative to the database server’s current date. Either bound may be supplied independently.
user_idInteger stringNoExact user filter when nonzero.
notesStringNoTrimmed substring match against the stored notes JSON/text under database collation rules.
sourceInteger stringNoExact source_type; -1 means all.
order[0][column] / order[0][dir]DataTables controlsNoSortable indices are 0 ID, 2 date, and 7 flag. Other indices fall back to date; only exact desc requests descending order.

Example request

$page = FM_api('UserClockins_getDT', [
	'draw' => '3',
	'start' => '0',
	'length' => '25',
	'user_id' => '18',
	'flag' => '-1',
	'order' => [['column' => '2', 'dir' => 'desc']],
]);

Example response

{
  "recordsTotal": 91,
  "recordsFiltered": 12,
  "draw": 3,
  "data": [
    [
      "481", "18", "2026-09-26",
      [1790413200, 1790413212, 12, "[]", "35", "{\"coords\":{\"latitude\":53.3,\"longitude\":-6.2}}"],
      [1790442000, 1790442018, 18, "[]", "44", "{\"coords\":{\"latitude\":53.31,\"longitude\":-6.21}}"],
      {"total":1800,"breaks":[]}, 27000, "0", "[]", 1, ""
    ]
  ]
}

Row positions are: 0 ID, 1 user ID, 2 date, 3 start tuple, 4 end tuple, 5 decoded breaks, 6 net seconds, 7 flag, 8 general notes text, 9 integer source type, and 10 an always-empty compatibility value.

Each start/end tuple is [time, creationTime, difference, notes, geoDistance, geoJson]. Database scalars retain mixed string/null types except explicitly integer-converted values.

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":"missing or invalid parameter: draw"}The draw key is absent.
Database error/invalid responseUnsupported negative offsets or another generated SQL failure is not translated into a stable operation-specific error.

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

Behaviour and edge cases

  • Without explicit ordering, rows are sorted by stored date descending. Exact-ID mode still applies paging and ordering but deliberately ignores saved date/user/flag/note/source filters.
  • Net seconds are recomputed as clockout - clockin - breaks.total when both epochs are nonzero; otherwise zero. The result can be negative and may differ from stored gross duration.
  • recordsTotal counts every tenant row; recordsFiltered counts the constructed filter before paging. No user-role, ownership, or department scope is applied.

See it in Fieldmotion

CRM1

This is the server-side source for Users → Clock-ins, including its saved filters and manual-correction deep links.

CRM2

CRM2 does not call this route.

Related endpoints