Files
Get a stored filename
/a/File_getFilenameByEnumAndId
Return a file ID, expected type, and stored filename without loading the file bytes.
When to use this endpoint
Use File_getFilenameByEnumAndId when only a display filename is needed. The id parameter is the file ID despite the legacy function name.
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. The handler selects by file id while this entry path requires resource type_id; their correspondence needs confirmation.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Integer-compatible | Yes | Positive file ID. Use the tenant file-record ID returned by upload/list/detail calls. This is separate from type_id/typeId (the linked resource ID), and from the random token in a storage URL. |
type_enum | Integer-compatible | Yes | Expected positive file type. This is a file relationship category, not a second record ID. For Job files use 3, for Asset files 2; Customer 0 is rejected by these legacy handlers. Use File_getRequestedDetails or File_getFile for Customer attachments. |
Example request
$name = FM_api('File_getFilenameByEnumAndId', ['id' => '4821', 'type_enum' => '2']);
Example response
{
"id": "4821",
"type_enum": "2",
"filename": "asset-photo.jpg"
}
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: id"} | ID is non-positive. |
{"error":"missing or invalid parameter: type_enum"} | Type is non-positive. |
{"error":"no such file"} | No row matches both values. |
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. This is metadata-only: it does not touch object storage or refresh access time.
- Neither endpoint returns content. Their SQL id is the file-record ID; they do not search by the resource’s type_id. File_getByEnumAndId has the opposite selection contract: type_id is the resource ID and the newest matching file is streamed.
Side effects
- No content read, storage hydration, mail or record mutation.
See it in Fieldmotion
CRM1
No current direct CRM1 caller was found.
CRM2
No current direct CRM2 caller was found.
Related endpoints
File_getFileDetailsByEnumAndIdalso returns the storage URL.- File identifiers and downloads explains file ID, resource ID, type enum, stored URL and the different content response shapes.