Job types
Create a job type through the field map
/a/JobType_createData
Create a job classification through CRM2’s named field map, including defaults used when a job is prepared.
When to use this endpoint
Use JobType_createData for CRM2’s configurable Job Types create dialog. Use JobType_new when reproducing CRM1’s older name-only workflow.
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 |
|---|---|---|---|
name | String | Yes | Stored name. It must contain a non-whitespace character, but the original value is stored without trimming and is not checked for uniqueness or length. |
priority | Integer string | No | Default priority copied by job-editing screens. The mapped route integer-converts the value but does not check it against the tenant priority choices. |
notes | String | No | Complete default notes value. Plain text and CRM2’s encoded note-list text are both stored verbatim. |
meta | String or JSON-compatible value | No | Complete low-level metadata. Arrays/objects are JSON-encoded; strings are stored verbatim. Named meta* fields below are merged afterwards and take precedence for their keys. |
archived | Integer string | No | Archive value after integer conversion. CRM screens use 0 and 1, but this route does not enforce that range. |
nominalCode | String | No | Fallback nominal code used when an invoice is generated from a job and the customer supplies no usable default. No account lookup is performed. |
taxSettings | String or JSON-compatible value | No | Complete tax-settings value. Arrays/objects are JSON-encoded, strings are stored verbatim, and a blank string becomes SQL null. |
department | Integer string | No | Default department ID after integer conversion. The route does not verify that the department exists. |
metaFormID | String | No | Default form ID stored as meta.form_id. The route does not verify the form. |
metaSendNotification | String | No | Notification override stored as meta.send_notification. CRM uses 0 for fallback, 1 for no, and 2 for yes; this route accepts other text. |
metaNotificationEmail | String | No | Address stored as meta.notification_email. This mapped route does not validate email syntax. |
metaOrderNum | Integer string | No | CRM2 display order stored as meta.orderNum; defaults to 0, including when meta contains a different orderNum. |
lastEdited | Datetime string | No | Stored timestamp. Current server time is supplied when omitted; a supplied nonblank value is not date-validated. |
id | Any | No | Ignored during creation even though it is part of the shared field map. |
Example request
$created = FM_api('JobType_createData', [
'name' => 'Emergency repair',
'priority' => '4',
'department' => '7',
'metaFormID' => '18',
'metaSendNotification' => '2',
]);
Example response
{
"ok": 1,
"id": 42
}
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: name"} | name is absent, blank, or whitespace-only. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Unknown request keys are ignored. The operation creates exactly one row and has no filtering or pagination.
- Named metadata fields preserve other keys when
metais valid JSON. Invalid metadata text is replaced with an object when a named metadata field is merged. - Creating a type does not apply any defaults to existing jobs.
Side effects
- Inserts the tenant row, advances the job-type cache marker, and writes generic field-level audit entries for accepted and defaulted fields.
- No notification is sent and no job is created or changed.
See it in Fieldmotion
CRM1
A production-source search found no direct CRM1 caller. CRM1 creates a type with JobType_new.
CRM2
Open Settings → Job Types and create a row. The shared display widget derives JobType_createData from the Job Type API prefix.
Related endpoints
JobType_updateDataupdates the same mapped fields.JobType_newimplements the older duplicate-aware name-only create.