Customers
Query tenant email records
/a/Customer_emailsGetDataTable
Query tenant mail records with selectable named fields, generic filters, optional DataTables paging, and a derived job reference.
When to use this endpoint
Use Customer_emailsGetDataTable only for consumers that need the generic mail-field contract. Despite its namespace, it is tenant-wide unless customerID and usually customerType are supplied.
For the established CRM1 customer email-history rows and compatibility fallbacks, use Customer_emailsGetDT.
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
| Parameter | Type | Required | Description |
|---|---|---|---|
fields | Form array | Yes | Requested aliases from id, cDate, cDateE, sentDate, sentDate_E, status, type, meta, customerID, customerType, userID, recipients, objType, objID, and qmID. Unknown names are ignored; id is always added. Send an actual form array, not a JSON string. |
isTable | Integer string | No | Defaults to 1. Set 0 for an unwrapped data result without DataTables counts or paging. |
start | Integer string | No | Zero-based offset in table mode; defaults to 0. |
length | Integer string | No | Page size in table mode; defaults to 10. |
draw | Integer string | No | DataTables request counter; defaults to 0. |
limit | Integer string | No | Positive limit used only when isTable=0. Without it, non-table mode has no limit. |
orderBy / orderDesc | String | No | Named-field sort pair. orderBy is case-insensitively resolved to an allowed alias; use asc or desc for orderDesc. Both must be present to use this form. |
order[0][column] / order[0][dir] | Integer string / string | No | DataTables alternative. The implementation subtracts one from the column index before selecting from fields; missing values sort by the first allowed requested field ascending. |
Field filters | Scalar or form array | No | Any allowed field alias can also be a filter. Text/date aliases use case-insensitive substring matching for scalar values; numeric aliases use exact integer matching. Arrays become IN filters. |
searchValue | String | No | Case-insensitive substring search over all mapped fields, or only searchField. |
searchField | String or form array | No | One or more exact aliases for searchValue; defaults to All. |
referenceDate | String | No | Mapped date alias used by relative date/time controls, for example sentDate. Unknown aliases disable those controls. |
dateFrom / dateTo | Integer strings | With referenceDate | Relative day offsets from today in the tenant timezone. Both must be present. Datetime fields use inclusive day start/end boundaries. |
offsetFrom / offsetTo | Form objects | No | Optional hour and minute adjustments to the relative date boundaries. |
timeRangeFrom / timeRangeTo | Integer strings | No | Inclusive hours for the reference date in the tenant timezone; reversed endpoints are swapped. timeRangeFrom must be present to activate the range; timeRangeTo alone is ignored. |
groupBy | Form array | No | Allowed field aliases to group by. This changes SQL grouping but does not provide aggregate fields. |
Example request
$emails = FM_api('Customer_emailsGetDataTable', [
'fields' => ['id', 'sentDate', 'status', 'meta', 'recipients'],
'customerID' => '1088',
'customerType' => '0',
'start' => '0',
'length' => '25',
'draw' => '9',
'orderBy' => 'sentDate',
'orderDesc' => 'desc',
]);
Example response
{
"data": [
{
"id": "501",
"sentDate": "2026-09-24 11:01:02",
"status": "2",
"meta": "{\"job_id\":7204}",
"recipients": "[\"ops@example.test\"]",
"jobReference": "JOB-7204"
}
],
"draw": 9,
"recordsTotal": "320",
"recordsFiltered": "1"
}
Response rows are objects keyed by requested aliases; stored JSON such as meta and recipients remains encoded text. jobReference is added by reading meta.job_id and looking up the job.
Include meta when job references are needed. The post-processing code reads it even when not selected, so omitting it can produce a warning and leaves jobReference blank.
Errors and unusual responses
| Response | Condition |
|---|---|
{"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. |
{"error":"error in database query"} | The generic field, grouping, or ordering combination produces an invalid query. |
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 mail table is not in the generic helper’s soft-delete allowlist, so no deletion predicate is added.
- In table mode,
recordsTotalis every tenant mail row andrecordsFilteredapplies supplied filters. In non-table mode onlydatais returned. - Unknown requested fields are silently ignored. An empty or all-unknown field array still selects
idautomatically. - This endpoint exposes generic advanced-search controls inherited from the shared data processor. They are an internal CRM contract and are intentionally not presented as a supported integration interface here.
See it in Fieldmotion
CRM1
A source search found no CRM1 production caller for Customer_emailsGetDataTable. The customer Email History page uses Customer_emailsGetDT instead.
CRM2
A source search found no CRM2 production caller for this endpoint.
Related endpoints
Customer_emailsGetDTis the supported positional contract used by the CRM1 customer Email History page.- The customer Jobs data-table endpoint returns the jobs referenced by derived
jobReferencevalues.