Opportunities
Restore an opportunity
POST
/a/Opportunity_restore
Restore one soft-deleted opportunity through the Admin-console-only recovery path.
When to use this endpoint
Use Opportunity_restore only from the Admin deleted-object recovery workflow after an opportunity was soft-deleted.
Authentication and permissions
The request must have a logged-in tenant session whose login_source is exactly admin-console. A normal CRM session or signed API-key login is rejected.
The row is resolved only inside that authenticated tenant.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Integer string | Yes | Positive ID of a currently soft-deleted opportunity. |
Example request
$restored = FM_api('Opportunity_restore', [
'id' => '481',
]);
Example response
{
"ok": 1,
"type": "opportunity",
"id": 481,
"label": "Opportunity #481 (Replace reception lighting)",
"summary": {"type":"opportunity","id":481,"notes":"Replace reception lighting","name":"Replace reception lighting"}
}
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 integer-converts below one. |
{"error":"admin console login required"} | Login exists but did not originate from the Admin console. |
{"error":"deleted opportunity not found"} | The tenant has no opportunity with that ID and deleted=1. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Sets
deleted=0andddate=0. It does not validate linked customer/user/status rows or restore any related object. - The label appends the stored notes when nonblank. The summary contains
type, numericid,notes, and a duplicatenamederived from those notes.
Side effects
- Invalidates the opportunities cache and marks the newest active matching deletion-log row as restored, recording time, acting user, and restore function. A missing log row does not prevent restoration.
- Does not update
last_edited, write a generic opportunity audit entry, or send notifications.
See it in Fieldmotion
CRM1
Normal CRM1 screens do not expose this recovery route.
CRM2
Normal CRM2 screens do not expose this recovery route; it belongs to the separate Admin deleted-object workflow.
Related endpoints
Opportunity_deletesoft-deletes one row.Opportunities_deletesoft-deletes a selection.