Tasks
Create a legacy task
/a/Task_create
Create a task through the legacy CRM1-compatible contract and optionally queue assignment email.
When to use this endpoint
Use Task_create when maintaining a legacy integration that sends the older snake-case or camel-case task fields. New CRM2-style integrations should prefer Task_createData.
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 |
|---|---|---|---|
client_id / clientId | Integer-compatible | Yes (either name) | Customer ID. Presence is checked, but zero and an ID that does not identify a customer are accepted. |
details | String | Yes | Task details. Empty and string "0" values are rejected by PHP’s truth test. |
assigned_to / assignedTo | Integer-compatible | No | Assigned user ID; defaults to 0 (not assigned). The endpoint does not verify that the user exists. |
subject | String | No | Maximum 128 bytes. When blank or omitted, it is derived from details, with newlines replaced by spaces, then truncated to 128 bytes. |
due_date | String | No | Stored without date-format validation. A missing, blank, or 0 value becomes the current server datetime. |
assigned_date / assignedDate | String | No | Assignment datetime. A missing or blank value becomes the current server datetime. |
type | Integer-compatible | No | Task type ID; defaults to 0. No task-type lookup is performed. |
status | Integer-compatible | No | Stored integer status; defaults to 0. CRM values are 0 New, 1 Open, 2 Closed, and 3 Archived, but this route does not enforce that list. |
privacy | Integer-compatible | No | Defaults to 0. CRM values are 0 Private and 1 Public, but other integers are not rejected. |
resolution | String | No | Trimmed resolution text; defaults to an empty string. |
time_spant | Float-compatible | No | Legacy misspelled wire field stored in time_spent; defaults to 0. time_spent and minutes_spent are ignored by this endpoint. |
Example request
$task = FM_api('Task_create', [
'client_id' => '1042',
'assigned_to' => '17',
'type' => '3',
'subject' => 'Confirm access details',
'details' => 'Confirm the site access details with the customer.',
'due_date' => '2026-10-02 09:30:00',
'status' => '1',
'privacy' => '1',
]);
Example response
{
"ok": 1,
"id": 318,
"user_id": 17,
"customer_id": 1042
}
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: client_id"} | Neither customer parameter name is present. |
{"error":"you must fill in the task details"} | details is missing or false-like. |
{"error":"Subject too long. 128 characters max"} | An explicitly supplied subject is longer than 128 bytes. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Creates one active row in the authenticated tenant with current
cdate/last_editedvalues and the current user ascreated_by. There is no duplicate detection or idempotency key. - Customer, assignee, type, status, privacy, and datetime values are not validated against related rows or allowlists.
- If derived subject text is longer than 128 bytes, the truncation uses the original details rather than the newline-normalized value.
Side effects
- Invalidates the task cache. This legacy creator does not write mapped field-history entries or call the generic notification service.
- Unless tenant setting
block-task-email-notificationsis truthy, it may queue assignment mail. Enablednotification_types.task_change_userconfiguration controls template and customer/user/creator/other recipients; without enabled configuration, the legacy fallback sends to the assigned user. A zero assignee queues nothing. - Mail configuration errors are ignored after the task is inserted, so the endpoint can return success even when no configured recipient is valid.
See it in Fieldmotion
CRM1
Use the global New Task dialog or the Tasks page Create action and filter the network panel for Task_create. Task edits from that dialog use the focused setters instead.
CRM2
No current production CRM2 caller was found. CRM2 creates tasks through Task_createData; direct calls here occur in regression/setup code.
Related endpoints
Task_createDatais the mapped CRM2 creator with audit, mention, and notification-service side effects.Task_getreads the created row through the fixed legacy response.