Files
Download one file
/a/File_get
Stream one stored file to the browser with a safe MIME type and attachment disposition.
When to use this endpoint
Use File_get for normal download links. Use File_getFile when JavaScript needs base64 content instead.
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 |
|---|---|---|---|
id | Integer-compatible | Yes | Positive file ID. Soft-deleted rows are rejected. |
oid | Integer-compatible | No | Read from another tenant only for a Job file that is linked back to the current tenant through verified outsourcing metadata. Other types or unlinked jobs are denied. |
return | Any | Internal only | Presence suppresses the final exit; it is used by internal calls and is not part of the browser-download contract. |
Example request
// Navigate a browser to:
/a/File_get/id=4821
Example response
Raw file bytes. The response is not JSON on success.
The route sends X-Content-Type-Options: nosniff. Known image/PDF extensions receive a browser MIME type; unknown types are application/octet-stream. Downloads use a sanitized stored filename.
Legacy rows with a blank URL fall back to customers/<type_id>/<filename>, then to the older numeric storage path if needed.
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 absent or non-positive. |
{"error":"not logged in"} | No tenant context can be resolved. |
{"error":"no such file"} | No non-deleted file row matches. |
{"error":"permission denied"} | The file type, CRM2 Files permission, or cross-tenant outsourcing guard rejects the read. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Reading archived/object-backed content may restore bytes into the tenant database and refresh
last_accessedwhen it is more than seven days old. A missing storage object produces an empty successful body. - The endpoint exits after streaming, so API wrappers expecting JSON must not use it as an ordinary data call.
See it in Fieldmotion
CRM1
Click a filename on Customer, Job, Asset, User, recurring-Job, Task, or shared file tables.
CRM2
Click a filename or photo download link. CRM2 disables ordinary links when the user lacks pageFiles_view.
Related endpoints
File_getFilereturns JSON-safe base64 content.File_getByUrlreturns metadata and bytes for an internal storage URL.