When to use this endpoint

Use JobType_setArchived for CRM1’s inline archive toggle. Archiving is safer than JobType_delete when jobs already refer to the type.

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
idInteger stringYesPositive job-type ID.
valInteger stringYesComplete archive value after integer conversion. CRM uses 0 for active and 1 for archived, but any integer is accepted.

Example request

$result = FM_api('JobType_setArchived', [
	'id' => '42',
	'val' => '1',
]);

Example response

{
  "ok": 1
}

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: id"}The ID is absent or integer-converts below one.
{"error":"missing or invalid parameter: val"}val is absent or null.

Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.

Behaviour and edge cases

  • Any nonzero archive value excludes the type from active-only selectors; table/detail calls can still return it.
  • The write runs even when the stored value already matches, so last_edited advances on every valid call.
  • Existing jobs retain their type ID.

Side effects

  • Updates archived and current last_edited, then advances the job-type cache marker.
  • This focused legacy setter does not write a generic field-level audit entry.

See it in Fieldmotion

CRM1

Open Settings → Job Types and change the Archived column. CRM1 calls this endpoint directly.

CRM2

CRM2’s Job Types module uses JobType_updateData, including for bulk archive/unarchive, rather than this focused route.

Related endpoints