When to use this endpoint

Use Supplier_new for compatibility with CRM1’s Suppliers Create dialog. For complete mapped supplier fields, use Supplier_createData.

Authentication and permissions

The request must authenticate with signed API-key fields or a logged-in CRM session. This legacy handler checks the authenticated user ID directly.

The write is tenant-scoped and has no additional Suppliers-page, stock, purchasing, role, or create permission check.

Parameters

ParameterTypeRequiredDescription
nameStringYesTrimmed nonempty name. It must not exactly match another active supplier name.
account_numberStringNoTrimmed account number.
ref_numberStringNoTrimmed reference number. This route does not enforce the table’s 16-character limit.
phoneStringNoTrimmed phone number, maximum 40 characters.
websiteStringNoTrimmed website, maximum 64 characters on this legacy route.
tax_idStringNoTrimmed tax ID, maximum 20 characters.
emailStringNoTrimmed and checked for a maximum of 64 characters, but not written by this endpoint.
postcodeStringNoTrimmed and checked for a maximum of 20 characters, but not written by this endpoint.

Example request

$supplier = FM_api('Supplier_new', [
	'name' => 'Northshore Components',
	'account_number' => 'NS-42',
	'phone' => '+353 1 555 0180',
	'website' => 'https://example.test',
]);

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 name is absent or blank.
{"error":"Supplier with that name already exists","id":"488104"}An active supplier has the exact same stored name.
{"error":"postcode too long"}The supplied postcode exceeds 20 characters, even though this route does not save it.
{"error":"email too long"}The supplied email exceeds 64 characters, even though this route does not save it.
{"error":"phone number too long"}The phone exceeds 40 characters.
{"error":"website too long"}The website exceeds 64 characters.
{"error":"tax ID too long"}The tax ID exceeds 20 characters.

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

Behaviour and edge cases

  • The duplicate check considers active rows only and compares the complete stored name.
  • Only name, tax ID, account number, reference number, phone, website, creation date, and last-edited date are inserted.
  • The route performs no email-format validation and does not accept the full supplier address or accounting metadata.

Side effects

  • Creates an active supplier row, clears the supplier cache, and fires the configurable Supplier_new event.
  • It does not write the mapped field-history entries produced by Supplier_createData.

See it in Fieldmotion

CRM1

Open Stock → Suppliers in CRM1 and filter browser developer tools for the exact function name. Choose Create, fill the compact dialog, and save.

CRM2

CRM2 does not call this route; configured Supplier Create layouts save through Layout_setValue and Supplier_createData.

Related endpoints