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

ParameterTypeRequiredDescription
jobTypesNative array of objectsYesRows processed in input order. JSON text is not decoded. Each row can contain the fields below.
jobTypes[].nameStringYes per rowStored 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[].priorityInteger stringNoInteger-converted value; defaults to 3 and is not checked against tenant priority choices.
jobTypes[].notesStringNoStored verbatim; defaults to an empty string.
jobTypes[].archivedInteger stringNoInteger-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

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: 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 errorjobTypes 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_new creates one type and rejects an existing name.
  • JobTypes_listByNames supports name resolution with optional missing-row creation and import logging.