When to use this endpoint

Use Customer_stockTotalsGetData for the CRM2 Customer Stock and Asset Stock summary tables.

For CRM1-compatible totals that include legacy “None” source entries, use Customer_stockTotalsGet.

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
idInteger stringYesPositive target ID. Existence of the customer, asset, or location is not checked.
customerTypeInteger stringNoJob target type: 0 customer (default), 1 asset, or 2 location. Other integer values are accepted but normally find no rows.
dateFromDate/time stringNoInclusive completed-time lower bound converted from tenant-local time to epoch. May be supplied independently.
dateToDate stringNoInclusive tenant-local completed-time upper bound through 23:59:59. May be supplied independently.
includeFormInteger stringNoDefaults to enabled. Set 0 to omit stock embedded in eligible table-form fields; CRM2 sends 0.

Example request

$totals = FM_api('Customer_stockTotalsGetData', [
	'id' => '1088',
	'customerType' => '0',
	'includeForm' => '0',
	'dateFrom' => '2026-09-01',
	'dateTo' => '2026-09-30',
]);

Example response

{
  "Filter cartridge": 5,
  "Cable 10m": 2.5
}

The result is keyed by current stock name, not ID. No matches return an empty JSON array ([]) rather than an empty object because the PHP result begins as an empty array.

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: id"}id is absent, zero, negative, or non-numeric.

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

Behaviour and edge cases

  • Jobs must be non-deleted, have non-zero completion state, match both target ID and customerType, and have metadata uses_stock=1.
  • Main stock_used entries whose source begins with -1 are skipped. This regression behavior prevents the stock picker’s “None” sub-status from contributing to totals.
  • The source exclusion is applied while reading main stock. Table-form entries are appended later and are not passed through that same source check.
  • Table-form extraction runs only when main stock_used decodes to a nonempty array and only for fields whose current form definition is stock or stock-single.
  • There is no pagination or explicit ordering. Missing stock IDs can become an empty-string name key.

See it in Fieldmotion

CRM1

A source search found no CRM1 caller for this newer totals variant. CRM1 uses Customer_stockTotalsGet.

CRM2

Open Customer Stock or Asset Stock and filter Network requests for Customer_stockTotalsGetData. Customer pages use the default target type; asset pages send customerType=1. Both currently send includeForm=0.

Related endpoints