When to use this endpoint

Use Customer_stockTotalsGet for the CRM1 customer Stock Used totals shown beneath the job table.

Use Customer_stockTotalsGetData for CRM2, asset targets, or exclusion of main stock entries whose source represents “None”.

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 customer ID. The customer row is not checked for existence.
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 exact integer-like 0 to omit stock embedded in eligible table-form fields.

Example request

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

Example response

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

The JSON object is keyed by each stock row’s current name, not stock ID. Quantities are sums of stored amt values and can be integers, decimals, or numeric strings coerced by PHP addition. No matches encode as an empty JSON array ([]), not an empty object.

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 is_complete, target the customer directly (customer_type=0), and have metadata uses_stock=1.
  • The endpoint starts table-form extraction only when the job’s main stock_used value decodes to a nonempty array. A job with stock only in subforms contributes nothing.
  • When form stock is enabled, only fields whose saved form definition still identifies them as stock or stock-single are read.
  • Main stock entries whose source starts with -1 are included by this older endpoint. The newer data variant excludes them.
  • There is no pagination or ordering. Missing/deleted stock records can produce an empty-string object key.

See it in Fieldmotion

CRM1

Open a customer’s Stock Used tab. Filter Network requests for Customer_stockTotalsGet; opening the page and changing its date range refresh the summary object.

CRM2

CRM2 does not call this older endpoint; its customer and asset pages use Customer_stockTotalsGetData with includeForm=0.

Related endpoints