Files
Get the CRM1 Files table
/a/Files_getDT
Serve CRM1’s positional, server-paged Files table, including portal/mail options and outsourced Job files.
When to use this endpoint
Use Files_getDT only for the legacy DataTables contract. CRM2 uses Files_getDataTable.
Authentication and permissions
Use signed API-key authentication or a logged-in CRM session on the account’s routed host. File IDs and stored URLs normally resolve within that tenant; they are not public or cross-tenant identifiers. Session CSRF applies where required by the dispatcher.
The shared content-read guard denies type 10. For ordinary file types it requires a user session; CRM2 sessions (crmVersion=2) additionally need Files View (pageFiles_view). CRM1 does not receive that CRM2 page permission check.
Types 6, 8 and 16 return before the shared guard’s login/Files-page checks. Types 7 and 9 bypass the CRM2 Files-page check only after a user is established; type 6 is also treated as an app asset. An internal shareable-file context can bypass the remaining ordinary checks. Explicit route login checks still apply, and these exceptions do not override the dispatcher’s configured record-scope guard.
When department/team or Assigned Jobs Only scope is configured for the actor, the dispatcher adds record-scope checks. This is selected by account features/actor flags, separately from the CRM2-only Files View check; the existing TeamAccess entry guard has no CRM-version condition. Explicit supplied id/ids values are checked. Collection entry acceptance does not itself add a file-scope SQL predicate to these legacy mapped/table handlers; confirm the configured-scope collection contract before treating every returned row/count as authorized.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
start | Integer-compatible | Yes | Required nonnegative decimal integer offset. Presence is checked before login; after login/type checks, invalid numeric input is rejected. |
length | Integer-compatible | No | Defaults to 10. Must be nonnegative decimal integer text or scalar; 0 selects an empty local page and -1 is rejected. Outsourced rows can still be appended separately. |
draw | Integer-compatible | No | Echoed as an integer. |
order[0][column] / order[0][dir] | Integer / string | No | Defaults to column 0 and asc. Columns 0/1/other select cdate, 2 filename. Direction must be exact asc or desc. Malformed array/column/direction returns a validation error. No stable ID tie-breaker. |
search[value] | String | No | Case-insensitive substring across notes, description, raw metadata, and filename. |
type_enum / type_id | Integer-compatible | No | Exact relationship filters. For Customer type 0 with a nonzero ID, direct parent Customer files flagged for site sharing are also included. |
Example request
$table = FM_api('Files_getDT', [
'draw' => '1',
'start' => '0',
'length' => '25',
'order' => [['column' => '1', 'dir' => 'desc']],
'search' => ['value' => 'service'],
'type_enum' => '3',
'type_id' => '7712',
]);
Example response
{
"draw": 1,
"iTotalRecords": "4",
"iTotalDisplayRecords": "2",
"data": [
[4821, "2026-09-20 10:15:00", "service-photo.jpg", "created by ...", [0,1,1,0,0], "Notes", "", "service", 0]
]
}
Each row is [id,cdate,filename,description,options,notes,blank,tags,originTenant]. Options are customer-readable, include-in-email, show-in-portal, edit-notes-in-portal, and share-with-sites; outsourced rows omit the fifth option.
For Job files, linked outsourcing metadata can append rows read from another tenant. Their final value is that origin tenant ID, used in the download oid.
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: start"} | Start is absent. |
{"error":"permission denied"} | The requested file type fails the read guard. |
{"error": "missing or invalid parameter: length"} | Negative/nondecimal page size. |
{"error": "missing or invalid parameter: order"} | Malformed sort structure or direction. |
{"error": "missing or invalid parameter: search"} | search is not an object/array or its value is not text. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Local rows always exclude soft-deleted files. Customer listing calls
Customer_rebuildFilesCsvas a read side effect before resolving parent sharing. - Descriptions can contain server-generated HTML and CRM1 link rewriting. Missing descriptions may trigger a per-row User-name lookup.
- There is no tenant setting controlling the query; portal/share flags come from file columns/metadata.
- Outsourced Job rows are appended after local pagination, without matching the local search/order/length, and are excluded from the local counts. data can therefore exceed the page size and counts; originTenant distinguishes those file IDs.
- The Customer-site total count excludes inherited parent rows while the filtered count/data can include them. The handler may rebuild a Customer’s cached file CSV before selecting its files.
Side effects
- Customer type-0 site listing calls the Customer file-list rebuild helper. Other table reads do not fetch file bytes.
See it in Fieldmotion
CRM1
Open Files on a Customer, Job, Asset, User, recurring Job, Task, or Asset Type. Searching, sorting, and paging use this endpoint.
CRM2
No primary CRM2 caller was found; CRM2 uses the named-field table.
Related endpoints
Files_getDataTableis the CRM2 contract.- File identifiers and downloads explains file ID, resource ID, type enum, stored URL and the different content response shapes.