Opportunities
Set an opportunity status
/a/Opportunity_setStatus
Change a legacy opportunity status, creating and linking a quote when the requested value is 2.
When to use this endpoint
Use Opportunity_setStatus for CRM1’s inline Status selector. CRM2 uses Opportunity_updateData, where its Quoted value is 3.
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 | Opportunity ID after integer conversion. |
val | Integer string | Yes | Replacement status. Exact integer 2 invokes Opportunity_convertToQuote instead of a direct status update. |
Example request
$result = FM_api('Opportunity_setStatus', [
'id' => '481',
'val' => '2',
]);
Example response
{
"ok": 1,
"quoteId": 9021
}
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"} | id is omitted. |
{"error":"missing or invalid parameter: val"} | val is omitted. |
{"error":"opportunities is not existing."} | The row is absent—or its current status is numeric zero, which the implementation also treats as missing. |
{"ok":"1","warning":"no change required"} | The requested integer loosely equals the current status. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- For values other than 2, the route writes the integer without checking a status row or transition rule.
- The lookup/update does not exclude soft-deleted opportunities. A zero current status cannot be changed through this endpoint.
Side effects
- Ordinary changes update
status/last_editedand invalidate the opportunities cache, without audit/notifications. - Value
2creates a quote and links it usingOpportunity_convertToQuote, including that route’s quote audit entries.
See it in Fieldmotion
CRM1
The inline Status selector calls this route; rows already at status 2 are rendered as non-editable and linked to the quote.
CRM2
CRM2 uses mapped status updates and its own status constants; it does not call this route.
Related endpoints
Opportunity_convertToQuoteimplements the value-2 conversion.Opportunity_updateDatahandles CRM2’s Quoted value 3.