# Organizational transfer

Stock transfers between organizations

::: info
Каждый ответ приходит в общем конверте — `code`, `message`, `messages`, `status_code`, `time` — а полезная нагрузка лежит в `data`. Таблицы ниже описывают содержимое `data`.
:::

## POST /organizational-transfer/create

Create a new organizational transfer (cross-organization stock movement) in DRAFT or NEW state.

**Нужное разрешение:** `organizational_transfer_create` · [как работают разрешения](https://docs.bito.uz/ru/api/permissions.md)

**Пример запроса**

::: code-group

```bash [curl]
curl -X POST 'https://api.bito.uz/integration-api/integration/api/v2/organizational-transfer/create' \
  -H "api-key: $BITO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "source_organization_id": "string",
  "destination_organization_id": "string",
  "state": "draft",
  "date": "2025-05-01T12:00:00Z",
  "shipping_date": "2025-05-01T12:00:00Z",
  "sender_warehouse_id": "string",
  "sender_employee_id": "string",
  "reason_id": "string",
  "requests": [
    {
      "request_id": "string",
      "products": []
    }
  ]
}'
```

```js [JavaScript]
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/organizational-transfer/create', {
  method: 'POST',
  headers: { 'api-key': process.env.BITO_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    "source_organization_id": "string",
    "destination_organization_id": "string",
    "state": "draft",
    "date": "2025-05-01T12:00:00Z",
    "shipping_date": "2025-05-01T12:00:00Z",
    "sender_warehouse_id": "string",
    "sender_employee_id": "string",
    "reason_id": "string",
    "requests": [
      {
        "request_id": "string",
        "products": []
      }
    ]
  }),
})
const { code, data } = await res.json()
```

```python [Python]
import os
import requests

res = requests.request(
    "POST",
    "https://api.bito.uz/integration-api/integration/api/v2/organizational-transfer/create",
    headers={"api-key": os.environ["BITO_API_KEY"]},
    json={
        "source_organization_id": "string",
        "destination_organization_id": "string",
        "state": "draft",
        "date": "2025-05-01T12:00:00Z",
        "shipping_date": "2025-05-01T12:00:00Z",
        "sender_warehouse_id": "string",
        "sender_employee_id": "string",
        "reason_id": "string",
        "requests": [
            {
                "request_id": "string",
                "products": [],
            },
        ],
    },
)
print(res.json())
```

```php [PHP]
<?php
$body = <<<'JSON'
{
  "source_organization_id": "string",
  "destination_organization_id": "string",
  "state": "draft",
  "date": "2025-05-01T12:00:00Z",
  "shipping_date": "2025-05-01T12:00:00Z",
  "sender_warehouse_id": "string",
  "sender_employee_id": "string",
  "reason_id": "string",
  "requests": [
    {
      "request_id": "string",
      "products": []
    }
  ]
}
JSON;

$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/organizational-transfer/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);
```

:::

**Тело запроса**

| Поле | Тип | Обязательно | Описание |
|---|---|---|---|
| `code` | `string` | Нет | Optional custom transfer code / reference number |
| `source_organization_id` | `string` | Да | Sending organization ObjectId |
| `destination_organization_id` | `string` | Да | Receiving organization ObjectId |
| `state` | `string` | Да | Initial state — draft (held) or new (ready to process). Допустимые значения: `draft`, `new` |
| `invoice_created` | `boolean` | Нет | Whether a supplier invoice was created for this transfer. По умолчанию: `false` |
| `with_price` | `boolean` | Нет | Whether product prices are included in the transfer. По умолчанию: `false` |
| `date` | `string (date-time)` | Да | Transfer document date (ISO 8601) |
| `shipping_date` | `string (date-time)` | Да | Expected shipment date (ISO 8601) |
| `sender_warehouse_id` | `string` | Да | Source warehouse ObjectId |
| `sender_employee_id` | `string` | Да | Employee responsible for sending ObjectId |
| `reason_id` | `string` | Да | Transfer reason ObjectId |
| `price_id` | `string` | Нет | Price-list ObjectId (optional) |
| `note` | `string` | Нет | Optional free-text note (max 500 characters) |
| `currency` | `object` | Нет | Currency snapshot at transfer time (optional) |
| `currency._id` | `string` | Да | Currency ObjectId |
| `currency.name` | `string` | Да |  |
| `currency.value` | `number` | Да | Exchange rate value |
| `currency.symbol` | `string` | Нет |  |
| `currency.side` | `string` | Нет | Допустимые значения: `start`, `end` |
| `requests` | `object[]` | Да | One or more transfer request lines (each may reference a transfer-request document) |
| `requests[].request_id` | `string` | Нет | Linked transfer-request ObjectId (optional) |
| `requests[].products` | `object[]` | Да | Products included in this request line |
| `requests[].products[].product_id` | `string` | Да | Product ObjectId |
| `requests[].products[].amount` | `number` | Да | Quantity to transfer (must be positive) |
| `requests[].products[].price` | `number` | Нет | Unit price (optional; required when with_price=true) |
| `requests[].products[].box_count` | `number` | Нет | Number of boxes (integer ≥ 0). По умолчанию: `0` |
| `requests[].products[].box_item` | `number` | Нет | Items per box |
| `requests[].products[].marks` | `string[]` | Нет | Mark/serial codes for marked goods. По умолчанию: `[]` |
| `requests[].products[].expiration_date` | `string (date-time)` | Нет | Expiration date (ISO 8601) for perishable goods |
| `requests[].products[].extra_costs` | `object[]` | Нет | Per-product additional costs. По умолчанию: `[]` |
| `requests[].products[].used_measure` | `object` | Нет |  |
| `additional_costs` | `object[]` | Нет | Transfer-level additional costs. По умолчанию: `[]` |
| `additional_costs[].cost_id` | `string` | Да |  |
| `additional_costs[].amount` | `number` | Да |  |
| `additional_costs[].customer_id` | `string` | Нет |  |
| `additional_costs[].employee_id` | `string` | Нет |  |
| `additional_costs[].supplier_id` | `string` | Нет |  |
| `additional_costs[].person_id` | `string` | Нет |  |
| `attachments` | `object[]` | Нет | Attached files (documents, scans). По умолчанию: `[]` |
| `attachments[].name` | `string` | Нет |  |
| `attachments[].path` | `string` | Да |  |
| `attachments[].size` | `number` | Нет |  |
| `attachments[].note` | `string` | Нет |  |

```json
{
  "code": "string",
  "source_organization_id": "string",
  "destination_organization_id": "string",
  "state": "draft",
  "invoice_created": false,
  "with_price": false,
  "date": "2025-05-01T12:00:00Z",
  "shipping_date": "2025-05-01T12:00:00Z",
  "sender_warehouse_id": "string",
  "sender_employee_id": "string",
  "reason_id": "string",
  "price_id": "string",
  "note": "string",
  "currency": {
    "_id": "string",
    "name": "string",
    "value": 0,
    "symbol": "string",
    "side": "start"
  },
  "requests": [
    {
      "request_id": "string",
      "products": []
    }
  ],
  "additional_costs": [
    {
      "cost_id": "string",
      "amount": 0,
      "customer_id": "64b7f4d9e2b3b6a0b7c5d7ff",
      "employee_id": "64b7f4d9e2b3b6a0b7c5d7ff",
      "supplier_id": "64b7f4d9e2b3b6a0b7c5d7ff",
      "person_id": "64b7f4d9e2b3b6a0b7c5d7ff"
    }
  ],
  "attachments": [
    {
      "name": "string",
      "path": "string",
      "size": 0,
      "note": "string"
    }
  ]
}
```

**Ответ**

```json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": "string",
  "time": "2025-05-01T12:00:00Z"
}
```

## GET /organizational-transfer/get-by-id/{id}

Fetch a single organizational transfer by ObjectId (aggregated detail view with products and requests).

**Нужное разрешение:** `organizational_transfer` · [как работают разрешения](https://docs.bito.uz/ru/api/permissions.md)

**Пример запроса**

::: code-group

```bash [curl]
curl -X GET 'https://api.bito.uz/integration-api/integration/api/v2/organizational-transfer/get-by-id/6712f0a9c4d1e87b3a0f9911' \
  -H "api-key: $BITO_API_KEY"
```

```js [JavaScript]
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/organizational-transfer/get-by-id/6712f0a9c4d1e87b3a0f9911', {
  method: 'GET',
  headers: { 'api-key': process.env.BITO_API_KEY },
})
const { code, data } = await res.json()
```

```python [Python]
import os
import requests

res = requests.request(
    "GET",
    "https://api.bito.uz/integration-api/integration/api/v2/organizational-transfer/get-by-id/6712f0a9c4d1e87b3a0f9911",
    headers={"api-key": os.environ["BITO_API_KEY"]},
)
print(res.json())
```

```php [PHP]
<?php
$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/organizational-transfer/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` | Да | Organizational transfer ObjectId |

**Тело запроса**

Тело запроса не требуется.

**Ответ**

| Поле | Тип | Описание |
|---|---|---|
| `_id` | `string` | Transfer ObjectId |
| `number` | `string` | Auto-generated transfer document number |
| `code` | `string` | Custom reference code |
| `state` | `string` | Допустимые значения: `draft`, `new`, `accepted`, `in_progress`, `done`, `canceled` |
| `type` | `string` | Transfer type (o2o for organizational transfers) |
| `source_organization_id` | `string` |  |
| `destination_organization_id` | `string` |  |
| `sender_warehouse_id` | `string` |  |
| `receiver_warehouse_id` | `string` | Set after receive; null until received |
| `sender_employee_id` | `string` |  |
| `reason_id` | `string` |  |
| `price_id` | `string` |  |
| `date` | `string (date-time)` |  |
| `shipping_date` | `string (date-time)` |  |
| `invoice_created` | `boolean` |  |
| `with_price` | `boolean` |  |
| `note` | `string` |  |
| `total_amount` | `number` | Total quantity across all products |
| `total_cost` | `number` |  |
| `total_price` | `number` |  |
| `total_extra_cost` | `number` |  |
| `requests` | `object[]` | Transfer request lines with their product details |
| `requests[].request_id` | `string` |  |
| `requests[].products` | `object[]` |  |
| `requests[].products[].product_id` | `string` |  |
| `requests[].products[].amount` | `number` |  |
| `requests[].products[].price` | `number` |  |
| `requests[].products[].box_count` | `number` |  |
| `requests[].products[].marks` | `string[]` |  |
| `requests[].products[].expiration_date` | `string (date-time)` |  |
| `requests[].products[].sender_stock_before` | `number` | Sender warehouse stock before outflow |
| `requests[].products[].sender_stock_after` | `number` | Derived: sender_stock_before − amount |
| `requests[].products[].receiver_stock_before` | `number` | Receiver warehouse stock before inflow (set after receive) |
| `requests[].products[].receiver_stock_after` | `number` | Derived: receiver_stock_before + amount (set after receive) |
| `additional_costs` | `object[]` |  |
| `attachments` | `object[]` |  |
| `created_at` | `string (date-time)` |  |
| `updated_at` | `string (date-time)` |  |

```json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": {
    "_id": "string",
    "number": "string",
    "code": "string",
    "state": "draft",
    "type": "string",
    "source_organization_id": "string",
    "destination_organization_id": "string",
    "sender_warehouse_id": "string",
    "receiver_warehouse_id": "string",
    "sender_employee_id": "string",
    "reason_id": "string",
    "price_id": "string",
    "date": "2025-05-01T12:00:00Z",
    "shipping_date": "2025-05-01T12:00:00Z",
    "invoice_created": false,
    "with_price": false,
    "note": "string",
    "total_amount": 0,
    "total_cost": 0,
    "total_price": 0,
    "total_extra_cost": 0,
    "requests": [
      {
        "request_id": "string",
        "products": []
      }
    ],
    "additional_costs": [
      {}
    ],
    "attachments": [
      {}
    ],
    "created_at": "2025-05-01T12:00:00Z",
    "updated_at": "2025-05-01T12:00:00Z"
  },
  "time": "2025-05-01T12:00:00Z"
}
```

## POST /organizational-transfer/get-paging

Paginated list of organizational transfers, filterable by organization, warehouse, state, and reason.

**Нужное разрешение:** `organizational_transfer` · [как работают разрешения](https://docs.bito.uz/ru/api/permissions.md)

**Пример запроса**

::: code-group

```bash [curl]
curl -X POST 'https://api.bito.uz/integration-api/integration/api/v2/organizational-transfer/get-paging' \
  -H "api-key: $BITO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "page": 1,
  "limit": 20
}'
```

```js [JavaScript]
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/organizational-transfer/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()
```

```python [Python]
import os
import requests

res = requests.request(
    "POST",
    "https://api.bito.uz/integration-api/integration/api/v2/organizational-transfer/get-paging",
    headers={"api-key": os.environ["BITO_API_KEY"]},
    json={
        "page": 1,
        "limit": 20,
    },
)
print(res.json())
```

```php [PHP]
<?php
$body = <<<'JSON'
{
  "page": 1,
  "limit": 20
}
JSON;

$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/organizational-transfer/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` |
| `source_organization_id` | `string` | Нет | Filter by sending organization ObjectId |
| `destination_organization_id` | `string` | Нет | Filter by receiving organization ObjectId |
| `sender_warehouse_id` | `string` | Нет | Filter by sender warehouse ObjectId |
| `receiver_warehouse_id` | `string` | Нет | Filter by receiver warehouse ObjectId |
| `states` | `string[]` | Нет | Filter by one or more transfer states |
| `reason_id` | `string` | Нет | Filter by transfer reason ObjectId |
| `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. |
| `organization_id` | `string` | Нет | Organization ObjectId. |

```json
{
  "page": 1,
  "limit": 20,
  "source_organization_id": "string",
  "destination_organization_id": "string",
  "sender_warehouse_id": "string",
  "receiver_warehouse_id": "string",
  "states": [
    "draft"
  ],
  "reason_id": "string",
  "search": "string",
  "updated_at": "2025-05-01T12:00:00Z",
  "date_from": "2025-05-01T12:00:00Z",
  "date_to": "2025-05-01T12:00:00Z",
  "organization_id": "64b7f4d9e2b3b6a0b7c5d7ff"
}
```

**Ответ**

| Поле | Тип | Описание |
|---|---|---|
| `total` | `number` |  |
| `list` | `any[]` |  |

```json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": {
    "total": 0,
    "list": []
  },
  "time": "2025-05-01T12:00:00Z"
}
```

## PUT /organizational-transfer/update/{id}

Update an existing organizational transfer. Only allowed in DRAFT or NEW state.

**Нужное разрешение:** `organizational_transfer_update` · [как работают разрешения](https://docs.bito.uz/ru/api/permissions.md)

**Пример запроса**

::: code-group

```bash [curl]
curl -X PUT 'https://api.bito.uz/integration-api/integration/api/v2/organizational-transfer/update/6712f0a9c4d1e87b3a0f9911' \
  -H "api-key: $BITO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "source_organization_id": "string",
  "destination_organization_id": "string",
  "date": "2025-05-01T12:00:00Z",
  "shipping_date": "2025-05-01T12:00:00Z",
  "sender_warehouse_id": "string",
  "sender_employee_id": "string",
  "reason_id": "string",
  "requests": [
    {
      "request_id": "string",
      "products": []
    }
  ]
}'
```

```js [JavaScript]
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/organizational-transfer/update/6712f0a9c4d1e87b3a0f9911', {
  method: 'PUT',
  headers: { 'api-key': process.env.BITO_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    "source_organization_id": "string",
    "destination_organization_id": "string",
    "date": "2025-05-01T12:00:00Z",
    "shipping_date": "2025-05-01T12:00:00Z",
    "sender_warehouse_id": "string",
    "sender_employee_id": "string",
    "reason_id": "string",
    "requests": [
      {
        "request_id": "string",
        "products": []
      }
    ]
  }),
})
const { code, data } = await res.json()
```

```python [Python]
import os
import requests

res = requests.request(
    "PUT",
    "https://api.bito.uz/integration-api/integration/api/v2/organizational-transfer/update/6712f0a9c4d1e87b3a0f9911",
    headers={"api-key": os.environ["BITO_API_KEY"]},
    json={
        "source_organization_id": "string",
        "destination_organization_id": "string",
        "date": "2025-05-01T12:00:00Z",
        "shipping_date": "2025-05-01T12:00:00Z",
        "sender_warehouse_id": "string",
        "sender_employee_id": "string",
        "reason_id": "string",
        "requests": [
            {
                "request_id": "string",
                "products": [],
            },
        ],
    },
)
print(res.json())
```

```php [PHP]
<?php
$body = <<<'JSON'
{
  "source_organization_id": "string",
  "destination_organization_id": "string",
  "date": "2025-05-01T12:00:00Z",
  "shipping_date": "2025-05-01T12:00:00Z",
  "sender_warehouse_id": "string",
  "sender_employee_id": "string",
  "reason_id": "string",
  "requests": [
    {
      "request_id": "string",
      "products": []
    }
  ]
}
JSON;

$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/organizational-transfer/update/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` | Да | Organizational transfer ObjectId |

**Тело запроса**

| Поле | Тип | Обязательно | Описание |
|---|---|---|---|
| `code` | `string` | Нет | Optional custom transfer code / reference number |
| `source_organization_id` | `string` | Да | Sending organization ObjectId |
| `destination_organization_id` | `string` | Да | Receiving organization ObjectId |
| `invoice_created` | `boolean` | Нет | Whether a supplier invoice was created for this transfer. По умолчанию: `false` |
| `with_price` | `boolean` | Нет | Whether product prices are included in the transfer. По умолчанию: `false` |
| `date` | `string (date-time)` | Да | Transfer document date (ISO 8601) |
| `shipping_date` | `string (date-time)` | Да | Expected shipment date (ISO 8601) |
| `sender_warehouse_id` | `string` | Да | Source warehouse ObjectId |
| `sender_employee_id` | `string` | Да | Employee responsible for sending ObjectId |
| `reason_id` | `string` | Да | Transfer reason ObjectId |
| `price_id` | `string` | Нет | Price-list ObjectId (optional) |
| `note` | `string` | Нет | Optional free-text note (max 500 characters) |
| `currency` | `object` | Нет | Currency snapshot at transfer time (optional) |
| `currency._id` | `string` | Нет | Currency ObjectId |
| `currency.name` | `string` | Да |  |
| `currency.value` | `number` | Да | Exchange rate value |
| `currency.symbol` | `string` | Нет |  |
| `requests` | `object[]` | Да | One or more transfer request lines (each may reference a transfer-request document) |
| `requests[].request_id` | `string` | Нет | Linked transfer-request ObjectId (optional) |
| `requests[].products` | `object[]` | Да | Products included in this request line |
| `requests[].products[].product_id` | `string` | Да | Product ObjectId |
| `requests[].products[].amount` | `number` | Да | Quantity to transfer (must be positive) |
| `requests[].products[].box_count` | `number` | Нет | Number of boxes (integer ≥ 0). По умолчанию: `0` |
| `requests[].products[].box_item` | `number` | Нет | Items per box |
| `requests[].products[].marks` | `string[]` | Нет | Mark/serial codes for marked goods. По умолчанию: `[]` |
| `requests[].products[].expiration_date` | `string (date-time)` | Нет | Expiration date (ISO 8601) for perishable goods |
| `requests[].products[].extra_costs` | `object[]` | Нет | Per-product additional costs. По умолчанию: `[]` |
| `requests[].products[].used_measure` | `object` | Нет |  |
| `additional_costs` | `object[]` | Нет | Transfer-level additional costs. По умолчанию: `[]` |
| `additional_costs[].cost_id` | `string` | Да |  |
| `additional_costs[].amount` | `number` | Да |  |
| `additional_costs[].customer_id` | `string` | Нет |  |
| `additional_costs[].employee_id` | `string` | Нет |  |
| `additional_costs[].supplier_id` | `string` | Нет |  |
| `additional_costs[].person_id` | `string` | Нет |  |
| `attachments` | `object[]` | Нет | Attached files (documents, scans). По умолчанию: `[]` |
| `attachments[].name` | `string` | Нет |  |
| `attachments[].path` | `string` | Да |  |
| `attachments[].size` | `number` | Нет |  |
| `attachments[].note` | `string` | Нет |  |

```json
{
  "code": "string",
  "source_organization_id": "string",
  "destination_organization_id": "string",
  "invoice_created": false,
  "with_price": false,
  "date": "2025-05-01T12:00:00Z",
  "shipping_date": "2025-05-01T12:00:00Z",
  "sender_warehouse_id": "string",
  "sender_employee_id": "string",
  "reason_id": "string",
  "price_id": "string",
  "note": "string",
  "currency": {
    "_id": "string",
    "name": "string",
    "value": 0,
    "symbol": "string"
  },
  "requests": [
    {
      "request_id": "string",
      "products": []
    }
  ],
  "additional_costs": [
    {
      "cost_id": "string",
      "amount": 0,
      "customer_id": "64b7f4d9e2b3b6a0b7c5d7ff",
      "employee_id": "64b7f4d9e2b3b6a0b7c5d7ff",
      "supplier_id": "64b7f4d9e2b3b6a0b7c5d7ff",
      "person_id": "64b7f4d9e2b3b6a0b7c5d7ff"
    }
  ],
  "attachments": [
    {
      "name": "string",
      "path": "string",
      "size": 0,
      "note": "string"
    }
  ]
}
```

**Ответ**

Структура ответа совпадает с [POST /organizational-transfer/create](#post-organizational-transfer-create).

## PUT /organizational-transfer/set-status/{id}

Transition the transfer through the state machine. Valid transitions: NEW→DRAFT|CANCELED|ACCEPTED; DRAFT→NEW; ACCEPTED→IN_PROGRESS|CANCELED; IN_PROGRESS→CANCELED; DONE→CANCELED. Use `receive` for the ACCEPTED/IN_PROGRESS→DONE transition.

**Нужное разрешение:** `organizational_transfer_update` · [как работают разрешения](https://docs.bito.uz/ru/api/permissions.md)

Приложению, которое отменяет документ, стоит запросить и `organizational_transfer_cancel`.

**Пример запроса**

::: code-group

```bash [curl]
curl -X PUT 'https://api.bito.uz/integration-api/integration/api/v2/organizational-transfer/set-status/6712f0a9c4d1e87b3a0f9911' \
  -H "api-key: $BITO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "state": "draft"
}'
```

```js [JavaScript]
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/organizational-transfer/set-status/6712f0a9c4d1e87b3a0f9911', {
  method: 'PUT',
  headers: { 'api-key': process.env.BITO_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    "state": "draft"
  }),
})
const { code, data } = await res.json()
```

```python [Python]
import os
import requests

res = requests.request(
    "PUT",
    "https://api.bito.uz/integration-api/integration/api/v2/organizational-transfer/set-status/6712f0a9c4d1e87b3a0f9911",
    headers={"api-key": os.environ["BITO_API_KEY"]},
    json={
        "state": "draft",
    },
)
print(res.json())
```

```php [PHP]
<?php
$body = <<<'JSON'
{
  "state": "draft"
}
JSON;

$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/organizational-transfer/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` | Да | Organizational transfer ObjectId |

**Тело запроса**

| Поле | Тип | Обязательно | Описание |
|---|---|---|---|
| `state` | `string` | Да | Target state. Valid transitions: NEW→DRAFT\|CANCELED\|ACCEPTED; DRAFT→NEW; ACCEPTED→IN_PROGRESS\|CANCELED; IN_PROGRESS→CANCELED; DONE→CANCELED. Use the `receive` endpoint to transition to DONE.. Допустимые значения: `draft`, `new`, `accepted`, `in_progress`, `canceled` |

```json
{
  "state": "draft"
}
```

**Ответ**

Структура ответа совпадает с [POST /organizational-transfer/create](#post-organizational-transfer-create).

## PUT /organizational-transfer/receive/{id}

Receive an accepted organizational transfer: transitions ACCEPTED or IN_PROGRESS → DONE and applies stock movement into the receiver warehouse.

**Нужное разрешение:** `organizational_transfer_update` · [как работают разрешения](https://docs.bito.uz/ru/api/permissions.md)

**Пример запроса**

::: code-group

```bash [curl]
curl -X PUT 'https://api.bito.uz/integration-api/integration/api/v2/organizational-transfer/receive/6712f0a9c4d1e87b3a0f9911' \
  -H "api-key: $BITO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "receiver_warehouse_id": "string"
}'
```

```js [JavaScript]
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/organizational-transfer/receive/6712f0a9c4d1e87b3a0f9911', {
  method: 'PUT',
  headers: { 'api-key': process.env.BITO_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    "receiver_warehouse_id": "string"
  }),
})
const { code, data } = await res.json()
```

```python [Python]
import os
import requests

res = requests.request(
    "PUT",
    "https://api.bito.uz/integration-api/integration/api/v2/organizational-transfer/receive/6712f0a9c4d1e87b3a0f9911",
    headers={"api-key": os.environ["BITO_API_KEY"]},
    json={
        "receiver_warehouse_id": "string",
    },
)
print(res.json())
```

```php [PHP]
<?php
$body = <<<'JSON'
{
  "receiver_warehouse_id": "string"
}
JSON;

$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/organizational-transfer/receive/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` | Да | Organizational transfer ObjectId |

**Тело запроса**

| Поле | Тип | Обязательно | Описание |
|---|---|---|---|
| `receiver_warehouse_id` | `string` | Да | Destination warehouse ObjectId where stock will be received |

```json
{
  "receiver_warehouse_id": "string"
}
```

**Ответ**

Структура ответа совпадает с [POST /organizational-transfer/create](#post-organizational-transfer-create).

---

*Эта страница сгенерирована из спецификации OpenAPI.*
