When to use this endpoint

Use Supplier_createData when supplying the camel-cased fields from the supplier map. CRM2 reaches it indirectly through Layout_setValue when a Supplier Create layout is saved.

Use Supplier_new only for the smaller legacy CRM1 create dialog.

Authentication and permissions

The request must authenticate with signed API-key fields or a logged-in CRM session. The handler calls the normal login guard but performs no additional Suppliers-page, stock, purchasing, role, create, edit, or delete permission check.

All records are selected from the authenticated tenant. CRM1 and CRM2 hide some controls through client-side permissions, but these endpoints do not repeat those UI checks.

Parameters

ParameterTypeRequiredDescription
idInteger-compatible or arrayNoIgnored for creation; the database assigns the ID.
nameStringYesSupplier name. It must be nonempty when creating through the mapped route.
contactName, streetAddress1, streetAddress2, town, county, countryStringNoContact and address values. country maps directly to the tenant table’s three-character country column.
postcodeStringNoMaximum 20 characters.
emailEmail stringNoMaximum 64 characters. A nonblank value must pass PHP email validation.
phoneStringNoMaximum 40 characters.
notesString or notes JSONNoSupplier notes. When the value is a notes array, newly added @username tokens can create Fieldmotion notices.
website, terms, accountNumber, typeStringNoMapped supplier text fields. The mapped website field has no application-level 64-character limit.
taxIdStringNoMaximum 20 characters.
refNumberStringNoMaximum 16 characters.
isActive, onHoldInteger-compatibleNoConverted with intval(). Conventionally use 0 or 1.
metaStringNoComplete raw metadata value. Prefer the named accounting fields when changing their keys.
accountsContact, accountsEmail, additionalEmailStringNoStored inside meta as contact_accounting, email_accounting, and email_extra. accountsEmail validates a nonblank email address.
customValuesJSON-compatible valueNoStored in custom_values. Creation defaults it to an empty JSON object.
createDate, lastEditedSQL datetime stringNoDefault to the server’s current date and time on creation. Normal updates advance lastEdited automatically.
editedUuidStringNoMapped synchronization marker.

Example request

$supplier = FM_api('Supplier_createData', [
	'name' => 'Northshore Components',
	'contactName' => 'Aisling Byrne',
	'email' => 'orders@example.test',
	'accountsEmail' => 'accounts@example.test',
	'country' => 'IRL',
]);

Example response

{"ok":1,"id":488104}

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: name"}The required name field is absent or blank.
{"error":"Invalid email address."}A mapped email field is nonblank but invalid.
{"error":"email is too long."}A mapped value exceeds the maximum defined in the supplier map; the field name changes with the failing input.

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

Behaviour and edge cases

  • Only mapped camel-case fields are stored; unknown request fields are ignored.
  • No duplicate-name check is performed, unlike Supplier_new.
  • createDate, lastEdited, and customValues receive mapped defaults when omitted.

Side effects

  • Creates the tenant supplier row, clears the supplier cache, and writes field-level history entries.
  • Can create notices for newly mentioned users in structured notes.
  • Fires the configurable Supplier_new event after creation.

See it in Fieldmotion

CRM1

CRM1 does not call this mapped route; its Create dialog calls Supplier_new.

CRM2

Open Stock → Suppliers in CRM2 and filter browser developer tools for the exact function name. Choose Create and save the configured Supplier Create layout. The browser sends Layout_setValue, which dispatches internally to Supplier_createData.

Related endpoints