When to use this endpoint

Request explicit fields for the CRM2 template settings table.

Authentication and permissions

Use signed API-key authentication or a logged-in CRM session on the account’s routed host. API keys act as their owner; normal session requests need dispatcher CSRF protection where configured. Tenant data is selected from the authenticated account.

The handler has no additional page-action/Role check. A CRM2 screen hiding a control does not add such a server guard, and CRM2 role names must not be assumed to apply to CRM1. The dispatcher has no dedicated object-scope mapping for this namespace.

Parameters

ParameterTypeRequiredDescription
groupByNative list of mapped namesNoGroups the SQL rows by recognized mapped fields. Returned columns remain ordinary projections; counts still count matching records rather than groups. This wrapper adds no aggregate-safe projection validator.
fieldsNative list of mapped namesNo for details; required for tablesDetails default to all mapped fields. Unknown names are omitted; id is always included. JSON-encoded list text is not decoded. Whole JSON/text columns remain encoded strings, while nested metadata projections can decode values.
start / length / draw / isTable / limitInteger-compatibleNoTable defaults 0/10/0 for offset/page size/draw. isTable integer-converting to 0 returns {data:[...]} without draw/counts, optionally capped by positive limit. No route-owned maximum, negative-value clamp or length=-1 all-record sentinel exists.
orderBy / orderDesc / orderMapped name/direction or DataTables orderNoNamed orderBy/orderDesc take precedence; use asc/desc. Otherwise order[0].column minus one (clamped at zero) selects a projected mapped field; default first recognized projected field ascending. No stable ID tie-breaker. Unpaged mode has separate reference-date ordering.
searchValue / searchFieldText / mapped name or native listNoCase-insensitive substring LIKE; searchField defaults All. SQL % and _ retain wildcard meaning.
referenceDate / dateFrom / dateToMapped date field / relative integer day offsetsNoBoth bounds add inclusive day limits relative to today in the account timezone, with UTC fallback. These are day offsets, not absolute dates. Legacy offsetFrom/offsetTo hour/minute objects adjust datetime boundaries; date-only fields ignore them. timeRangeFrom enables inclusive hour filtering, upper timeRangeTo defaults 23; reversed bounds swap and the hour timezone falls back to Europe/London.
Mapped filters / order / advanceSearchScalars, native lists or structured query controlsNoMapped filters combine with AND; lists use IN. Detail text filters are trimmed case-insensitive exact matches; table text filters use substring LIKE. Detail order accepts mapped names or {id,dir} descriptors. Structured comparisons use mapped columns, condition/value and optional andOr/special. These legacy wrappers do not add a strict query-control allowlist; raw advanced conditions are a trusted UI surface, not an integration SQL interface.
Template filtersMapped scalars or native listsNoid,name,body,archived,fromEmail,isDefault,subject,type,meta,metaFormID. metaFormID projects meta.form_id; meta is encoded text. No automatic archived filter.

Example request

$result = FM_api('EmailTemplates_getDataTable', ['fields'=>['id','name','subject','archived'],'start'=>'0','length'=>'10']);

Example response

{
  "data": [],
  "draw": 0,
  "recordsTotal": "0",
  "recordsFiltered": "0"
}

Application errors normally remain JSON responses with HTTP 200; inspect error/warning keys. Numeric driver values can be strings.

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: fields"}fields 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

  • Table mode returns the normal data/draw/counts envelope; non-table mode remains {data:[...]}. recordsTotal counts all template records; recordsFiltered includes request filters. No role/owner/current-form constraint is implicit.
  • body and whole meta can be selected; body is unrendered text. There is no soft-deletion flag/filter in this template map.

Side effects

  • Reads templates only; no render, send or default-setting mutation.

See it in Fieldmotion

CRM1

Settings > Email Templates uses EmailTemplates_getDT; email composers and Job/Quote/Invoice send flows call EmailTemplates_list.

CRM2

Settings > Email Templates uses the mapped table; email composers and notification configuration use EmailTemplates_list to populate template choices.

Related endpoints