Maxim

Maxim

Last updated on Oct 8, 2026

Updates a product and its components. Only the fields you pass are changed, the rest stay as they were.

v1/products/edit.php

Parameters

Field Type Required Description
product_id int Yes Product ID
name string No Name
sku string No SKU
unit string No Unit of measure
price float No Sale price per unit
batch_size float No Batch size
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
alternative_sku array No Alternative SKUs: objects with sku and label. Replace the current ones as a whole
materials array No Materials in the components
products array No Subassemblies in the components
resources array No Resources in the components. Replace the current ones as a whole

Product components

The components are defined per batch (batch_size units) and passed as the arrays materials, products (subassemblies) and resources.

materials and products lines

Field Type Required Description
id int Yes Material or product ID
amount_per_batch float Yes Quantity per batch
unit string Yes Line unit. From the same group as the material or product unit: for a material in "kg", "kg" or "g" fit
loss_percent float No Loss, in percent. Default 0. Accepted only if showing loss in components is enabled in the company settings
position int No Line position in the components

If at least one of the materials and products arrays is passed, materials and subassemblies are replaced as a whole, and the array that is not passed is treated as empty. For example, if you pass only materials, the subassemblies are removed from the components.

position sets the order of component lines in the Controlata interface, shared by materials and products. Lines without it go last, in the order passed. Controlata renumbers positions from 0, so in Retrieving a Product they may differ from the ones you passed.

resources lines

Each resource line contains the resource id. Whether amount_per_batch and unit are needed depends on the resource type (see Creating a Resource):

Resource type amount_per_batch unit
Fixed rate Quantity per batch, e.g. work hours Required
Fixed rate, price specified in the product components A money amount per batch Not needed
Percentage Not passed: taken from the resource Not needed
Percentage, specified in the product components The percentage Not needed
Depreciation Quantity per batch, e.g. equipment hours Required

Example request

A new sale price and material components. No subassemblies are passed, so they are removed from the components; resources stay the same.

{
    "product_id": 3120,
    "price": 47000,
    "materials": [
        {
            "id": 2051,
            "amount_per_batch": 0.6,
            "unit": "cu m",
            "loss_percent": 5
        },
        {
            "id": 2060,
            "amount_per_batch": 400,
            "unit": "pcs"
        }
    ]
}

Change only the minimum stock:

{
    "product_id": 3120,
    "minimum": 3,
    "storage_id": 3999
}

Example response

{
    "success": true
}

Errors

Error Reason
No product_id in input product_id is missing
Product not found or access denied Product not found or deleted
Name must not be empty An empty name was passed
Name must be a string Name passed not as a string, e.g. as an array
Unit not set An empty unit of measure was passed
Unit not found Unknown unit of measure
Unit cannot be changed to another unit group: the product is used in components of other products Changing the unit group of a product used in other products' components
Batch size must be greater than 0 Batch size is 0 or less
No storage_id in input minimum passed without storage_id
Storage ID not found Storage location not found or deleted
Product is not stored in storage location 3999, so its minimum cannot be set there The product is not stocked at the storage location
Invalid price value. Must be a number The value is not a number (same for batch_size and minimum)
Category 12 not found Category not found
Supplier not found or access denied Supplier not found or deleted
SKU must be from 1 to 50 characters for alternative_sku 0 The alternative SKU is empty or longer than 50 characters
Label must not exceed 100 characters for alternative_sku 0 The alternative SKU caption is longer than 100 characters

Errors in component lines

In the error text, instead of 2051 there is the item ID, and instead of 0 the line number in the array (from 0).

Error Reason
Materials is not an array materials was not passed as an array (same for products and resources)
Line 0 of materials must be an object The line is not an object (same for products and resources)
No id for material 0 The material id is missing or not a number (same for product)
Material 2051 not found Material not found or deleted
Product 2051 not found Product not found or deleted
Product cannot be a component of itself The product was added to its own components
Amount per batch must be greater than 0 for material 2051 The quantity is missing, not a number, or 0 after rounding to 3 decimals (same for product and resource)
Unit not found for material 2051. Use a unit of the same group as the material unit The unit is missing, unknown or from another group (same for product)
Loss percent must be from 0 to 100 for material 2051 Loss is below 0, above 100 or not a number (same for product)
Loss percent is disabled in company settings for material 2051 Loss was passed, but showing loss in components is disabled in the company settings (same for product)
Resource for line 0 not found Resource not found or deleted
Percent must not exceed 100 for resource 2051 The percentage in the components is above 100
Unit not found for resource 2051. Use a unit of the same group as the resource unit The resource unit is missing, unknown or from another group