Skip to content

Write off ​

Stock write-offs

INFO

Every response arrives in the shared envelope — code, message, messages, status_code, time — with the payload in data. The tables below describe what is inside data.

POST /write-off/create ​

Create a new write-off (stock loss). The document is immediately persisted in DONE state; stock is decremented and a linked invoice is created inside the same transaction.

Request body

FieldTypeRequiredDescription
organization_idstringNoOrganization ObjectId. Required when the tenant has multiple organizations.
codestringNoOptional external reference code for the write-off
write_datestring (date-time)YesDate the write-off occurred
source_warehouse_idstringNoSource warehouse ObjectId — the warehouse stock is deducted from
responsible_idstringYesEmployee ObjectId responsible for this write-off
reason_idstringYesReason ObjectId explaining why the stock is being written off
currency_idstringNoCurrency ObjectId used for cost values. Defaults to the organization's base currency.
actionstringYesWrite-off action type. remove — permanent stock removal; defect — defective goods moved to a destination warehouse.. One of: remove, defect
destination_warehouse_idstringNoDestination warehouse ObjectId. Required when action is defect.
notestringNoOptional free-text note
productsobject[]YesList of products to write off. At least one item is required.
products[].product_idstringYesProduct ObjectId
products[].amountnumberYesQuantity to write off (must be positive)
products[].box_countnumberNoNumber of boxes (integer; defaults to 0)
products[].marksstring[]NoMark/serial codes for marked goods. Each mark must be unique within the request.
products[].expiration_datestring (date-time)NoExpiration date — required for perishable products that have has_expiration: true
json
{
  "organization_id": "string",
  "code": "string",
  "write_date": "2025-05-01T12:00:00Z",
  "source_warehouse_id": "string",
  "responsible_id": "string",
  "reason_id": "string",
  "currency_id": "string",
  "action": "remove",
  "destination_warehouse_id": "string",
  "note": "string",
  "products": [
    {
      "product_id": "string",
      "amount": 0,
      "box_count": 0,
      "marks": [],
      "expiration_date": "2025-05-01T12:00:00Z"
    }
  ]
}

Response

FieldTypeDescription
_idstring
numberstringAuto-generated write-off document number
codestringOptional external reference code
write_datestring (date-time)
actionstringOne of: remove, defect
statestringOne of: done, canceled
notestring
total_costnumber
organizationobject
organization._idstring
organization.namestring
responsible_employeeobject
responsible_employee._idstring
responsible_employee.full_namestring
reasonobject
reason._idstring
reason.namestring
currencyobject
currency._idstring
currency.namestring
source_warehouseobject
source_warehouse._idstring
source_warehouse.namestring
destination_warehouseobjectPopulated only when action is defect
destination_warehouse._idstring
destination_warehouse.namestring
productsobject[]
products[]._idstring
products[].product_idstring
products[].namestring
products[].barcodestring
products[].amountnumber
products[].box_countnumber
products[].costnumber
products[].total_costnumber
products[].marksstring[]
products[].expiration_datestring (date-time)
created_atstring (date-time)
updated_atstring (date-time)
json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": {
    "_id": "string",
    "number": "string",
    "code": "string",
    "write_date": "2025-05-01T12:00:00Z",
    "action": "remove",
    "state": "done",
    "note": "string",
    "total_cost": 0,
    "organization": {
      "_id": "string",
      "name": "string"
    },
    "responsible_employee": {
      "_id": "string",
      "full_name": "string"
    },
    "reason": {
      "_id": "string",
      "name": "string"
    },
    "currency": {
      "_id": "string",
      "name": "string"
    },
    "source_warehouse": {
      "_id": "string",
      "name": "string"
    },
    "destination_warehouse": {
      "_id": "string",
      "name": "string"
    },
    "products": [
      {
        "_id": "string",
        "product_id": "string",
        "name": "string",
        "barcode": "string",
        "amount": 0,
        "box_count": 0,
        "cost": 0,
        "total_cost": 0,
        "marks": [],
        "expiration_date": "2025-05-01T12:00:00Z"
      }
    ],
    "created_at": "2025-05-01T12:00:00Z",
    "updated_at": "2025-05-01T12:00:00Z"
  },
  "time": "2025-05-01T12:00:00Z"
}

PUT /write-off/set-status/{id} ​

Transition a write-off to CANCELED state. This is the only valid state transition — it reverses stock, cancels the linked invoice, and posts a CREDIT reconciliation act. Only status: "canceled" is accepted; write-offs are created directly in DONE state.

Path parameters

ParameterTypeRequiredDescription
idstringYesWrite-off ObjectId

Request body

FieldTypeRequiredDescription
statusstringYesTarget status. Only canceled is accepted — write-offs are created directly in DONE state and the only permitted transition is DONE → canceled.. One of: canceled
reasonstringNoOptional free-text reason for the cancellation
json
{
  "status": "canceled",
  "reason": "string"
}

Response

Same response shape as POST /write-off/create.

GET /write-off/get-by-id/{id} ​

Fetch a single write-off by ObjectId with full detail (products, organization, responsible employee, reason, currency, warehouses, attachments).

Path parameters

ParameterTypeRequiredDescription
idstringYesWrite-off ObjectId

Request body

No request body.

Response

Same response shape as POST /write-off/create.

POST /write-off/get-paging ​

Paginated list of write-offs. Filterable by organization, warehouse, responsible employee, action type, and date range.

Request body

FieldTypeRequiredDescription
pagenumberYesDefault: 1
limitnumberYesDefault: 20
organization_idstringNoFilter by organization ObjectId
warehouse_idstringNoFilter by source warehouse ObjectId
responsible_idstringNoFilter by responsible employee ObjectId
actionstringNoFilter by write-off action type. One of: remove, defect
json
{
  "page": 1,
  "limit": 20,
  "organization_id": "string",
  "warehouse_id": "string",
  "responsible_id": "string",
  "action": "remove"
}

Response

FieldTypeDescription
totalnumber
listobject[]
list[]._idstring
list[].numberstring
list[].codestring
list[].write_datestring (date-time)
list[].actionstringOne of: remove, defect
list[].statestringOne of: done, canceled
list[].total_costnumber
list[].organizationobject
list[].organization._idstring
list[].organization.namestring
list[].responsible_employeeobject
list[].responsible_employee._idstring
list[].responsible_employee.full_namestring
list[].reasonobject
list[].reason._idstring
list[].reason.namestring
list[].source_warehouseobject
list[].source_warehouse._idstring
list[].source_warehouse.namestring
list[].created_atstring (date-time)
json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": {
    "total": 0,
    "list": [
      {
        "_id": "string",
        "number": "string",
        "code": "string",
        "write_date": "2025-05-01T12:00:00Z",
        "action": "remove",
        "state": "done",
        "total_cost": 0,
        "organization": {
          "_id": null,
          "name": null
        },
        "responsible_employee": {
          "_id": null,
          "full_name": null
        },
        "reason": {
          "_id": null,
          "name": null
        },
        "source_warehouse": {
          "_id": null,
          "name": null
        },
        "created_at": "2025-05-01T12:00:00Z"
      }
    ]
  },
  "time": "2025-05-01T12:00:00Z"
}

This page is generated from the OpenAPI spec.

Bito 2.0 Integration API