Write off
Stock write-offs
INFO
Каждый ответ приходит в общем конверте — code, message, messages, status_code, time — а полезная нагрузка лежит в data. Таблицы ниже описывают содержимое 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.
Нужное разрешение: write_off_create · как работают разрешения
Пример запроса
curl -X POST 'https://api.bito.uz/integration-api/integration/api/v2/write-off/create' \
-H "api-key: $BITO_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"write_date": "2025-05-01T12:00:00Z",
"responsible_id": "string",
"reason_id": "string",
"action": "remove",
"products": [
{
"product_id": "string",
"amount": 0,
"box_count": 0,
"marks": [],
"expiration_date": "2025-05-01T12:00:00Z",
"used_measure": {
"_id": null,
"ratio": null,
"amount": null
}
}
]
}'const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/write-off/create', {
method: 'POST',
headers: { 'api-key': process.env.BITO_API_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({
"write_date": "2025-05-01T12:00:00Z",
"responsible_id": "string",
"reason_id": "string",
"action": "remove",
"products": [
{
"product_id": "string",
"amount": 0,
"box_count": 0,
"marks": [],
"expiration_date": "2025-05-01T12:00:00Z",
"used_measure": {
"_id": null,
"ratio": null,
"amount": null
}
}
]
}),
})
const { code, data } = await res.json()import os
import requests
res = requests.request(
"POST",
"https://api.bito.uz/integration-api/integration/api/v2/write-off/create",
headers={"api-key": os.environ["BITO_API_KEY"]},
json={
"write_date": "2025-05-01T12:00:00Z",
"responsible_id": "string",
"reason_id": "string",
"action": "remove",
"products": [
{
"product_id": "string",
"amount": 0,
"box_count": 0,
"marks": [],
"expiration_date": "2025-05-01T12:00:00Z",
"used_measure": {
"_id": None,
"ratio": None,
"amount": None,
},
},
],
},
)
print(res.json())<?php
$body = <<<'JSON'
{
"write_date": "2025-05-01T12:00:00Z",
"responsible_id": "string",
"reason_id": "string",
"action": "remove",
"products": [
{
"product_id": "string",
"amount": 0,
"box_count": 0,
"marks": [],
"expiration_date": "2025-05-01T12:00:00Z",
"used_measure": {
"_id": null,
"ratio": null,
"amount": null
}
}
]
}
JSON;
$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/write-off/create');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => ['api-key: ' . getenv('BITO_API_KEY'), 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => $body,
CURLOPT_RETURNTRANSFER => true,
]);
$response = json_decode(curl_exec($ch), true);Тело запроса
| Поле | Тип | Обязательно | Описание |
|---|---|---|---|
organization_id | string | Нет | Organization ObjectId. Required when the tenant has multiple organizations. |
code | string | Нет | Optional external reference code for the write-off |
write_date | string (date-time) | Да | Date the write-off occurred |
source_warehouse_id | string | Нет | Source warehouse ObjectId — the warehouse stock is deducted from |
responsible_id | string | Да | Employee ObjectId responsible for this write-off |
reason_id | string | Да | Reason ObjectId explaining why the stock is being written off |
currency_id | string | Нет | Currency ObjectId used for cost values. Defaults to the organization's base currency. |
action | string | Да | Write-off action type. remove — permanent stock removal; defect — defective goods moved to a destination warehouse.. Допустимые значения: remove, defect |
destination_warehouse_id | string | Нет | Destination warehouse ObjectId. Required when action is defect. |
note | string | Нет | Optional free-text note |
products | object[] | Да | List of products to write off. At least one item is required. |
products[].product_id | string | Да | Product ObjectId |
products[].amount | number | Да | Quantity to write off (must be positive) |
products[].box_count | number | Нет | Number of boxes (integer; defaults to 0) |
products[].marks | string[] | Нет | Mark/serial codes for marked goods. Each mark must be unique within the request. |
products[].expiration_date | string (date-time) | Нет | Expiration date — required for perishable products that have has_expiration: true |
products[].used_measure | object | Нет | |
products[].used_measure._id | string | Да | |
products[].used_measure.ratio | number | Да | |
products[].used_measure.amount | number | Да | |
attachments | object[] | Нет | |
attachments[].name | string | Нет | |
attachments[].path | string | Да | |
attachments[].size | number | Нет | |
attachments[].note | string | Нет |
{
"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",
"used_measure": {
"_id": null,
"ratio": null,
"amount": null
}
}
],
"attachments": [
{
"name": "string",
"path": "string",
"size": 0,
"note": "string"
}
]
}Ответ
| Поле | Тип | Описание |
|---|---|---|
_id | string | |
number | string | Auto-generated write-off document number |
code | string | Optional external reference code |
write_date | string (date-time) | |
action | string | Допустимые значения: remove, defect |
state | string | Допустимые значения: done, canceled |
note | string | |
total_cost | number | |
organization | object | |
organization._id | string | |
organization.name | string | |
responsible_employee | object | |
responsible_employee._id | string | |
responsible_employee.full_name | string | |
reason | object | |
reason._id | string | |
reason.name | string | |
currency | object | |
currency._id | string | |
currency.name | string | |
source_warehouse | object | |
source_warehouse._id | string | |
source_warehouse.name | string | |
destination_warehouse | object | Populated only when action is defect |
destination_warehouse._id | string | |
destination_warehouse.name | string | |
products | object[] | |
products[]._id | string | |
products[].product_id | string | |
products[].name | string | |
products[].barcode | string | |
products[].amount | number | |
products[].box_count | number | |
products[].cost | number | |
products[].total_cost | number | |
products[].marks | string[] | |
products[].expiration_date | string (date-time) | |
created_at | string (date-time) | |
updated_at | string (date-time) |
{
"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.
Нужное разрешение: write_off · как работают разрешения
Приложению, которое отменяет документ, стоит запросить и write_off_cancel.
Пример запроса
curl -X PUT 'https://api.bito.uz/integration-api/integration/api/v2/write-off/set-status/6712f0a9c4d1e87b3a0f9911' \
-H "api-key: $BITO_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"status": "canceled"
}'const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/write-off/set-status/6712f0a9c4d1e87b3a0f9911', {
method: 'PUT',
headers: { 'api-key': process.env.BITO_API_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({
"status": "canceled"
}),
})
const { code, data } = await res.json()import os
import requests
res = requests.request(
"PUT",
"https://api.bito.uz/integration-api/integration/api/v2/write-off/set-status/6712f0a9c4d1e87b3a0f9911",
headers={"api-key": os.environ["BITO_API_KEY"]},
json={
"status": "canceled",
},
)
print(res.json())<?php
$body = <<<'JSON'
{
"status": "canceled"
}
JSON;
$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/write-off/set-status/6712f0a9c4d1e87b3a0f9911');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_HTTPHEADER => ['api-key: ' . getenv('BITO_API_KEY'), 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => $body,
CURLOPT_RETURNTRANSFER => true,
]);
$response = json_decode(curl_exec($ch), true);Параметры пути
| Параметр | Тип | Обязательно | Описание |
|---|---|---|---|
id | string | Да | Write-off ObjectId |
Тело запроса
| Поле | Тип | Обязательно | Описание |
|---|---|---|---|
status | string | Да | Target status. Only canceled is accepted — write-offs are created directly in DONE state and the only permitted transition is DONE → canceled.. Допустимые значения: canceled |
reason | string | Нет | Optional free-text reason for the cancellation |
{
"status": "canceled",
"reason": "string"
}Ответ
Структура ответа совпадает с 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).
Нужное разрешение: write_off · как работают разрешения
Пример запроса
curl -X GET 'https://api.bito.uz/integration-api/integration/api/v2/write-off/get-by-id/6712f0a9c4d1e87b3a0f9911' \
-H "api-key: $BITO_API_KEY"const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/write-off/get-by-id/6712f0a9c4d1e87b3a0f9911', {
method: 'GET',
headers: { 'api-key': process.env.BITO_API_KEY },
})
const { code, data } = await res.json()import os
import requests
res = requests.request(
"GET",
"https://api.bito.uz/integration-api/integration/api/v2/write-off/get-by-id/6712f0a9c4d1e87b3a0f9911",
headers={"api-key": os.environ["BITO_API_KEY"]},
)
print(res.json())<?php
$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/write-off/get-by-id/6712f0a9c4d1e87b3a0f9911');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => ['api-key: ' . getenv('BITO_API_KEY')],
CURLOPT_RETURNTRANSFER => true,
]);
$response = json_decode(curl_exec($ch), true);Параметры пути
| Параметр | Тип | Обязательно | Описание |
|---|---|---|---|
id | string | Да | Write-off ObjectId |
Тело запроса
Тело запроса не требуется.
Ответ
Структура ответа совпадает с 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.
Нужное разрешение: write_off · как работают разрешения
Пример запроса
curl -X POST 'https://api.bito.uz/integration-api/integration/api/v2/write-off/get-paging' \
-H "api-key: $BITO_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"page": 1,
"limit": 20
}'const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/write-off/get-paging', {
method: 'POST',
headers: { 'api-key': process.env.BITO_API_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({
"page": 1,
"limit": 20
}),
})
const { code, data } = await res.json()import os
import requests
res = requests.request(
"POST",
"https://api.bito.uz/integration-api/integration/api/v2/write-off/get-paging",
headers={"api-key": os.environ["BITO_API_KEY"]},
json={
"page": 1,
"limit": 20,
},
)
print(res.json())<?php
$body = <<<'JSON'
{
"page": 1,
"limit": 20
}
JSON;
$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/write-off/get-paging');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => ['api-key: ' . getenv('BITO_API_KEY'), 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => $body,
CURLOPT_RETURNTRANSFER => true,
]);
$response = json_decode(curl_exec($ch), true);Тело запроса
| Поле | Тип | Обязательно | Описание |
|---|---|---|---|
page | number | Да | По умолчанию: 1 |
limit | number | Да | По умолчанию: 20 |
organization_id | string | Нет | Filter by organization ObjectId |
warehouse_id | string | Нет | Filter by source warehouse ObjectId |
responsible_id | string | Нет | Filter by responsible employee ObjectId |
action | string | Нет | Filter by write-off action type. Допустимые значения: remove, defect |
search | string | Нет | Free-text search. |
updated_at | string (date-time) | Нет | Only records updated at or after this time. |
date_from | string (date-time) | Нет | Start of the date range. |
date_to | string (date-time) | Нет | End of the date range. |
{
"page": 1,
"limit": 20,
"organization_id": "string",
"warehouse_id": "string",
"responsible_id": "string",
"action": "remove",
"search": "string",
"updated_at": "2025-05-01T12:00:00Z",
"date_from": "2025-05-01T12:00:00Z",
"date_to": "2025-05-01T12:00:00Z"
}Ответ
| Поле | Тип | Описание |
|---|---|---|
total | number | |
list | object[] | |
list[]._id | string | |
list[].number | string | |
list[].code | string | |
list[].write_date | string (date-time) | |
list[].action | string | Допустимые значения: remove, defect |
list[].state | string | Допустимые значения: done, canceled |
list[].total_cost | number | |
list[].organization | object | |
list[].organization._id | string | |
list[].organization.name | string | |
list[].responsible_employee | object | |
list[].responsible_employee._id | string | |
list[].responsible_employee.full_name | string | |
list[].reason | object | |
list[].reason._id | string | |
list[].reason.name | string | |
list[].source_warehouse | object | |
list[].source_warehouse._id | string | |
list[].source_warehouse.name | string | |
list[].created_at | string (date-time) |
{
"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"
}Эта страница сгенерирована из спецификации OpenAPI.