When to use this endpoint

Use Task_setDueDate for CRM1 Task Main’s absolute date/time edit. Use Task_move only for a relative calendar offset.

Authentication and permissions

The request must authenticate with signed API-key fields or a logged-in CRM session. The handler calls the normal login guard but performs no additional task, page, role, ownership, or privacy-permission check.

All reads and writes use the authenticated tenant. CRM1 and CRM2 apply task visibility and editing permissions in their interfaces, but these handlers do not repeat those client-side rules.

Parameters

ParameterTypeRequiredDescription
idInteger-compatibleYesTask ID. Row existence and deletion state are not checked.
due_dateDigits or datetime-containing stringYesAll-digit input is interpreted as Unix seconds using the server timezone. Otherwise the string must contain a YYYY-MM-DD HH:MM:SS sequence; the regex is not anchored, and the complete original string is stored.

Example request

$changed = FM_api('Task_setDueDate', [
	'id' => '318',
	'due_date' => '2026-10-03 10:00:00',
]);

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"}ID is absent or below 1.
{"error":"missing or invalid parameter: due_date"}Due date is absent or trims to blank.
{"error":"due_date must be a unix timestamp"}The value is neither all digits nor a string containing the accepted datetime pattern. The message is misleading because datetime strings are accepted.

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

Behaviour and edge cases

  • Numeric epochs are formatted with PHP date() in the API process timezone; the endpoint does not perform a tenant-timezone conversion.
  • Datetime matching is not anchored or calendar-validating. For example, surrounding text can pass the regex and then be stored unchanged.
  • Updates last_edited but has no active/existence check, so deleted or missing IDs still return success.

Side effects

  • Invalidates the task cache. It writes no audit entry or notification.

See it in Fieldmotion

CRM1

On a task’s Task Main page, change Due Date. CRM1 converts the chosen datetime to Unix seconds and calls Task_setDueDate.

CRM2

CRM2 calendar and layout saves use Task_updateData with mapped dueDate.

Related endpoints

  • Task_move applies a signed minute offset for CRM1 drag-and-drop.
  • Task_updateData stores mapped due dates without this route’s format gate.