Production

8 articles Maxim By Maxim

Production

Production: making products from their components. You pass only the products and quantities, and Controlata calculates the consumption of materials, used products and resources from the product components, and the cost by FIFO. Via the API you can create, edit and delete production runs, change the status, and get a list and a production's details. Method paths are given relative to the base API URL; the rules common to all methods (authorization, request format, partial editing, pagination) are described in API Overview and Common Rules. Methods | Method | What it does | |---|---| | v1/production/get_statuses | Returns the company's production statuses | | v1/production/add | Creates a production run | | v1/production/edit | Updates a production run | | v1/production/delete | Deletes a production run | | v1/production/update_status | Changes the production status | | v1/production/get_list | Returns the list of production runs | | v1/production/get_entry | Returns a production run with its products and consumption |

Production Statuses

Returns the company's production statuses in the order they appear in Controlata. Statuses can be configured individually, so get the codes with this method rather than hardcoding them in your integration. v1/production/get_statuses.php Parameters The method takes no parameters; the request body can be omitted. Response An array statuses. | Field | Type | Description | |---|---|---| | code | int | Status code. It is passed as status in v1/production/update_status and v1/production/get_list | | name | string | Status name | Codes run in order starting from 0. If the company has not configured statuses, the default ones are returned: | Code | Status | |---|---| | 0 | Planned | | 1 | In progress | | 2 | Done | Statuses created in the company come with the names given to them in Controlata. Example request {} Example response { "success": true, "statuses": [ { "code": 0, "name": "Planned" }, { "code": 1, "name": "In progress" }, { "code": 2, "name": "Done" } ] } Errors The method only returns the common authorization and request-limit errors, see API Overview.

Creating a Production Run

Creates a production run. Controlata calculates the consumption of materials, used products and resources from the product components; you do not pass it. v1/production/add.php Parameters | Field | Type | Required | Description | |---|---|---|---| | products | array | Yes | Products to make, see below | | date | string | No | Production date, YYYY-MM-DD. Default today | | name | string | No | Name | | notes | string | No | Notes | | produce_subproducts | int | No | 1: produce subassemblies together with the products, 0: deduct them from stock ready-made. Default per company setting | | materials_storage_id | int | No | Storage location materials are deducted from. 0: choose automatically | | subproducts_storage_id | int | No | Storage location used products are deducted from. 0: choose automatically | | products_storage_id | int | No | Storage location the produced products are added to | products line: | Field | Type | Required | Description | |---|---|---|---| | id | int | id or sku | Product ID | | sku | string | id or sku | Product SKU | | amount | float | Yes | Quantity, greater than 0 | A product is specified by id or sku (it is also matched by alternative SKUs). The same product can be listed in several lines. A new production run is created with the status from the Default status for new production setting. Example request { "date": "2026-10-06", "name": "Batch of tables", "products": [ { "id": 512, "amount": 10 }, { "sku": "P-CHAIR-01", "amount": 40 } ], "materials_storage_id": 3998, "products_storage_id": 4001, "produce_subproducts": 1 } Example response { "success": true, "production_id": 39978, "num": 152, "status": 0 } The response returns the ID, number and status code of the new production run. Errors | Error | Reason | |---|---| | No products in input | products is missing or an empty array | | Products is not an array | products is not an array | | Line 0 of products must be an object | A products line is not an object (instead of 0, the line number) | | SKU or id not set for product 0 | The line has neither id nor sku | | Product with id 512 not found | Product not found or deleted (for a SKU: Product with SKU "P-CHAIR-01" not found) | | Amount must be greater than 0 for product with id 512 | Quantity is not a number or not above 0 after rounding | | Storage ID is not set | products_storage_id equal to 0 was passed | | Storage ID not found | Storage location not found or deleted | | Date is not a valid date in format YYYY-MM-DD | Invalid date format |

Editing a Production Run

Updates a production run. Only the fields you pass are changed, the rest stay as they were. v1/production/edit.php Parameters | Field | Type | Required | Description | |---|---|---|---| | production_id | int | Yes | Production run ID | | products | array | No | Products to make: id or sku and amount, as in v1/production/add. Replace the current ones as a whole | | date | string | No | Production date, YYYY-MM-DD | | name | string | No | Name | | notes | string | No | Notes | | produce_subproducts | int | No | 1: produce subassemblies together with the products, 0: deduct them from stock | | materials_storage_id | int | No | Storage location materials are deducted from. 0: choose automatically | | subproducts_storage_id | int | No | Storage location used products are deducted from. 0: choose automatically | | products_storage_id | int | No | Storage location the produced products are added to | The status is not changed by this method; use v1/production/update_status. The number cannot be changed. Example request { "production_id": 39978, "products": [ { "id": 512, "amount": 12 } ], "notes": "Added two tables" } Example response { "success": true } Errors | Error | Reason | |---|---| | No production_id in input | production_id is missing | | Production not found or access denied | Production run not found or deleted | | Products of a production linked to a sale cannot be changed. Edit the sale instead | Changing the products of a made-to-order production | | No products in input | An empty products array was passed | | Products is not an array | products is not an array | | Product with id 512 not found | Product not found or deleted | | Amount must be greater than 0 for product with id 512 | Quantity is not a number or not above 0 after rounding | | Storage ID is not set | products_storage_id equal to 0, or an empty storage location, was passed | | Storage ID not found | Storage location not found or deleted | | Date is not a valid date in format YYYY-MM-DD | Invalid date format | Other products line errors are the same as in v1/production/add.

Deleting a Production Run

Deletes a production run. v1/production/delete.php Parameters | Field | Type | Required | Description | |---|---|---|---| | production_id | int | Yes | Production run ID | Deletion cannot be undone. A made-to-order production (order_id greater than 0) is not deleted by this method: turn off production in the sale or delete the sale, see Creating a Sale. Example request { "production_id": 39978 } Example response { "success": true } Errors | Error | Reason | |---|---| | No production_id in input | production_id is missing | | Production not found or access denied | Production run not found or already deleted | | A production linked to a sale cannot be deleted. Edit the sale instead | The production was created for a sale |

Changing the Production Status

Changes the production status. The status determines whether the materials, used products and resources are deducted and whether the produced products are added to stock. v1/production/update_status.php Parameters | Field | Type | Required | Description | |---|---|---|---| | production_id | int | Yes | Production run ID | | status | int | Yes | Status code from v1/production/get_statuses | Example request { "production_id": 39978, "status": 2 } Example response { "success": true } Errors | Error | Reason | |---|---| | No production_id in input | A required field is missing (instead of production_id, the field's name) | | Invalid status value. Must be one of: 0, 1, 2 | The code is not in the company's status list. The allowed codes are listed in the error text | | Production not found or access denied | Production run not found or deleted |

Retrieving a List of Production Runs

Returns the company's production runs, from newest to oldest: by date, and within one date by number. v1/production/get_list.php Parameters | Field | Type | Required | Description | |---|---|---|---| | date_from | string | No | Production runs from this date inclusive, YYYY-MM-DD | | date_to | string | No | Production runs up to this date inclusive, YYYY-MM-DD | | status | int | No | Status code from v1/production/get_statuses | | limit | int | No | Page size, from 1 to 1000 | | offset | int | No | How many records to skip | Without limit the whole list is returned. See Common Rules for pagination. Response An array production with the production's fields (without products and consumption, which are returned by Retrieving a Production Run): | Field | Type | Description | |---|---|---| | id | int | Production run ID | | num | int | Number. Assigned automatically | | name | string | Name | | date | string | Production date, YYYY-MM-DD | | status | int | Status code from Production Statuses | | order_id | int | ID of the sale the production was created for. 0 if not linked to a sale | | produce_subproducts | int | 1 if subassemblies are produced together with the products | | materials_storage_id | int | Storage location materials are deducted from. 0 if chosen automatically | | materials_storage_name | string | Materials storage location name | | products_storage_id | int | Storage location the produced products are added to | | products_storage_name | string | Produced products storage location name | | subproducts_storage_id | int | Storage location used products are deducted from. 0 if chosen automatically | | subproducts_storage_name | string | Used products storage location name | | cost | float | Cost of the whole production run | | price | float | Value of the produced products at their sale price | | amount | float | Total quantity of products. null if the products have different units | | lines | int | Number of product lines | | notes | string | Notes | The total field holds the total number of production runs matching the filters. Example request { "date_from": "2026-10-01", "status": 0, "limit": 100, "offset": 0 } Example response { "success": true, "production": [ { "id": 39978, "num": 152, "name": "Batch of tables", "date": "2026-10-06", "status": 0, "order_id": 0, "produce_subproducts": 1, "materials_storage_id": 3998, "materials_storage_name": "Main", "products_storage_id": 4001, "products_storage_name": "Finished goods", "subproducts_storage_id": 0, "subproducts_storage_name": null, "cost": 184250, "price": 390000, "amount": 50, "lines": 2, "notes": "" } ], "total": 1 } Errors | Error | Reason | |---|---| | Date is not a valid date in format YYYY-MM-DD | Invalid date_from or date_to | | Invalid status value. Must be a number | status is not a number | | Invalid limit value. Must be between 1 and 1000 | Invalid limit | | Offset requires limit | offset passed without limit |

Retrieving a Production Run

Returns a production run: its fields, the produced products and the consumption of materials, used products and resources. v1/production/get_entry.php Parameters | Field | Type | Required | Description | |---|---|---|---| | production_id | int | Yes | Production run ID | Response An object production with the production's fields: | Field | Type | Description | |---|---|---| | id | int | Production run ID | | num | int | Number. Assigned automatically | | name | string | Name | | date | string | Production date, YYYY-MM-DD | | status | int | Status code from Production Statuses | | order_id | int | ID of the sale the production was created for. 0 if not linked to a sale | | produce_subproducts | int | 1 if subassemblies are produced together with the products | | materials_storage_id | int | Storage location materials are deducted from. 0 if chosen automatically | | materials_storage_name | string | Materials storage location name | | products_storage_id | int | Storage location the produced products are added to | | products_storage_name | string | Produced products storage location name | | subproducts_storage_id | int | Storage location used products are deducted from. 0 if chosen automatically | | subproducts_storage_name | string | Used products storage location name | | cost | float | Cost of the whole production run | | price | float | Value of the produced products at their sale price | | amount | float | Total quantity of products. null if the products have different units | | lines | int | Number of product lines | | notes | string | Notes | and four arrays of lines. products: the produced products. | Field | Type | Description | |---|---|---| | id | int | Product ID | | sku | string | SKU | | name | string | Name | | amount | float | Quantity | | unit | string | Unit of measure | | cost | float | Line cost | | price | float | Line value at the product's sale price | materials: material consumption across the whole production run. If a material is deducted from several storage locations, a separate line comes for each one. | Field | Type | Description | |---|---|---| | id | int | Material ID | | sku | string | SKU | | name | string | Name | | storage_id | int | Storage location the material was deducted from | | amount | float | Quantity | | unit | string | Unit of measure | | cost | float | Cost | subproducts: used products from the components of the ones being made. If subassemblies are produced (produce_subproducts is 1), they do not appear here: instead, the consumption of their components goes into materials and resources. | Field | Type | Description | |---|---|---| | id | int | Product ID | | sku | string | SKU | | name | string | Name | | storage_id | int | Storage location the product was deducted from | | amount | float | Quantity | | unit | string | Unit of measure | | cost | float | Cost | resources: the resources used. | Field | Type | Description | |---|---|---| | id | int | Resource ID | | name | string | Name | | type | string | Calculation type: "rate" fixed rate, "percent" percentage, "amortized" depreciation | | amount | float | Quantity | | unit | string | Unit of measure | | cost | float | Cost | The products array can be sent to v1/production/edit unchanged. Consumption is not changed via the API: it is calculated from the product components. Example request { "production_id": 39978 } Example response { "success": true, "production": { "id": 39978, "num": 152, "name": "Batch of tables", "date": "2026-10-06", "status": 1, "order_id": 0, "produce_subproducts": 0, "materials_storage_id": 3998, "materials_storage_name": "Main", "products_storage_id": 4001, "products_storage_name": "Finished goods", "subproducts_storage_id": 3998, "subproducts_storage_name": "Main", "cost": 61540, "price": 130000, "amount": 10, "lines": 1, "notes": "", "products": [ { "id": 512, "sku": "P-TABLE-01", "name": "Dining table", "amount": 10, "unit": "pcs", "cost": 61540, "price": 130000 } ], "materials": [ { "id": 2051, "sku": "M010", "name": "Oak board", "storage_id": 3998, "amount": 0.4, "unit": "cu m", "cost": 54000 } ], "subproducts": [ { "id": 530, "sku": "P-LEG-01", "name": "Table leg", "storage_id": 3998, "amount": 40, "unit": "pcs", "cost": 6000 } ], "resources": [ { "id": 77, "name": "Carpenter's work", "type": "rate", "amount": 20, "unit": "h", "cost": 1540 } ] } } Errors | Error | Reason | |---|---| | No production_id in input | production_id is missing | | Production not found or access denied | Production run not found or deleted |