Files
Delete every file for a resource
/a/Files_deleteAll
Delete every live file linked to one resource type/ID pair by invoking the full single-file deletion workflow for each row.
When to use this endpoint
Use Files_deleteAll only when removing all attachments from a known resource. For selected IDs use File_delete individually.
Authentication and permissions
Normal API transport requires signed API-key fields or a logged-in CRM session and a tenant context. Session CSRF applies except for the dispatcher’s upload/download exceptions.
These handlers do not add general Files Add/Edit/Delete or file-owner role checks. UI visibility is not that protection. Configured team-scope entry checks are separate and may validate the linked record and its Edit permission before a handler runs; see the route-specific note below. This does not introduce CRM2 role requirements for ordinary CRM1 requests.
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
| Parameter | Type | Required | Description |
|---|---|---|---|
type_id | Integer-compatible | Yes | Positive linked resource ID. This is the linked object ID, never the file ID. |
type_enum | Integer-compatible | No | Defaults to 0 (Customer) when absent. 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
$result = FM_api('Files_deleteAll', ['type_enum' => '2', 'type_id' => '1042']);
Example response
{
"ok": 1
}
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 absent or non-positive. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Only rows that are live when the initial ID query runs are selected. Each call performs its type-specific parent-list rebuild/logging, which can repeat work many times.
- There is no pagination, upper bound, transaction, or final verification. An empty match also returns success.
- No pagination applies to this write. Use a fresh metadata/list read before dependent work; an error after storage, audit or notification work does not imply that earlier steps were rolled back.
See it in Fieldmotion
CRM1
No direct current CRM1 caller was found; screens normally delete one row at a time.
CRM2
No direct current CRM2 caller was found; the generic bulk framework uses Files_delete.
Related endpoints
File_deleteperforms each deletion.Files_deleteselects mapped matches and delegates the same lifecycle, stopping on the first returned error.- File identifiers and downloads explains file ID, resource ID, type enum, stored URL and the different content response shapes.