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

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. It requires a supported type_enum and visible type_id: 0 Customer, 2 Asset, 3 Job, 4 User, 13 Task or 14 Contract. Upload/deleteAll additionally require the owning object’s Edit grant.

Parameters

ParameterTypeRequiredDescription
type_idInteger-compatibleYesPositive resource ID. This is the linked object ID, never the file ID.
type_enumInteger-compatibleYesPositive 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 Task file. 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

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: 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.
  • type_id identifies the parent resource, not a file record. The newest means largest live file ID, not latest edit date. It is a single byte stream, not an attachment list.

Side effects

  • Storage reads can update access/size metadata, restore archived bytes and clear archive linkage, or hydrate missing database bytes from a configured backend. File content reads are not guaranteed read-only. No email or user notification is sent by the ordinary successful download path.

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