Maxim

Maxim

Last updated on Oct 8, 2026

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