When to use this endpoint

Use to reconcile quantities across stock destination types; Total QTY intentionally excludes the three dispatch types.

Authentication and permissions

Authenticate with a signed API-key request or a logged-in CRM session. Requires Stock view (pageStocks_view) and table export (pageMain_exportTableData) permissions through the shared export guard; denial returns permission denied.

Client administrators and the all permission satisfy the checks. Legacy users with no role use the helper’s allow fallback when no explicit permission list is loaded. This is not merely the CRM1 export-button bit check.

Queries use the authenticated tenant. No department/owner restriction or stock-tracking feature gate is added by these handlers. CRM2 features2.stockTracking changes the export choices offered, not server authorization. Session CSRF and API signing still apply.

Parameters

ParameterTypeRequiredDescription
yesStringYesMust equal really. This compatibility confirmation is checked before the handler login/permission checks; it does not authorize the export.
stockIDsFilterComma-separated stringNoA string such as 1042,1088, not a JSON or native array. Omitted or blank/whitespace means no selection restriction. Tokens must be positive decimal IDs; whitespace is trimmed and duplicates are removed. Malformed, zero/negative or non-string lists return invalid parameter: stockIDsFilter.

Example request

$csv = FM_api('Stock_exportSummary', ['yes'=>'really']);

Example response

ID,Name,Code,Warehouse,Customer,Job,User,Vehicle,"Job Dispatch","User Dispatch","Vehicle Dispatch",Description,"Total QTY",Cost,Price,"Nominal Code","Tax Rate","Reference Type",Category,Status,"Price Bands","Manufacturer Part No",EAN/Barcode,"Trigger Level",Supplier,Notes,"Location Tags",Unit
1042,"Filter cartridge",FLT-01,7,0,0,0,0,0,0,0,"Replacement cartridge",7,4.5,6.75,4000,20,Batch,Filters,Active,"Retail:6.75",AC-01,12345,3,"Parts supplier","Service part","Cabinet A",pcs

Success is raw CSV, not JSON: retain the response body instead of JSON-decoding it. The response uses text/csv and the final download filename stock_summary.csv. Column positions and blank cells are meaningful.

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":"permission denied"}Either required export permission is denied.
{"error":"yes is not really"}yes is omitted or differs from really.
Header-only CSV or interrupted outputMost database reads are not checked for failure. A blank export is not proof that the database contained no matching rows; malformed stored JSON can interrupt legacy reports.
{"error":"invalid parameter: stockIDsFilter"}A supplied selected-ID list is not a string of positive decimal IDs.
{"error":"invalid parameter: search"}A supplied stock/date filter is an array or other non-scalar value; the error names that parameter.
{"error":"could not create stock export"}The per-request CSV stream cannot be created, written or rewound.

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

Behaviour and edge cases

  • Stock selection excludes deleted rows and otherwise uses only stockIDsFilter. Archived stock is included; no shared stock filters apply. Supplier/price-band names can include retained deleted rows; categories exclude deleted category rows.
  • Quantity columns sum stock_container by type: Customer=6, Job=7, User=1, Vehicle=2 and dispatched Job/User/Vehicle=18/14/20, preserving float sums.
  • Total QTY is warehouse in_stock plus all container amounts except types 14/18/20. Other types, including locations/storage/quote, contribute even though they lack individual displayed columns.
  • Reference Type reads the exact legacy metadata key referrenceType: 0 Batch, 1 Serial, 2 No Reference. Unit maps 0 pcs,1 length,2 weight; unknown/missing keys display blank.
  • Uses active category CSV membership, structured-note flattening, price-band name:value display and Active/Archived status. Location-tag arrays are comma-joined, while stored text remains unchanged.
  • No row order or date filter is declared.
  • No pagination or result limit is implemented. The entire result is exported; a header-only CSV is a valid empty result.
  • No stock quantity, audit, edit timestamp, notification or event is changed. Reads across multiple queries are not a transactionally frozen snapshot.
  • No direct caller for this exact endpoint was found in the current app JavaScript or m/www intermediary; these are office reporting/source-selection calls, not the app download protocol.
  • The shared guard rejects non-scalar supplied stock/date filters and validates any supplied stockIDsFilter even on reports that do not use it for selection.

Side effects

  • Builds CSV in a checked per-request php://temp stream, then streams it, closes it and exits. No shared tenant filename is written; concurrent requests generate independent files.

See it in Fieldmotion

CRM1

No direct caller for this exact endpoint was found in CRM1. Its Stock page has separate warehouse, user, vehicle, customer and cost export actions.

CRM2

Open Stocks, choose Export, select the matching report and submit. Filter Network for Stock_exportSummary (the posted form uses php/api.php with extra=/Stock_exportSummary). CRM2 supplies yes=really and a comma-separated stockIDsFilter for the selected export scope.

Related endpoints