When to use this endpoint

Use Opportunity_setSource for CRM1’s Lead Source column. New code should prefer Opportunity_updateData.

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

ParameterTypeRequiredDescription
idInteger stringYesOpportunity ID after integer conversion.
valInteger stringYesReplacement marketing_source; blank/non-numeric values become zero.

Example request

$result = FM_api('Opportunity_setSource', [
	'id' => '481',
	'val' => '7',
]);

Example response

{
  "ok": 1
}

Errors and unusual responses

ResponseCondition
{"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.

Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.

Behaviour and edge cases

  • No opportunity/source existence, active-state, deleted-state, feature, or edit-permission check is performed. Missing IDs still return success.

Side effects

  • Sets marketing_source, updates last_edited, and invalidates the opportunities cache.
  • Does not create audit history or notifications.

See it in Fieldmotion

CRM1

Click an Opportunities row’s Lead Source cell and leave the select to call this route.

CRM2

CRM2 edits the mapped source field through Opportunity_updateData.

Related endpoints