When to use this endpoint

Use for the old Add new supplier picker action. Supplier_new additionally supports ordinary supplier details and duplicate-name checks.

Authentication and permissions

Authenticate with signed API-key fields or a logged-in CRM session. This handler requires both a user identity and tenant context; it adds no stock-page, finance or administrator permission check.

All queries use the authenticated tenant. API signing and session CSRF checks still apply; see Getting started.

Parameters

ParameterTypeRequiredDescription
nameStringYesMust be nonblank after PHP trim. The string "0" is rejected by truthiness. Stored trimmed; response echoes the original untrimmed input. No uniqueness or handler length check.

Example request

$supplier = FM_api('Stock_supplierAdd', ['name'=>'Parts Depot']);

Example response

{"id":1088,"name":"Parts Depot"}

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 parameter: name"}Missing, blank/whitespace or string "0" name.
{"error":"stock catalog write failed"}A primary write or required history insert fails; the transaction rolls back.
{"error":"stock catalog read failed"}A checked read fails; a normalization or write transaction is rolled back.
{"error":"stock catalog transaction failed"}Transaction start or commit fails; no success is returned.
{"error":"stock catalog operation failed"}Unexpected database/runtime failure during the transaction.

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

Behaviour and edge cases

  • Inserts a trimmed name with server cdate/last_edited and edited_uuid=Stock_supplierAdd, in a checked tenant transaction with name history.
  • Other parameters, including stock id, are ignored. The supplier is not assigned to stock until a separate call. Duplicate names remain accepted; no supplier-page/admin/feature gate.
  • Response echoes the original untrimmed name with a positive numeric ID. Failed insertion or history returns an error without an ID.
  • No direct mobile caller was found in the current app JavaScript or m/www intermediary. The app receives stock through syncDownloads, which selects non-deleted stock by edit timestamp; these calls are not the app synchronization protocol.

Side effects

  • Creates a supplier, its timestamps and checked name history; invalidates suppliers cache. Does not edit stock or create multi-supplier pricing records.
  • Runs configured Supplier_new after commit. A follow-up event exception returns the saved ID and a warning; do not create the supplier again.

See it in Fieldmotion

CRM1

Click a supplier cell on Stock and choose Add new. CRM1 prompts for name, calls Stock_supplierAdd, then calls Stock_supplierSet using its returned id.

CRM2

No direct CRM2 browser caller was found for this exact endpoint; the Stocks module uses mapped Stock reads and writes.

Related endpoints