Contracts
Restore a contract
/a/Contract_restore
Restore one soft-deleted contract through the restricted Admin-console recovery flow.
When to use this endpoint
Use Contract_restore only from the Admin deleted-items workflow after verifying the contract should return to the tenant.
Ordinary CRM/API clients cannot use this route even with a valid tenant API key.
Authentication and permissions
The request must be a logged-in session whose login_source is exactly admin-console. Signed API-key authentication alone is not sufficient.
The lookup and restore are tenant-scoped by the Admin session.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Integer string | Yes | Positive ID of a contract currently stored with deleted=1. |
Example request
$restored = FM_api('Contract_restore', [
'id' => '720',
]);
Example response
{
"ok": 1,
"type": "contract",
"id": 720,
"label": "Contract #720 (North Region Service Contract)",
"summary": {
"type": "contract",
"id": "720",
"name": "North Region Service Contract"
}
}
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 ID is absent or nonpositive. |
{"error":"admin console login required"} | The authenticated session was not created by the Admin console. |
{"error":"deleted contract not found"} | The ID is unknown or the row is not currently soft-deleted. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
deletedbecomes0andddatebecomes0. Other contract fields are unchanged.- The label includes the current contract name when present. There is no pagination.
Side effects
- Invalidates the contracts cache and annotates the newest active
deleteslog row with restored status, time, user, and route.
See it in Fieldmotion
CRM1
There is no CRM1 caller. Recovery is exposed through the separate Admin deleted-items interface.
CRM2
There is no CRM2 caller. CRM2 users cannot invoke the Admin-console-only restore flow.
Related endpoints
Contract_deletecreates the soft-deleted state and deletion log.Contract_getcan read the contract again after restoration.