When to use this endpoint

Tasks_setStatus is an unsafe legacy bulk helper retained for compatibility. New code should use Task_updateField with field=status or update each task deliberately.

Authentication and permissions

The request must establish an authenticated tenant context with signed API credentials or a logged-in CRM session. This legacy handler uses the tenant database prefix without calling the normal login guard.

It performs no task, page, role, ownership, or privacy-permission check. Any visibility restriction described below comes from request filters or a specific server-side rule, not from a general Tasks permission check.

Parameters

ParameterTypeRequiredDescription
idsNative arrayYesTask IDs inserted directly into an SQL IN list. Send a nonempty array containing numeric IDs only.
valNumeric stringYesRaw status expression. Intended values are 0 New, 1 Open, 2 Closed, and 3 Archived, but the handler does not enforce that allowlist or quote/escape the value.

Example request

$result = FM_api('Tasks_setStatus', [
	'ids' => ['318', '319'],
	'val' => '2',
]);

Example response

{
  "ok": 1
}

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":"missing or invalid parameter: ID"}ids is absent.
{"error":"missing or invalid parameter: Val"}val is absent. Blank is accepted.
{"ok":1}Also returned when no task matches. There is no affected-row count.

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 update has no deleted=0 condition, so matching soft-deleted tasks are changed as well.
  • It does not validate task existence, status range, transition rules, ownership, or privacy. An empty/scalar ids value is not cleanly handled.

Side effects

  • Updates only status and invalidates the task cache. It does not update last_edited, write field history, send notices/notifications, or log per-task outcomes.

See it in Fieldmotion

CRM1

No direct CRM1 caller was found.

CRM2

No direct CRM2 caller was found. Current CRM2 bulk status changes use Task_updateData.

Related endpoints