When to use this endpoint

Use the exact field/val keys. This is different from Stock_updateField, whose field names use the mapped camelCase contract.

Authentication and permissions

Authenticate with a signed API key or a logged-in CRM session on the account’s routed host. API keys act as their owner; session calls require dispatcher CSRF protection where configured. IDs address the authenticated tenant.

The handler checks that the tenant database context is defined rather than calling Core_requireLogin. Use normal authenticated dispatcher access; this is not a public or cross-tenant endpoint. No extra Stock page-action/CRM2 role check is added here.

Parameters

ParameterTypeRequiredDescription
idInteger-compatibleYesPositive stock catalogue ID. It is not a stock-container row ID, category ID or supplier ID.
fieldStringYesExactly name,code,is_archived or amt_trigger.
valNon-null valueYesname must be a nonblank string up to 80 bytes; code may be blank and is limited to 182 bytes. is_archived must be 0 or 1. amt_trigger must be amount|email; amount float-converts and email must validate.

Example request

$result = FM_api('Stock_updateOneField', ['id'=>'18', 'field'=>'amt_trigger', 'val'=>'5|stock@example.test']);

Example response

{
  "ok": 1
}

Application errors can use HTTP 200. Inspect error/warning fields; database numeric values can be strings unless this handler explicitly converts them.

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 absent or integer-converts below 1.
{"error":"missing or invalid parameter: field"}field is absent/null.
{"error":"missing or invalid parameter: val"}val is absent/null.
{"error":"invalid field: price"}The field is not on the four-field allowlist.
{"error":"invalid email address: bad"}The threshold email is invalid.
{"error":"parameter too long: code"}Code exceeds 182 bytes.

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

Behaviour and edge cases

  • Allowlist remains name,code,is_archived,amt_trigger. name must be a nonblank string up to 80 bytes; code retains the 182-byte limit; archive values must be 0/1. Threshold email validation and amount|email normalization remain.
  • Locks an undeleted item, checks persistence, updates last_edited/edited_uuid and records history before Stock_edit. Missing rows no longer acknowledge a save.
  • Setting a threshold does not itself deliver an alert.
  • Primary changes and stock history use a checked transaction. Failed validation/read/write/commit returns an error and rolls back open changes. Configured events/notices run after commit; a post-commit warning means the save succeeded and must not be repeated blindly.

Side effects

  • Stock field/history/cache writes and post-commit Stock_edit events.

See it in Fieldmotion

CRM1

Open Stock in CRM1. The legacy grid is Stock_getDT and its editor/inline actions use legacy Stock routes. Inspect the exact function name in the browser Network panel. Edit Code, archive or minimum-stock threshold in the Stock table.

CRM2

CRM2 moduleStocks archive inline edits use full Stock_updateData with isArchived. Stock_updateField is the generic mapped one-field counterpart, with different hooks; neither accepts the legacy is_archived field name in field/val.

Related endpoints

  • Stock_updateField — Set one mapped field for one or more stock items using the inline-save contract.
  • Stock_updateData — Update stock fields, category membership and picker values through the full mapped save.
  • Stock_get — Read the full saved stock row, with selected manufacturing metadata flattened for the legacy editor.