Updates a material. Only the fields you pass are changed, the rest stay as they were.
v1/materials/edit.php
Parameters
| Field |
Type |
Required |
Description |
| material_id |
int |
Yes |
Material ID |
| name |
string |
No |
Name |
| sku |
string |
No |
SKU |
| unit |
string |
No |
Unit of measure |
| price |
float |
No |
Price per unit |
| notes |
string |
No |
Notes |
| minimum |
float |
No |
Minimum stock at storage location storage_id |
| storage_id |
int |
With minimum |
Storage location where the minimum stock is changed |
| categories |
array |
No |
Categories: objects with id or name. Replace the current ones as a whole |
| suppliers |
array |
No |
Suppliers: objects with id. Replace the current ones as a whole |
Example request
{
"material_id": 2051,
"price": 135000,
"minimum": 1,
"storage_id": 3998
}
Example response
{
"success": true
}
Errors
| Error |
Reason |
| No material_id in input |
material_id is missing |
| Material not found or access denied |
Material not found or deleted |
| Name must not be empty |
An empty name was passed |
| Unit not found |
Unknown unit of measure |
| Unit cannot be changed to another unit group: the material is used in components of products |
Changing the unit group of a material used in product components |
| No storage_id in input |
minimum passed without storage_id |
| Material is not stored in storage location 3998, so its minimum cannot be set there |
The material is not stocked at that storage location |
| Invalid price value. Must be a number |
The value is not a number (same for minimum) |
| Category 12 not found |
Category not found |
| Supplier not found or access denied |
Supplier not found or deleted |