Suppliers
Delete or hold a supplier
/a/Supplier_delete
Soft-delete an unused supplier, or place it on hold when purchasing records still depend on it.
When to use this endpoint
Use Supplier_delete for supplier removal from CRM1 or CRM2. Callers must handle both successful deletion and the protective on-hold response.
Authentication and permissions
The request must establish an authenticated tenant context with signed API credentials or a logged-in CRM session. This legacy handler checks for the tenant database prefix rather than calling the normal login guard.
It performs no additional Suppliers-page, stock, purchasing, role, create, edit, or delete permission check.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | Integer-compatible | Yes | Tenant supplier ID. The value is integer-converted; zero is accepted after presence validation. |
Example request
$result = FM_api('Supplier_delete', [
'id' => 488104,
]);
Example response
{"ok":1}
When an active purchase order or any purchases-in row refers to the supplier, the response is {"hold":1,"error":"cannot delete supplier as there are purchase orders or purchases-in linked to it. marked as on_hold instead"}.
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":"no Supplier ID provided"} | The id key is absent. |
{"hold":1,"error":"cannot delete supplier as there are purchase orders or purchases-in linked to it. marked as on_hold instead"} | Purchasing history prevents deletion; the supplier is changed to on hold. |
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 nondeleted purchase orders are counted, while every matching purchases-in row is counted.
- An unreferenced row is soft-deleted with
deleted=1, a deletion time, and an updatedlast_editedvalue. - Stock and stock-supplier relationship rows are not deleted.
- An unknown ID follows the nominal success branch and returns
{"ok":1}.
Side effects
- Logs a supplier deletion and clears the supplier cache on the soft-delete branch.
- Removes queued global supplier uploads and tenant accounting-sync links when a parent tenant ID exists in the session.
- The dependency branch sets
on_hold=1without advancinglast_edited.
See it in Fieldmotion
CRM1
Open Stock → Suppliers in CRM1 and filter browser developer tools for the exact function name. Edit a supplier, choose Delete, and confirm the dialog.
CRM2
Open Stock → Suppliers in CRM2 and filter browser developer tools for the exact function name. Select one or more rows and use Delete Suppliers; CRM2 calls this route once per selected ID.
Related endpoints
Supplier_restorerestores a successfully soft-deleted supplier from an Admin Console session.Supplier_getStatusreads the on-hold marker.