Contracts
Set contract status
/a/Contract_setActive
Set a contract to active or completed and keep its completion date and expiry-status worker aligned.
When to use this endpoint
Use Contract_setActive for the CRM1 inline status control on a known non-deleted contract.
CRM clients use 1 for active and 0 for completed. Do not send the field-map-only value 2 through this focused setter.
Authentication and permissions
The request must establish an authenticated tenant context through signed API-key fields or a CRM session. The handler checks DBP but does not separately require a user ID.
No page or role-permission check is performed.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Integer string | Yes | ID of a non-deleted contract. A present value is integer-converted, so blank becomes zero and then fails the existence check. |
active | Integer string | Yes | Use 0 to complete or 1 to activate. Other integers are not rejected before storage but are unsupported by this setter’s audit-label logic. |
Example request
$result = FM_api('Contract_setActive', [
'id' => '720',
'active' => '0',
]);
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":"no ID provided"} | The id key is omitted. |
{"error":"no active value provided"} | The active key is omitted. A present blank value converts to zero. |
{"error":"contract does not exist"} | No non-deleted contract has the converted ID. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Setting
0records the current server date-time indate_completed. Every other value clearsdate_completedto null. - Repeating the same status still updates
last_edited, recalculatesdate_completed, reschedules expiry-status work, and writes an audit entry. - Expiry itself does not change
active; the expiry worker only fills a previously-null completion date.
Side effects
- Updates status/completion fields, invalidates the contracts cache, replaces the pending global type-104 expiry-status row from the current expiry, and writes a contract audit entry.
See it in Fieldmotion
CRM1
On Contracts, a customer’s Contracts tab, or an asset’s Contracts tab, change the Active column between Active and Completed and filter Network requests for Contract_setActive.
CRM2
CRM2’s configurable contracts list updates status through Contract_updateData; no direct client call to this focused setter was found.
Related endpoints
Contract_setExpiryDatecontrols the date that drives the expiry worker.Contract_updateDatacan update the mappedactivefield.Contract_deletehides a contract through soft deletion instead.