Contracts
Remove a legacy job link alias
/a/Contract_removeJob
Remove a job’s type-6 legacy contract link and invalidate a supplied contract’s customer/asset cache.
When to use this endpoint
Use Contract_removeJob inside a job mutation that is clearing or changing the contract.
The normal job save and delete implementations call it after handling the job row itself.
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 |
|---|---|---|---|
id | Integer string | Yes | Positive contract ID used only for the audit entry and dirty flag. It is not used to scope the link deletion. |
aid | Integer string | Yes | Positive job ID. Every type-6 link from this ID is deleted. |
Example request
$result = FM_api('Contract_removeJob', [
'id' => '720',
'aid' => '2039001',
]);
Example response
{
"ok": 1
}
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: id"} | The supplied contract ID is absent or not positive. |
{"error":"missing or invalid parameter: aid"} | The supplied job ID is absent or not positive. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- The handler does not verify the contract, job, or link. Missing rows return
ok. - It does not clear
meetings.contract_id; the caller must maintain that direct relationship. - The operation provides no filtering or pagination and is not transactional with the audit/cache changes.
Side effects
- Deletes all type-6 relationship rows for the job, writes a contract audit entry, and sets
customersDirtyon the supplied contract when that row exists.
See it in Fieldmotion
CRM1
Remove or change the Contract while saving/deleting a job. The surrounding job route calls Contract_removeJob internally; the browser does not normally issue it separately.
CRM2
CRM2 job saves reach this route indirectly through the job API when a contract assignment changes.
Related endpoints
Contract_addJobinserts the replacement legacy link.Contract_removeAppointmentis the compatibility alias.Contracts_getDTshows reconciled link results.