Job types
Create a batch of job types
/a/JobTypes_new
Insert a batch of basic job types for the dedicated CRM1/CRM2 job-type import tools and return one status per input row.
When to use this endpoint
Use JobTypes_new only for the legacy batch format used by the dedicated Job Types import screen. For one interactive type use JobType_new; for mapped CRM2 creation use JobType_createData.
Authentication and permissions
The request must authenticate with signed API-key fields or a logged-in CRM session. The handler performs no additional page or role-permission check.
The lookup and any write use the authenticated tenant; an ID from another tenant cannot be addressed through this call.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
jobTypes | Native array of objects | Yes | Rows processed in input order. JSON text is not decoded. Each row can contain the fields below. |
jobTypes[].name | String | Yes per row | Stored verbatim. PHP-empty values, including empty string and string "0", produce a row error; whitespace is accepted. No trim, length, or duplicate check is applied. |
jobTypes[].priority | Integer string | No | Integer-converted value; defaults to 3 and is not checked against tenant priority choices. |
jobTypes[].notes | String | No | Stored verbatim; defaults to an empty string. |
jobTypes[].archived | Integer string | No | Integer-converted archive value; defaults to 0. Values outside 0/1 are accepted. |
Example request
$result = FM_api('JobTypes_new', [
'jobTypes' => [
['name' => 'Emergency repair', 'priority' => '4', 'notes' => 'Escalate immediately'],
['name' => 'Inspection', 'archived' => '1'],
],
]);
Example response
{
"statuses": [
{"ok": 1, "id": 42},
{"ok": 1, "id": 43}
]
}
An invalid row occupies its input position as {"error":"name not set"}; valid rows before and after it can still be inserted.
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: jobTypes"} | The top-level key is absent. |
{"statuses":[{"error":"name not set"}]} | A row has no name or has a PHP-empty name. |
Runtime warning or type error | jobTypes is not a native iterable array or contains unsupported row shapes. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Every accepted row receives current server datetime in
last_edited. No ordering, filtering, pagination, or batch-size limit is applied. - Only name, priority, notes, and archived state are accepted. Other row keys are ignored.
- The handler removes the request’s server-side referrer value before iterating, a legacy request-context side effect with no response field.
Side effects
- Inserts tenant job-type rows but does not explicitly invalidate the job-type cache, write import history, or write field-level audit entries.
- No jobs or existing job defaults are changed.
See it in Fieldmotion
CRM1
Open Settings → Job Types and use the dedicated import button. The importer chunks parsed rows and calls JobTypes_new.
CRM2
The CRM2 dedicated Job Types import control calls the same batch route with native row arrays.
Related endpoints
JobType_newcreates one type and rejects an existing name.JobTypes_listByNamessupports name resolution with optional missing-row creation and import logging.