When to use this endpoint

Use Files_upload from CRM2 drop zones sending multipart Filedata. Despite the plural name, one invocation processes one uploaded 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

ParameterTypeRequiredDescription
FiledataMultipart fileYesUses the uploaded temporary path and client filename. Multiple browser files are sent as separate requests by the widget.
type_idInteger-compatibleYesLinked resource ID; presence is checked but zero is accepted.
type_enumInteger-compatibleEffectively yesLinked resource type; omitted becomes zero. 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 email-template image. Other modules use later values; use the enum already emitted by the relevant CRM workflow.
uniqueInteger-compatibleNoTruthy stores the new file first, then deletes earlier live files for the same type/resource through the normal lifecycle.

Example request

// multipart/form-data
Filedata=@asset-photo.jpg
type_enum=2
type_id=1042

Example response

{
  "ok": 1,
  "id": 4821,
  "url": "files/2/1042/7d4f..."
}

Errors and unusual responses

ResponseCondition
{"error":"not logged in"}No authenticated tenant context is available. Invalid signed credentials can be rejected by the dispatcher before the handler runs.
{"error":"no file uploaded"}The multipart file collection is empty.
{"error":"missing or invalid parameter: type_id"}Type-ID key is absent.
{"error":"file too large. max file size is 12582912 bytes"}Content exceeds 12 MiB.
{"error":"failed to store file"}The storage helper returns a falsy result.

Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.

Behaviour and edge cases

  • The storage helper inserts metadata with uploader ID and updates legacy file lists for Customer, Asset, Job, User, and recurring-Job types. This wrapper additionally rebuilds Customer/Asset lists.
  • With unique=1, previous files are soft-deleted with content cleanup and deletion logs only after the replacement is stored. There is no cross-file transaction, content-type allowlist, filename normalization, or resource-existence check.

See it in Fieldmotion

CRM1

No primary CRM1 caller was found; CRM1 data-URI widgets use File_upload.

CRM2

Upload files on Customer, Job, Asset, User, Asset Type, photo, support, and shared file drop zones.

Related endpoints