Files
Get a file by storage URL
/a/File_getByUrl
Return a non-deleted file record and its stored bytes by internal storage URL.
When to use this endpoint
Use File_getByUrl for internal image/style/report workflows that retain a storage URL rather than a file ID. It is a heavy metadata-plus-content response.
For integrations starting with a file ID, File_getFile already returns a filename and base64 content together; no additional endpoint is needed for that response shape.
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. A URL-only request is not an accepted scoped collection request. Prefer an ID-based download with a verified file ID for scoped integrations; this handler’s URL selection is not itself a file-scope predicate.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
url | String | Yes | Exact stored tenant-relative URL, not a numeric file ID and not an external HTTP URL. For files/0/683084/<token>, 0 is the Customer file type, 683084 the linked Customer ID, and <token> an opaque random storage token. The separate file-record ID is returned as id. Copy url from upload or mapped metadata; never substitute file ID for a path segment. |
base64 | Integer-compatible | No | Exact integer 1 base64-encodes data; otherwise raw bytes are placed in the JSON field. |
Example request
$file = FM_api('File_getByUrl', ['url'=>'files/0/683084/abc123','base64'=>'1']);
Example response
{
"id": "4821",
"filename": "service-note.txt",
"description": "",
"notes": null,
"owner_id": null,
"meta": "{\"user_id\":37}",
"name": null,
"type_enum": "0",
"url": "files/0/683084/abc123",
"customer_readable": "0",
"deleted": "0",
"ddate": "0",
"storage_type": "0",
"storage_instance": "0",
"filesize": "6",
"data": "SGVsbG8K",
"last_accessed": "1794480000",
"mimetype": "application/octet-stream"
}
data is base64 only when base64 integer-converts to 1. The other selected storage/database columns are returned too, including last_accessed. Whole meta remains encoded JSON text. This projection does not include type_id or cdate; do not rely on the broader fields shown in older documentation.
The handler updates stale last_accessed after fetching the row, so the response can contain its previous value. It does not follow external URLs.
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: url"} | URL is blank or absent. |
{"error":"no such file"} | No non-deleted row has the exact URL. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- An exact URL lookup excludes deleted rows; duplicate URLs have no deterministic selection order. No pagination, ID lookup fallback or external URL fetch exists.
- Absent/zero/non-1 base64 leaves data as raw bytes in JSON. The dispatcher substitutes invalid UTF-8, so arbitrary binary data cannot be recovered reliably through that mode; use base64=1.
- If saved data is blank/null, the storage helper retrieves it. An access timestamp older than seven days is refreshed. Already populated database bytes are returned directly; this route does not always invoke archive restoration.
- MIME type uses the saved filename extension (URL only when filename is blank), not content inspection. It does not generally use the uploaded MIME type.
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
No direct current CRM1 JavaScript caller was found. Ordinary file tables use File_get; the custom-styles screen uses File_getByEnumAndId.
CRM2
Photo, Job-form, initialization, stock, and report-design widgets retrieve URL-backed images through this route.
Related endpoints
File_getstreams by ID with browser headers.- File identifiers and downloads explains file ID, resource ID, type enum, stored URL and the different content response shapes.