When to use this endpoint

Use Customer_financialsExport from the CRM1 customer Financials page after applying date, job type, department, or status filters.

This endpoint streams CSV and terminates the request. The FM_api() helper returns that CSV as a string; do not JSON-decode it.

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
customerIdInteger stringYesIntended to be a positive customer ID. Legacy validation rejects missing, zero, and negative numeric values, then integer-casts the input; always send a positive numeric value. Customer existence is not verified.
dateFromDate/time stringNoInclusive tenant-local lower bound converted to epoch time. When present, dateTo is consumed.
dateToDate stringWith dateFromInclusive tenant-local upper bound through 23:59:59.
daysFromInteger stringNoInclusive relative-day lower bound from server-calculated today, converted to tenant-local epoch. When present, daysTo is consumed.
daysToInteger stringWith daysFromRelative-day upper bound; midnight after that day is exclusive.
jobTypeInteger stringNoExact job type ID; zero and blank do not filter.
department_idInteger stringNoExact department ID; zero and blank do not filter.
status_idInteger stringNoExact completion-state filter. Blank means all; 0 selects incomplete jobs.

Example request

$csv = FM_api('Customer_financialsExport', [
	'customerId' => '1088',
	'dateFrom' => '2026-09-01',
	'dateTo' => '2026-09-30',
	'status_id' => '1',
]);
file_put_contents('northwind-financials.csv', $csv);

Example response

ID,Contract,Date,Labour,Mileage,Stock,"Total Costs",Price(Net),Price(Gross),Tax,Profit
7204,"Annual Maintenance","2026-09-24 10:30:00",80.00,12.00,45.00,137.00,300.00,369.00,69.00,163.00

The response is CSV, not JSON. Job date/time is converted to the tenant’s local time. There is no explicit row ordering.

The attachment filename is <customer name>_customer_finance.csv. The legacy handler sends a nonstandard Content: text/plain header rather than Content-Type.

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: customerId"}customerId is absent, zero, or a negative numeric value.
Header-only CSVNo job matches, including when a positive but nonexistent customer ID reaches the 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 customer/job predicate is exactly customer_type=0 and parent_id=customerId OR (customer_id=customerId AND parent_id IN (0,-1)).
  • The export accepts the same date, job-type, department, and status filters as Customer_financialsGetDT, but it has no search, sort, pagination, or count fields.
  • Total costs substitute zero for NULL components; profit can remain NULL because its arithmetic does not use those substitutions.
  • The endpoint performs no explicit financial-export permission check. CRM1 decides whether to show the export button.

See it in Fieldmotion

CRM1

Open a customer’s Financials tab and select its export action. Filter Network requests for Customer_financialsExport. CRM1 shows the export control only when permission bit 256 is not set, but the endpoint itself only authenticates the tenant.

CRM2

A source search found no CRM2 caller for this CSV export.

Related endpoints