Write-offs

7 articles Maxim By Maxim

Write-offs

Write-offs: removing materials and products from stock outside sales and production, for example defects, damage or materials for internal use. Via the API you can create, edit and delete write-offs, change their status, and get a list and a write-off'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/writeoffs/add | Creates a write-off | | v1/writeoffs/edit | Updates a write-off | | v1/writeoffs/delete | Deletes a write-off | | v1/writeoffs/update_status | Changes the write-off status | | v1/writeoffs/get_list | Returns the list of write-offs | | v1/writeoffs/get_entry | Returns a write-off with its lines |

Creating a Write-off

Creates a write-off of materials and products from stock. v1/writeoffs/add.php Parameters | Field | Type | Required | Description | |---|---|---|---| | materials | array | materials or products | Materials to write off: id or sku and amount | | products | array | materials or products | Products to write off: id or sku and amount | | num | string | No | Number. Default the next one in order | | date | string | No | Write-off date, YYYY-MM-DD. Default today | | materials_storage_id | int | No | Storage location materials are written off from. Default the write-off storage location from the company settings | | products_storage_id | int | No | Storage location products are written off from. Default the write-off storage location from the company settings | | notes | string | No | Notes | materials and products line: | Field | Type | Required | Description | |---|---|---|---| | id | int | id or sku | Material or product ID | | sku | string | id or sku | SKU | | amount | float | Yes | Quantity, greater than 0 | A material or product is specified by id or sku. At least one line in one of the arrays is required. A new write-off is created with the status from the Default status for new write-offs setting. Example request { "date": "2026-10-06", "materials": [ { "id": 2051, "amount": 0.15 } ], "products": [ { "sku": "P-TABLE-01", "amount": 1 } ], "materials_storage_id": 3998, "products_storage_id": 4001, "notes": "Defect while cutting" } Example response { "success": true, "writeoff_id": 19291, "num": "48", "status": 1 } The response returns the ID, number and status code of the new write-off. Errors | Error | Reason | |---|---| | No products or materials in input | No line was passed | | Materials is not an array | materials is not an array (same for products) | | Line 0 of materials must be an object | The line is not an object (instead of 0, the line number) | | SKU or id not set for material 0 | The line has neither id nor sku | | Material with id 2051 not found | Material not found or deleted (for a product: Product with SKU "P-TABLE-01" not found) | | Amount must be greater than 0 for material with id 2051 | Quantity is not a number or not above 0 after rounding | | 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 Write-off

Updates a write-off. Only the fields you pass are changed, the rest stay as they were. See Common Rules for partial editing. v1/writeoffs/edit.php Parameters | Field | Type | Required | Description | |---|---|---|---| | writeoff_id | int | Yes | Write-off ID | | materials | array | No | Materials to write off: id or sku and amount | | products | array | No | Products to write off: id or sku and amount | | num | string | No | Number | | date | string | No | Write-off date, YYYY-MM-DD | | materials_storage_id | int | No | Storage location materials are written off from. 0: the default write-off storage location | | products_storage_id | int | No | Storage location products are written off from. 0: the default write-off storage location | | notes | string | No | Notes | If at least one of the materials and products arrays is passed, the lines are replaced as a whole, and the array that is not passed is treated as empty. If neither is passed, the lines are unchanged. The status is not changed by this method; use v1/writeoffs/update_status. Example request { "writeoff_id": 19291, "materials": [ { "id": 2051, "amount": 0.2 } ] } In this example only materials is passed, so the product is removed from the write-off. Example response { "success": true } Errors | Error | Reason | |---|---| | No writeoff_id in input | writeoff_id is missing | | Write-off not found or access denied | Write-off not found or deleted | | No products or materials in input | The line arrays were passed but empty | | Material with id 2051 not found | Material not found or deleted | | Amount must be greater than 0 for material with id 2051 | Quantity is not a number or not above 0 after rounding | | 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 line errors are the same as in v1/writeoffs/add.

Deleting a Write-off

Deletes a write-off. v1/writeoffs/delete.php Parameters | Field | Type | Required | Description | |---|---|---|---| | writeoff_id | int | Yes | Write-off ID | Deletion cannot be undone. The written-off materials and products are returned to stock. Example request { "writeoff_id": 19291 } Example response { "success": true } Errors | Error | Reason | |---|---| | No writeoff_id in input | writeoff_id is missing | | Write-off not found or access denied | Write-off not found or already deleted |

Changing the Write-off Status

Changes the write-off status. The status determines whether the materials and products are deducted from stock. v1/writeoffs/update_status.php Parameters | Field | Type | Required | Description | |---|---|---|---| | writeoff_id | int | Yes | Write-off ID | | status | int | Yes | New status: 0 — Plan, 1 — Written off | Example request { "writeoff_id": 19291, "status": 1 } Example response { "success": true } Errors | Error | Reason | |---|---| | No writeoff_id in input | A required field is missing (instead of writeoff_id, the field's name) | | Invalid status value. Must be one of: 0, 1 | Invalid status code | | Write-off not found or access denied | Write-off not found or deleted |

Retrieving a List of Write-offs

Returns the company's write-offs, from newest to oldest: by date, and within one date by ID. Lines are not included in the list; they are returned by v1/writeoffs/get_entry. v1/writeoffs/get_list.php Parameters | Field | Type | Required | Description | |---|---|---|---| | date_from | string | No | Write-offs from this date inclusive, YYYY-MM-DD | | date_to | string | No | Write-offs up to this date inclusive, YYYY-MM-DD | | status | int | No | Status: 0 Plan, 1 Written off | | 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 writeoffs with the write-off's fields: | Field | Type | Description | |---|---|---| | id | int | Write-off ID | | num | string | Number | | date | string | Write-off date, YYYY-MM-DD | | status | int | Status: 0 Plan, 1 Written off | | materials_storage_id | int | Storage location materials are written off from | | materials_storage_name | string | Materials storage location name | | products_storage_id | int | Storage location products are written off from | | products_storage_name | string | Products storage location name | | cost | float | Cost of what was written off | | amount | float | Total quantity. null if the items have different units | | lines | int | Number of lines | | notes | string | Notes | The total field holds the total number of write-offs matching the filters. Example request { "date_from": "2026-10-01", "date_to": "2026-10-31", "limit": 100, "offset": 0 } Example response { "success": true, "writeoffs": [ { "id": 19291, "num": "48", "date": "2026-10-06", "status": 1, "materials_storage_id": 3998, "materials_storage_name": "Main", "products_storage_id": 4001, "products_storage_name": "Finished goods", "cost": 26350, "amount": null, "lines": 2, "notes": "Defect while cutting" } ], "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 Write-off

Returns a write-off with its lines. v1/writeoffs/get_entry.php Parameters | Field | Type | Required | Description | |---|---|---|---| | writeoff_id | int | Yes | Write-off ID | Response An object writeoff with the write-off's fields: | Field | Type | Description | |---|---|---| | id | int | Write-off ID | | num | string | Number | | date | string | Write-off date, YYYY-MM-DD | | status | int | Status: 0 Plan, 1 Written off | | materials_storage_id | int | Storage location materials are written off from | | materials_storage_name | string | Materials storage location name | | products_storage_id | int | Storage location products are written off from | | products_storage_name | string | Products storage location name | | cost | float | Cost of what was written off | | amount | float | Total quantity. null if the items have different units | | lines | int | Number of lines | | notes | string | Notes | And lines in two arrays: materials and products. If there are no items of one type, the array is empty. | Field | Type | Description | |---|---|---| | id | int | Material or product ID | | sku | string | SKU | | name | string | Name | | amount | float | Quantity | | unit | string | Unit of measure | | cost | float | Line cost | | position | int | Line number in the write-off, from 0. The numbering is shared by materials and products | The lines from the response can be sent to v1/writeoffs/edit unchanged. Example request { "writeoff_id": 19291 } Example response { "success": true, "writeoff": { "id": 19291, "num": "48", "date": "2026-10-06", "status": 1, "materials_storage_id": 3998, "materials_storage_name": "Main", "products_storage_id": 4001, "products_storage_name": "Finished goods", "cost": 26350, "amount": null, "lines": 2, "notes": "Defect while cutting", "materials": [ { "id": 2051, "sku": "M010", "name": "Oak board", "amount": 0.15, "unit": "cu m", "cost": 20250, "position": 0 } ], "products": [ { "id": 512, "sku": "P-TABLE-01", "name": "Dining table", "amount": 1, "unit": "pcs", "cost": 6100, "position": 1 } ] } } Errors | Error | Reason | |---|---| | No writeoff_id in input | writeoff_id is missing | | Write-off not found or access denied | Write-off not found or deleted |