Tasks
Set task time spent
/a/Task_setTimeSpent
Set the numeric time-spent value displayed as task minutes by the legacy CRM.
When to use this endpoint
Use Task_setTimeSpent for CRM1’s Minutes Spent field. The API stores the supplied numeric value directly; it performs no duration conversion.
Authentication and permissions
The request must establish an authenticated tenant context with signed API credentials or a logged-in CRM session. The handler checks for the tenant database prefix rather than calling the normal login guard.
It performs no additional task, page, role, ownership, or privacy-permission check. A caller that knows an active task ID in its tenant can address it regardless of the CRM screens’ visibility rules.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Integer-compatible | Yes | Task ID. Row existence and active state are not checked. |
time_spent | Float-compatible | No in implementation | Raw stored value, treated as minutes by CRM1. Missing or nonnumeric input becomes 0; negative/fractional values are accepted. |
Example request
$changed = FM_api('Task_setTimeSpent', [
'id' => '318',
'time_spent' => '15',
]);
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 absent or below 1. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Writes the float-coerced value and refreshes
last_edited. Omitting the value silently resets it to zero. - The endpoint does not enforce minimums, maximums, rounding, task existence, or active state.
Side effects
- Invalidates the task cache. It creates no audit history or notifications.
See it in Fieldmotion
CRM1
Open Tasks, edit a task, and change the corresponding field. CRM1’s task dialog and Task Main page load Task_get and save changed fields through the focused Task_set* routes.
CRM2
No direct production CRM2 caller was found. CRM2 mapped layouts use field minutes through Task_updateData.
Related endpoints
Task_getreturns the raw value astime_spent.Task_updateDatacalls this mapped fieldminutes.