Customers
Migrate all legacy customer history
/a/Customers_optimiseChanges
Migrate every nonempty legacy customer change-history blob in the tenant.
When to use this endpoint
Customers_optimiseChanges is a legacy maintenance operation, not a normal integration endpoint.
Use the one-customer variant only when repairing a known row. Avoid running this tenant-wide route during busy periods because it scans and processes all candidate customers synchronously.
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
This endpoint has no operation-specific parameters.
Example request
$result = FM_api('Customers_optimiseChanges', []);
Example response
{
"ok": 1,
"optimised": 3,
"bytes_saved": 4812
}
optimised is the number of candidate customer blobs selected, not the number of new history rows inserted. bytes_saved is the sum of each original blob length minus two bytes for the replacement [].
Errors and unusual responses
| Response | Condition |
|---|---|
{"error":"not logged in"} | No authenticated tenant context is available. Invalid signed credentials can be rejected by the dispatcher before the handler runs. |
The batch wrapper has no application-level validation branch after login. Child migration failures are not represented in the response.
Behaviour and edge cases
- Selects every customer whose
changeslength is greater than two, ordered from shortest blob to longest. Soft-deleted customers are included. - Calls
Customer_optimiseChangesonce per candidate. Exact duplicate normalized rows are skipped by that child route. - The endpoint performs no pagination, continuation token, or maximum-row limit.
Side effects
- Replaces candidate
customers.changesblobs with[], inserts parsedcustomer_changesrows, and updateslast_editedfor customers receiving at least one new row. - Does not fire customer notifications or general edit events.
See it in Fieldmotion
CRM1
No production CRM1 network caller was found. CRM1 normally migrates at most one large legacy blob internally during page rendering.
CRM2
No production CRM2 JavaScript caller was found. The shared login path likewise performs targeted one-customer migration rather than calling this batch route.
Related endpoints
Customer_optimiseChangesdefines parsing and duplicate handling for one customer.Customer_getChangesDTreads normalized change history.