Files
Download the first file for a resource
/a/File_getByEnumAndId
Find the first file linked to a resource type/ID pair and stream it through the normal download handler.
When to use this endpoint
Use File_getByEnumAndId only for legacy single-file settings such as CRM1 custom styling. It cannot address Customer files because type 0 is rejected.
Authentication and permissions
Normal requests require signed API-key authentication or a logged-in CRM session and are scoped to that tenant. In CRM2, ordinary file types additionally require view permission on pageFiles; CRM1 does not apply that page permission.
File type 10 is always denied by the shared read guard. Types 6, 8, and 16 bypass that guard’s session/page-files checks, while types 6, 7, and 9 bypass only its CRM2 page check after login. Routes that explicitly call the login guard still require login, and download routes still need a resolvable tenant context. A separately established shareable-link context may also bypass the shared read guard.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
type_id | Integer-compatible | Yes | Positive resource ID. |
type_enum | Integer-compatible | Yes | Positive file type; zero is rejected. Common verified values are 0 Customer, 1 Asset Type, 2 Asset, 3 Job, 4 User, 5 recurring Job, 6 User photo, 7 report-design image, 8 Job form photo, 9 report PDF background, 10 private/non-downloadable, 11 form file, 12 Quote, and 13 email-template image. Other modules use later values; use the enum already emitted by the relevant CRM workflow. |
Example request
// Browser/download request
FM_api('File_getByEnumAndId', ['type_enum' => '3', 'type_id' => '7712']);
Example response
Raw bytes from the selected file; success exits through <code>File_get</code>.
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: type_id"} | Resource ID is non-positive. |
{"error":"missing or invalid parameter: type_enum"} | Type is zero, absent, or negative. |
{"error":"no such file"} | No live row matches. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Soft-deleted rows are excluded. All download permissions, headers, storage fallbacks, and side effects come from
File_get.
See it in Fieldmotion
CRM1
The custom-styles settings screen retrieves its single uploaded stylesheet through this route.
CRM2
No direct production CRM2 caller was found.
Related endpoints
File_getis the delegated download route.Files_listis deterministic for enumerating all linked files.