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

ParameterTypeRequiredDescription
nameStringYesStored name. It must contain a non-whitespace character, but the original value is stored without trimming and is not checked for uniqueness or length.
priorityInteger stringNoDefault priority copied by job-editing screens. The mapped route integer-converts the value but does not check it against the tenant priority choices.
notesStringNoComplete default notes value. Plain text and CRM2’s encoded note-list text are both stored verbatim.
metaString or JSON-compatible valueNoComplete 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.
archivedInteger stringNoArchive value after integer conversion. CRM screens use 0 and 1, but this route does not enforce that range.
nominalCodeStringNoFallback nominal code used when an invoice is generated from a job and the customer supplies no usable default. No account lookup is performed.
taxSettingsString or JSON-compatible valueNoComplete tax-settings value. Arrays/objects are JSON-encoded, strings are stored verbatim, and a blank string becomes SQL null.
departmentInteger stringNoDefault department ID after integer conversion. The route does not verify that the department exists.
metaFormIDStringNoDefault form ID stored as meta.form_id. The route does not verify the form.
metaSendNotificationStringNoNotification override stored as meta.send_notification. CRM uses 0 for fallback, 1 for no, and 2 for yes; this route accepts other text.
metaNotificationEmailStringNoAddress stored as meta.notification_email. This mapped route does not validate email syntax.
metaOrderNumInteger stringNoCRM2 display order stored as meta.orderNum; defaults to 0, including when meta contains a different orderNum.
lastEditedDatetime stringNoStored timestamp. Current server time is supplied when omitted; a supplied nonblank value is not date-validated.
idAnyNoIgnored 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

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: 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 meta is 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