When to use this endpoint

Use Opportunities_getDT only for DataTables-compatible CRM1 consumers. CRM2 uses Opportunities_getDataTable and named fields.

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 draw token, integer-converted and echoed.
start / lengthInteger stringsNoSQL offset/row count; defaults to 0/10. No maximum is enforced.
order[0][column] / order[0][dir]Integer / desc-or-otherNoSort selection. Direction is descending only for exact desc; otherwise ascending. Server column mapping is ID, created epoch, user name, customer name, value, notes, status name, source name.
dateFrom / dateToRelative-day numbersTogether optionalWhen both exist, filter cdate from server-calendar midnight plus dateFrom days through, but not including, the day after dateTo.
userID / customerID / value / notes / status / sourceRaw scalar filtersNoExact SQL filters. Values are interpolated without consistent conversion/escaping; only trusted CRM-generated values should be used.
search[value]StringNoCase-insensitive substring search after trimming/lowercasing.
search[field]StringNoOne of id, createDate, userID, customerID, value, notes, status, source, or default All. Unknown names apply no search predicate.

Example request

$table = FM_api('Opportunities_getDT', [
	'draw' => 4,
	'start' => 0,
	'length' => 25,
	'dateFrom' => -30,
	'dateTo' => 0,
	'order' => [['column' => 1, 'dir' => 'desc']],
]);

Example response

{
  "data": [
    ["481","1790413200","12","18","1042","2500","Replace reception lighting",["{...}",null],"1","7",null,"",""]
  ],
  "draw": 4,
  "recordsTotal": 37,
  "recordsFiltered": 12
}

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"}draw is omitted. Its numeric value may be zero.
Database/runtime errorA raw filter contains unsafe syntax, paging is invalid, or nested DataTables inputs have the wrong shape.

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

Behaviour and edge cases

  • Each row contains: ID, creation epoch, form ID, user ID, customer ID, integer value, notes, [form_values, subform_values], status ID, lead-source ID, quote ID, empty string, empty string.
  • Both counts exclude soft-deleted opportunities. Related user/customer/status/source joins do not exclude deleted/inactive related rows.
  • No department/account-manager restriction is applied for non-admin users, and the handler does not enforce the CRM page access bit.

See it in Fieldmotion

CRM1

The Opportunities page sends DataTables paging, ordering, search, and its saved relative creation-date range here.

CRM2

CRM2 does not use this route.

Related endpoints