# Purchase return

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

## POST /purchase-return/get-paging

Paginated list of purchase returns with optional filters.

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

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

::: code-group

```bash [curl]
curl -X POST 'https://api.bito.uz/integration-api/integration/api/v2/purchase-return/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/purchase-return/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/purchase-return/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/purchase-return/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` |
| `states` | `string[]` | Нет |  |
| `organization_id` | `string` | Нет |  |
| `supplier_id` | `string` | Нет |  |
| `responsible_id` | `string` | Нет |  |
| `date_from` | `string (date-time)` | Нет |  |
| `date_to` | `string (date-time)` | Нет |  |
| `search` | `string` | Нет | Free-text search. |
| `updated_at` | `string (date-time)` | Нет | Only records updated at or after this time. |
| `sort_by` | `string` | Нет | Field name to sort by. |
| `asc` | `integer` | Нет | Sort direction: `1` ascending, `-1` descending.. Допустимые значения: `-1`, `1` |

```json
{
  "page": 1,
  "limit": 20,
  "states": [
    "new"
  ],
  "organization_id": "string",
  "supplier_id": "string",
  "responsible_id": "string",
  "date_from": "2025-05-01T12:00:00Z",
  "date_to": "2025-05-01T12:00:00Z",
  "search": "string",
  "updated_at": "2025-05-01T12:00:00Z",
  "sort_by": "string",
  "asc": -1
}
```

**Ответ**

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

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

## GET /purchase-return/get-by-id/{id}

Get a purchase return by its _id (detailed view).

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

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

::: code-group

```bash [curl]
curl -X GET 'https://api.bito.uz/integration-api/integration/api/v2/purchase-return/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/purchase-return/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/purchase-return/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/purchase-return/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` | Да |  |

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

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

**Ответ**

| Поле | Тип | Описание |
|---|---|---|
| `_id` | `string` |  |
| `number` | `string` |  |
| `organization_id` | `string` |  |
| `supplier_id` | `string` |  |
| `purchase_id` | `string` |  |
| `responsible_id` | `string` |  |
| `warehouse_id` | `string` |  |
| `currency_id` | `string` |  |
| `date` | `string (date-time)` |  |
| `state` | `string` | Допустимые значения: `new`, `done`, `canceled` |
| `total` | `number` |  |
| `note` | `string` |  |
| `items` | `object[]` |  |
| `items[]._id` | `string` |  |
| `items[].product_id` | `string` |  |
| `items[].amount` | `number` |  |
| `items[].cost` | `number` |  |
| `created_at` | `string (date-time)` |  |
| `updated_at` | `string (date-time)` |  |

```json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": {
    "_id": "string",
    "number": "string",
    "organization_id": "string",
    "supplier_id": "string",
    "purchase_id": "string",
    "responsible_id": "string",
    "warehouse_id": "string",
    "currency_id": "string",
    "date": "2025-05-01T12:00:00Z",
    "state": "new",
    "total": 0,
    "note": "string",
    "items": [
      {
        "_id": "string",
        "product_id": "string",
        "amount": 0,
        "cost": 0
      }
    ],
    "created_at": "2025-05-01T12:00:00Z",
    "updated_at": "2025-05-01T12:00:00Z"
  },
  "time": "2025-05-01T12:00:00Z"
}
```

---

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