Suppliers
Create a legacy supplier
/a/Supplier_new
Create the small supplier record accepted by CRM1’s quick-create dialog.
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
| Parameter | Type | Required | Description |
|---|---|---|---|
name | String | Yes | Trimmed nonempty name. It must not exactly match another active supplier name. |
account_number | String | No | Trimmed account number. |
ref_number | String | No | Trimmed reference number. This route does not enforce the table’s 16-character limit. |
phone | String | No | Trimmed phone number, maximum 40 characters. |
website | String | No | Trimmed website, maximum 64 characters on this legacy route. |
tax_id | String | No | Trimmed tax ID, maximum 20 characters. |
email | String | No | Trimmed and checked for a maximum of 64 characters, but not written by this endpoint. |
postcode | String | No | Trimmed 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
| 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: 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_newevent. - 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
Supplier_createDatasupports the complete mapped supplier schema.Supplier_editfills in the legacy fields after creation.