Assets
Export asset location history
/a/Asset_exportLocationHistory
Download one active asset’s whereabouts and owner timeline as CSV.
When to use this endpoint
Use Asset_exportLocationHistory for the export button on CRM1’s asset Location History screen.
The route streams CSV and exits instead of returning JSON on success.
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
| Parameter | Type | Required | Description |
|---|---|---|---|
asset_id | Integer string | Yes | Positive asset ID. The CSV contains data rows only if that asset currently exists and is not soft-deleted. |
search | Any | No | CRM1 submits this key, but the endpoint ignores it. |
Example request
// Submit an authenticated POST/download request to /a/Asset_exportLocationHistory:
[
'asset_id' => '4821',
]
Example response
MID,Name,Location,Owner,Dates,Duration,Job ID
551,"Northwind Service Centre","1 Main Street, Dublin, Dublin, D02 XY12","Northwind Service Centre","24/09/2026 - ","0 days",7719
The response has Content-Type: text/csv and attachment filename asset_location_history.csv. Rows are ordered by movement ID ascending.
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. |
{"error":"missing or invalid parameter: asset_id"} | asset_id is absent, zero, or otherwise not positive. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Location display uses current target names plus an address snapshot at the movement time where available. Missing targets are labelled
UNKNOWN. - An asset target is described as
located with another asset. A site uses its historical town/postcode when available, otherwise its current free-text address. - Owner is reconstructed at each movement time. Explicit no-owner history is
No Owner; unavailable or now-missing owner history isUnknown. - Dates are
d/m/Y; an open movement leaves the end blank. Duration is the floor of elapsed whole days and is zero for an open movement. - The server writes
/tmp/<tenant>/tmp/asset_location_history.csv, overwrites it on another tenant export, and does not remove it.
Side effects
- Creates or replaces a tenant-scoped temporary CSV file. It does not change the asset or movement history.
See it in Fieldmotion
CRM1
Open an asset’s Location History tab and select Export.
CRM2
No direct production CRM2 caller was found; regression tests verify the owner column contract.
Related endpoints
Asset_locationsGetDTsupplies the paginated on-screen timeline.Asset_setLocationappends a new movement when whereabouts changes.