Skip to content
View as Markdown

Recipe: write-off ​

Your system knows that goods were damaged or lost — it has to show up in Bito under Warehouse › Actions › Write-offs and leave stock. That is a write-off document. It is created directly as done: there is no draft.

Permissions needed: write_off_create, write_off, warehouse, employee.

1. Find the organization and warehouse ​

http
GET /organization/get-all
json
POST /warehouse/get-all

{ "organization_id": "6712f0a9c4d1e87b3a0f9911", "status": "active" }

Keep the organization's _id and currency_id and the warehouse's _id.

2. Pick a reason ​

json
POST /reason/get-paging

{ "page": 1, "limit": 200, "type": "write_off" }

Reasons and permissions

reason/* methods have no permission key. If your app declares even one permission in required_permissions, they are closed to it (Creating an integration). In such an app, keep the reason id in your settings, or take it from existing documents: write-off/get-paging rows carry reason._id.

3. Pick the responsible employee ​

json
POST /employee/get-paging

{ "page": 1, "limit": 200 }

4. Create the document ​

json
POST /write-off/create

{
    "organization_id": "6712f0a9c4d1e87b3a0f9911",
    "source_warehouse_id": "6712f0a9c4d1e87b3a0f9955",
    "currency_id": "6712f0a9c4d1e87b3a0f9988",
    "write_date": "2026-11-05T10:00:00Z",
    "responsible_id": "6712f0a9c4d1e87b3a0f99aa",
    "reason_id": "6712f0a9c4d1e87b3a0f99bb",
    "action": "remove",
    "products": [
        { "product_id": "6712f0a9c4d1e87b3a0f9933", "amount": 2 }
    ],
    "code": "WMS-10482",
    "note": "Damaged packaging"
}
FieldRequiredDescription
organization_idYesOrganization
source_warehouse_idYesWarehouse the goods leave
currency_idYesThe document's cost is calculated in it — usually the organization's currency
write_dateYesISO 8601
responsible_idYesResponsible employee
reason_idYesReason
actionYesremove — write off for good, defect — move to defective goods
destination_warehouse_idFor defectWarehouse that accounts for the defective goods
products[].product_idYesProduct
products[].amountYesA positive number in the product's unit of measure
products[].marksFor marked goodsCodes; their count must equal amount
products[].expiration_dateNoTake only from batches with this expiry date
codeNoThe document number in your system
noteNoComment

The reference lists organization_id, source_warehouse_id and currency_id as optional, but the call fails without them. Send an existing warehouse of the same organization as destination_warehouse_id.

The response carries _id, number, state: "done", total_cost and the products lines.

Retries

create is not idempotent: a repeated call writes the goods off a second time. If no response came back, first read write-off/get-paging with warehouse_id, date_from, date_to and look for your code in the rows (search matches the Bito number only).

5. What changes ​

  • amount goes down in the source warehouse. Reserved goods are not written off.
  • With action: "defect", the same quantity is added to the in_trash counter of destination_warehouse_id.
  • Cost is calculated from the batches (total_cost), and Bito issues an expense-type invoice for it — it shows up in invoice/get-paging rows, where write_off_id is the write-off's id. No money leaves a cashbox.
  • There is no webhook event for write-offs.

What the counters mean: stock and prices.

6. Cancel ​

json
PUT /write-off/set-status/6712f0a9c4d1e87b3a0f99cc

{ "status": "canceled" }

The only transition is done → canceled. The goods return to the source warehouse (for defect, in_trash also goes down) and the invoice is cancelled. There is no method to edit or delete the document: if it is wrong, cancel it and create a new one.

Errors ​

codeCause
10001Validation: a required field is missing or a value is wrong — read message
10003 (HTTP 403)A permission was not approved; data names it
26000, 26022Product not found, or not available in this organization
26008, 26014A compound product or a service cannot be written off
124000, 124009No stock, or not enough of it
124003Wrong marking codes
125000Reason not found
132000Document not found
132002Cannot cancel: already cancelled, or the goods were used afterwards

On an error no document is created at all — lines are never partly written off.

Methods ​

StepMethod
OrganizationGET /organization/get-all
WarehousePOST /warehouse/get-all
ReasonPOST /reason/get-paging
EmployeePOST /employee/get-paging
CreatePOST /write-off/create
CheckPOST /write-off/get-paging, GET /write-off/get-by-id/{id}
CancelPUT /write-off/set-status/{id}

Bito 2.0 Integration API