When to use this endpoint

Use to price a supplied stock-ID set for one customer. This does not calculate tax, totals, inventory valuation or schedule-of-rates pricing.

Authentication and permissions

Authenticate with signed API-key fields or a logged-in CRM session; all normal calls use that tenant. These handlers do not enforce an additional role or finance-page permission.

Use strings for signed numeric values, including values inside native arrays. Only JSON-encode parameters explicitly described as JSON text; see Getting started.

Parameters

ParameterTypeRequiredDescription
stockPositive integer scalar or nonempty native arrayYesEach member must be a valid positive integer. A scalar is normalized to one member; native-array members are validated and deduplicated before SQL construction. JSON text is not decoded.
customerIDInteger-compatible scalarNoInteger-coerced customer ID. Uses the non-deleted customer’s stored price_band; omission, zero, missing/deleted customer or missing band gives base prices. No parent-price inheritance.

Example request

$prices = FM_api('Stocks_getPrice', ['stock'=>['1042', '1043'], 'customerID'=>'1088']);

Example response

{"1042":{"id":"1042","price":11.39},"1043":{"id":"1043","price":22.5}}

Example shows relative mode. The outer JSON object is keyed by stock ID; inner id remains a database string. Base price remains a database string; fixed override preserves the stored JSON scalar type; relative price is numeric. Empty results are [], not {}.

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: stock"}stock omitted, empty, nonpositive, noninteger or malformed, whether scalar or native array.
{"error":"missing or invalid parameter: customerID"}customerID is supplied as a non-scalar value.
[]No supplied stock IDs exist; missing IDs are otherwise omitted without placeholders.
{"error":"pricing read failed"}A checked stock, customer or band read fails.

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

Behaviour and edge cases

  • Excludes deleted stock and deleted customer rows. Archived (not deleted) stock is still eligible. Invalid stock IDs produce an error; missing valid IDs are omitted. There is no paging or ORDER BY; repeated IDs collapse to one keyed row.
  • With is_relative=0, a non-null per-stock price_bands entry for the customer’s band overrides base price, including numeric/string zero. Missing/null override falls back to base.
  • With is_relative=1, returns round(base price × relative_multiple, 2), ignoring fixed overrides. Other flag values fall back to base. Changing a band does not rewrite stored stock price.
  • Removes the stored price_bands JSON from the response. Does not return band IDs, tax, currency, quantities or audit metadata; no finance-feature or rounding tenant setting is consulted.
  • CRM2 Stock.getCustomerPrice honors fixed zero overrides but retains four-decimal relative rounding. This endpoint continues rounding relative prices to two decimals.
  • The mobile app has no direct caller for this endpoint in the searched JavaScript or m/www intermediary. It downloads price bands through syncDownloads into its local priceBands table.

Side effects

  • Read-only; no price storage, audit, cache invalidation or customer update.

See it in Fieldmotion

CRM1

No direct CRM1 browser caller was found. Stock price-band selectors use PriceBands_list and document workflows apply their own pricing calculations.

CRM2

No direct caller for Stocks_getPrice was found. Stock.getCustomerPrice loads Stocks_getById and PriceBands_getById, then calculates the customer price locally; inspect those requests instead.

Related endpoints