Stock allocations and movement records
Set an allocation threshold
/a/StockContainer_updateOneField
Save an amount/email threshold on the exact stock, owner and source-type allocation.
When to use this endpoint
Use the Stock-Level Trigger editor after a balance exists. Send all three identity components from the selected allocation; its row ID is not accepted as a substitute.
Authentication and permissions
Authenticate with a signed API key or a logged-in CRM session on the account’s routed host. Signed requests act as the key owner. Session requests must include the dispatcher CSRF value when configured. All record identifiers belong to the authenticated tenant.
The dispatcher and these handlers do not impose an additional CRM2 Stock role or Stock TeamAccess record scope. CRM2 screen permissions are separate controls and must not be assumed to apply to CRM1. These routes do not become public because an individual legacy handler checks only the tenant context.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
stock_id | Integer-compatible | Yes | Positive catalogue ID; the legacy error names id if this is missing. |
container_id | Nonblank string or integer | Yes | Owner identifier, including a vehicle UUID when stored that way. "0" is syntactically accepted. |
container_type | Nonnegative digit string or integer | Yes | Stored source type, including dispatched types. Use the row’s exact type; non-digit and negative values fail. |
field | String | Yes | Only amt_trigger. |
val | String | Yes | amount|email. Amount float-converts (blank/nonnumeric becomes 0); email must validate. Negative/fractional amounts are not prohibited. A numeric zero alone is not a complete threshold. |
Example request
$result = FM_api('StockContainer_updateOneField', ['stock_id'=>'1042','container_id'=>'1088','container_type'=>'1','field'=>'amt_trigger','val'=>'2.5|stock@example.test']);
Example response
{"ok":1}
Examples show one representative result; database numeric scalars can be JSON strings. Application errors can use HTTP 200: inspect error and warning in the decoded response.
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"} | stock_id missing/nonpositive. |
{"error":"Unable to find stock container"} | No matching tuple. |
{"error":"Unable to save stock trigger"} | Update failure. |
{"error":"invalid field: qty"} | Only amt_trigger is supported. |
{"error":"invalid email address: bad"} | The supplied email is invalid. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Normalizes amount to its numeric text followed by |email, ignoring additional pipe components. No threshold-clearing mode bypasses email validation.
- Checks for a matching allocation and checks the update result. If historical duplicates share the tuple, the update targets all of them. It does not require positive quantity or an active catalogue/owner row.
- Setting the threshold does not itself deliver an email or reserve stock. Later quantity-changing workflows decide whether to queue alerts.
- Numeric vehicle IDs and stored legacy UUIDs resolve the same vehicle allocation key for type2/type20, matching the detail/table output. Source type remains part of the identity; another owner family cannot be updated accidentally.
Side effects
- Writes amt_trigger and server last_edited on matching allocation rows, invalidates stock_container cache. No stock movement history, owner timestamp, Stock_edit or mail is emitted.
See it in Fieldmotion
CRM1
Open User Stock or an owner’s stock tab, click the threshold cell and save. stockContainerEdit sends the allocation’s stock_id/container_id/container_type and waits for an error-free response.
CRM2
Open User Stock, Vehicle Stock or All User Stock and edit Stock-Level Trigger. The caller sends the selected row’s owner and allocated/dispatched source type. Filter for StockContainer_updateOneField.
Related endpoints
Stock_containerList— read raw amount|email text for an owner.