Files
Set emailed-report inclusion
/a/File_setIncludeInMailReport
Add or remove the metadata flag that includes a linked file with an emailed report.
When to use this endpoint
Use File_setIncludeInMailReport from Job/related file options when the report-email workflow should attach this file.
Authentication and permissions
The request must authenticate with signed API-key fields or a logged-in CRM session and establish the tenant database context.
The handler performs no record-owner or resource-specific permission check. CRM screens may hide the action, but callers with tenant API/session access can target any matching file ID.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Integer-compatible | Yes | Positive file ID. |
val | Integer-compatible | No | Truthy stores meta.include_in_mail=1; false/absent removes the key. |
Example request
$result = FM_api('File_setIncludeInMailReport', ['id' => '4821', 'val' => '1']);
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: id"} | ID is non-positive. |
{"error":"file not found"} | The ID does not identify a live file. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Malformed legacy metadata is normalized before the flag is changed. The update does not change
last_editedor create an audit record. It affects later email assembly only when that workflow reads the flag.
See it in Fieldmotion
CRM1
Toggle attach/include in emailed report on Job, Task, or shared file tables.
CRM2
Job/file option menus call this route for the emailed-report switch.
Related endpoints
Files_getDataTableexposes the flag asmetaIncludeInEmail.