When to use this endpoint

Read bootstrap.form_defaults immediately before saving. Send its revision and changed choices. Existing zero/blank Contract choices inherit at read/publication time; this does not rewrite individual overrides.

Send operation fields inside one JSON-encoded data object. When data is present it replaces top-level operation fields; otherwise the handler accepts the top-level request. String data is limited to 2 MB. Reserved transport/internal keys are removed. Malformed or non-array JSON becomes an empty input, so validate JSON before sending.

Authentication and permissions

Authenticate with a signed API key or logged-in CRM session; session requests follow dispatcher CSRF checks. API-key requests use the key owner’s identity and permissions.

Requires the Contracts entitlement (features & 64), features2.contractProgrammes and Contracts View. Requires Contracts Edit.

All storage belongs to the authenticated tenant. Contract operations follow the actor’s recursive HR manager/team scope, or the configured TeamAccess Contract/Department policy. Client administrators have broad Contract scope; private Programme and route ownership still applies. Active assignees must be within the permitted team.

Only a client administrator may perform this operation, in addition to the permissions above.

The tenant must have the Programme storage upgrade (foundation 803; independent route ownership 804 before planning). Requests never create or repair tables. A missing/incompatible storage failure can return an initialization/storage error or Contracts operation failed. Check the saved state before retrying.

Parameters

ParameterTypeRequiredDescription
revisionInteger-compatibleYesExact current revision; initial configuration uses 0.
service_form_id, qi_form_idPositive ID or 0NoUnarchived Job Form IDs; zero clears. Omitted values are preserved.
qi_field_idStringNoExisting select/selectbox/radio/contract-grade field ID on QI Form, at most 64 characters; blank clears. QI changes require contractProgrammeQI.

Example request

$result = FM_api('ContractProgramme_saveDefaults', [
	'data' => json_encode([
		'revision' => 0,
		'service_form_id' => 301,
		'qi_form_id' => 302,
		'qi_field_id' => 'grade',
	]),
]);

Example response

{
  "ok": 1,
  "form_defaults": {
    "service_form_id": 301,
    "qi_form_id": 302,
    "qi_field_id": "grade",
    "revision": 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":"Programme Contracts is not enabled"}Workspace flag or Contracts entitlement is disabled.
{"error":"Permission denied"}Contracts View or the required action permission is unavailable.
{"error":"Module settings changed. Reopen Module Settings before saving."}Revision is missing or stale.
{"error":"Selected Job Form is unavailable"}The resulting default is not an unarchived Job Form.

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

Behaviour and edge cases

  • Stores one revisioned tenant setting. Validate the full resulting Form/field combination, including unchanged values. Each successful save increments revision.
  • Changing inherited Service Forms invalidates pending previews. Already published Jobs and inspection snapshots retain their original configuration.

Side effects

  • The service serializes writes on the tenant owner in a transaction. Validation, persistence, audit or TeamAccess outstanding-Job access failures roll back that transaction. Successful changed writes refresh linked Contract/Customer sync timestamps and shared mobile update markers, then invalidate CRM caches after success. These operations do not create schema or enable account features.
  • Stores contract-programme-form-defaults and audits module_form_defaults_saved. QI changes advance inheriting Contract sync timestamps.

See it in Fieldmotion

CRM1

No direct caller was found in CRM1 source. This workflow is implemented by the opted-in CRM2 Programme Contracts workspace.

CRM2

Open Programme Contracts → Module Settings, change Forms and Save; filter for ContractProgramme_saveDefaults. The dialog reloads bootstrap before editing and sends that revision.

Related endpoints