When to use this endpoint

Use MarketingExpense_updateData for CRM2 edits or when changing several expense fields together. Omitted fields remain unchanged.

Authentication and permissions

The request must authenticate with signed API-key fields or a logged-in CRM session. The handler requires login but performs no additional Marketing-page, create, edit, delete, or role-permission check.

All reads and writes use the authenticated tenant’s tables. CRM1 and CRM2 hide some controls through client-side permissions; these routes do not repeat those UI checks.

Parameters

ParameterTypeRequiredDescription
idInteger-compatible or native arrayYesMarketing-expense ID. Prefer a scalar ID because the shared multi-row updater discards individual errors.
sourceInteger-compatibleNoMarketing-source ID. It is integer-converted but the endpoint does not verify that the source exists. Omission during creation leaves the database default 0.
expenseNumeric-compatibleNoExpense amount converted with floatval(). Omission during creation leaves the database default 0.
expenseDateDate stringNoExpense date in exact YYYY-MM-DD form. Blank is accepted; other invalid dates are rejected by mapped create/update routes.
createDateUnix timestamp or date stringNoCreation time stored as a Unix timestamp. Creation defaults to the current server time.
lastEditedUnix timestamp or date stringNoEdit time stored as a Unix timestamp. Creation defaults to now and ordinary updates advance it automatically.

Example request

$result = FM_api('MarketingExpense_updateData', [
	'id' => '7124',
	'expense' => '450.75',
	'expenseDate' => '2026-10-15',
]);

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"}No id key is present.
{"error":"invalid date parameter: expenseDate"}A nonblank date is not exact YYYY-MM-DD.

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

Behaviour and edge cases

  • Source is integer-converted and expense is float-converted. Source existence is not checked.
  • A native ID array is accepted, but individual row errors are discarded; use scalar IDs.
  • Successful changes advance lastEdited unless it is explicitly supplied.

Side effects

  • Changed fields are recorded in Core history and the marketing-expense cache is invalidated.

See it in Fieldmotion

CRM1

CRM1 uses the three dedicated MarketingExpense_set* routes for inline changes.

CRM2

Open Marketing → Marketing Expenses in CRM2 and filter browser developer tools for the exact function name. Edit an Expense table cell; the shared display widget derives this update route.

Related endpoints