Task types
Retrieve task types by ID
/a/TaskTypes_getById
Fetch selected raw task-type columns for one or several IDs.
When to use this endpoint
Use TaskTypes_getById when IDs are already known and a caller needs a narrow raw projection. CRM1’s task-import email page uses it through the shared TaskType object cache.
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 Settings-page, role, create, edit, or delete permission check.
All reads and writes use the authenticated tenant. CRM1 and CRM2 decide whether to show task-type controls, but these handlers do not repeat those client-side checks.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
ids | Native array, JSON array, or nonblank scalar | Yes | Task-type IDs. A JSON array is decoded; another nonblank scalar is wrapped as one ID. Each value is integer-converted. Duplicates are not removed. |
fields | Native array or JSON array | No | Allowed raw columns: id, name, cdate, and last_edited. Defaults to all. Unknown and duplicate names are ignored. |
Example request
$types = FM_api('TaskTypes_getById', [
'ids' => json_encode(['3', '7']),
'fields' => json_encode(['id', 'name']),
]);
Example response
[
{"id": "3", "name": "Customer follow-up"},
{"id": "7", "name": "Internal review"}
]
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: ids"} | ids is absent, blank, null, or cannot be normalized to an array. |
{"error":"no fields selected"} | fields is supplied but contains no allowed name. |
[] | The normalized ID array is empty or no row matches. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- There is no pagination, ordering, or deleted-state filter. Task types have no deleted column.
- Rows not found are omitted; input duplicates do not guarantee duplicate output rows because SQL
INhas set semantics. - Database-backed values remain JSON strings.
See it in Fieldmotion
CRM1
Open Imports → Tasks Email. CRM1’s TaskType.getInstance() batches ID lookups through TaskTypes_getById to display type names.
CRM2
No direct production CRM2 caller was found.
Related endpoints
TaskTypes_listreturns every ID/name pair in name order.TaskType_getRequestedDetailssupports mapped field names and exact filters.