When to use this endpoint

Use Contracts_getTypesDT only for CRM1’s Contract Types screen.

New CRM2 code uses the mapped ContractTypes endpoints rather than this legacy positional response.

Authentication and permissions

The route requires tenant routing established by a valid API signature or CRM session. It checks tenant context rather than calling the shared login guard.

The CRM Contracts area is hidden unless tenant feature bit 64 is enabled, but this endpoint does not enforce that setting.

Parameters

ParameterTypeRequiredDescription
lengthInteger stringYesPage size after integer conversion. Presence is required; blank becomes zero.
startInteger stringNoZero-based offset; defaults to 0.
drawInteger stringNoDataTables counter, integer-converted and echoed; defaults to 0.
order[0][column]Integer stringYes0 ID, 1 name, 2 intended invoicing-disabled state, or 3 last-edited. Column 2 currently names a nonexistent database column and can fail. Other indexes remain numeric SQL order positions.
order[0][dir]StringYesExact desc selects descending; every other value selects ascending.
search[value]StringYesPresence is required. A nonblank value searches type name or the textual form of ID by substring; blank applies no filter.

Example request

$table = FM_api('Contracts_getTypesDT', [
	'draw' => '1',
	'start' => '0',
	'length' => '25',
	'order' => [['column' => '1', 'dir' => 'asc']],
	'search' => ['value' => 'service'],
]);

Example response

{
  "draw": 1,
  "recordsTotal": "6",
  "recordsFiltered": "1",
  "data": [
    ["3", "Planned service", "0", "2026-03-05 14:20:00", ""]
  ]
}

Row positions are type ID, name, stored disable_invoicing flag, last-edited timestamp, and an empty placeholder.

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":"not logged in"}Tenant routing is unavailable.
{"error":"missing or invalid parameter: length"}length is absent.
{"error":"missing or invalid parameter: [order][0][column]"}The order column is absent.
{"error":"missing or invalid parameter: [order][0][dir]"}The order direction is absent.
{"error":"missing or invalid parameter: [search][value]"}The nested search value is absent.

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

Behaviour and edge cases

  • Contract types have no soft-delete/status filter in this handler. Total and filtered counts cover all rows in the tenant’s type table.
  • Results have no stable secondary order. Unsupported positive column indexes are left as numeric SQL ORDER BY positions and therefore depend on physical SELECT * column order.
  • The search condition is grouped across name/ID before pagination. Search values are escaped but are not trimmed beyond leading/trailing whitespace.

See it in Fieldmotion

CRM1

Open Contract Types. Its table calls Contracts_getTypesDT; use name or last-edited sorting, not the invoicing-disabled column.

CRM2

A production-source search found no direct CRM2 caller. CRM2 uses the mapped ContractTypes table APIs.

Related endpoints

  • Contracts_list returns contract choices, while contract-type management is a separate model family.