When to use this endpoint

Use ScheduleOfRates_setCost for the focused base-price editor used by CRM1 and CRM2.

Authentication and permissions

The request must establish tenant context with signed API credentials or a logged-in CRM session. The handler checks for the tenant database prefix rather than calling the normal login guard.

No additional page or role permission is checked. The CRM screens apply their own client-side Schedule of Rates permissions.

Parameters

ParameterTypeRequiredDescription
idInteger stringYesPositive rate ID.
valNumberYes in practiceFloating-point base customer price. Missing/non-numeric input becomes 0; negative values are accepted.

Example request

FM_api('ScheduleOfRates_setCost', [
	'id' => '430001',
	'val' => 165.50,
]);

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"}The ID is absent or not positive.
{"ok":1}The positive ID does not exist; absence is not reported.

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

Behaviour and edge cases

  • The database column is named cost, but CRM screens present it as the customer-facing base price.
  • The update always runs and fires its event, even when the numeric value is unchanged.
  • These endpoints store the base price in cost; they do not calculate a customer’s final price. Job/quote consumers can apply meta.customerCosts, the tenant setting sor-child-gets-parent-price, and the customer’s price band later.

Side effects

  • Advances last_edited and the scheduleOfRates cache marker.
  • Fires the tenant-configurable SOR_edit event with the rate ID. Any configured listeners run synchronously and can add integration-specific side effects.

See it in Fieldmotion

CRM1

Edit the Default value in a rate’s Prices dialog or use legacy inline price editing.

CRM2

Open a rate’s Prices dialog and change Default. CRM2 calls this focused setter.

Related endpoints