# Units of measure

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

## POST /units-of-measure/create

This method allows adding units-of-measure into the account.

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

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

::: code-group

```bash [curl]
curl -X POST 'https://api.bito.uz/integration-api/integration/api/v2/units-of-measure/create' \
  -H "api-key: $BITO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "decimal_count": 0,
  "name": "string"
}'
```

```js [JavaScript]
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/units-of-measure/create', {
  method: 'POST',
  headers: { 'api-key': process.env.BITO_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    "decimal_count": 0,
    "name": "string"
  }),
})
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/units-of-measure/create",
    headers={"api-key": os.environ["BITO_API_KEY"]},
    json={
        "decimal_count": 0,
        "name": "string",
    },
)
print(res.json())
```

```php [PHP]
<?php
$body = <<<'JSON'
{
  "decimal_count": 0,
  "name": "string"
}
JSON;

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

:::

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

| Поле | Тип | Обязательно | Описание |
|---|---|---|---|
| `name` | `string` | Да |  |
| `short_name` | `string` | Нет |  |
| `code` | `string` | Нет |  |
| `status` | `string` | Нет | Допустимые значения: `active`, `inactive`. По умолчанию: `"active"` |
| `decimal_count` | `integer` | Да | По умолчанию: `0` |
| `type` | `string` | Нет | Допустимые значения: `inventory`, `service` |

```json
{
  "name": "string",
  "short_name": "string",
  "code": "string",
  "status": "active",
  "decimal_count": 0,
  "type": "inventory"
}
```

**Ответ**

| Поле | Тип | Описание |
|---|---|---|
| `_id` | `string` |  |
| `name` | `string` |  |
| `code` | `string` |  |
| `short_name` | `string` |  |
| `status` | `string` | Допустимые значения: `active`, `inactive` |
| `system_code` | `string` |  |
| `decimal_count` | `integer` | По умолчанию: `0` |
| `type` | `string` | Допустимые значения: `inventory`, `service` |
| `is_default` | `boolean` |  |
| `created_at` | `string (date-time)` |  |
| `updated_at` | `string (date-time)` |  |

```json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": {
    "_id": "string",
    "name": "string",
    "code": "string",
    "short_name": "string",
    "status": "active",
    "system_code": "string",
    "decimal_count": 0,
    "type": "inventory",
    "is_default": false,
    "created_at": "2025-05-01T12:00:00Z",
    "updated_at": "2025-05-01T12:00:00Z"
  },
  "time": "2025-05-01T12:00:00Z"
}
```

## PUT /units-of-measure/update

This method allows updating units-of-measure in the account.

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

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

::: code-group

```bash [curl]
curl -X PUT 'https://api.bito.uz/integration-api/integration/api/v2/units-of-measure/update' \
  -H "api-key: $BITO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "decimal_count": 0,
  "name": "string",
  "_id": "67b486d242ed76693cd2cc59"
}'
```

```js [JavaScript]
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/units-of-measure/update', {
  method: 'PUT',
  headers: { 'api-key': process.env.BITO_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    "decimal_count": 0,
    "name": "string",
    "_id": "67b486d242ed76693cd2cc59"
  }),
})
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/units-of-measure/update",
    headers={"api-key": os.environ["BITO_API_KEY"]},
    json={
        "decimal_count": 0,
        "name": "string",
        "_id": "67b486d242ed76693cd2cc59",
    },
)
print(res.json())
```

```php [PHP]
<?php
$body = <<<'JSON'
{
  "decimal_count": 0,
  "name": "string",
  "_id": "67b486d242ed76693cd2cc59"
}
JSON;

$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/units-of-measure/update');
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` | Да |  |
| `name` | `string` | Да |  |
| `short_name` | `string` | Нет |  |
| `code` | `string` | Нет |  |
| `status` | `string` | Нет | Допустимые значения: `active`, `inactive`. По умолчанию: `"active"` |
| `decimal_count` | `integer` | Да | По умолчанию: `0` |
| `type` | `string` | Нет | Допустимые значения: `inventory`, `service` |

```json
{
  "_id": "67b486d242ed76693cd2cc59",
  "name": "string",
  "short_name": "string",
  "code": "string",
  "status": "active",
  "decimal_count": 0,
  "type": "inventory"
}
```

**Ответ**

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

## DELETE /units-of-measure/delete/{id}

Delete a units-of-measure

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

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

::: code-group

```bash [curl]
curl -X DELETE 'https://api.bito.uz/integration-api/integration/api/v2/units-of-measure/delete/6712f0a9c4d1e87b3a0f9911' \
  -H "api-key: $BITO_API_KEY"
```

```js [JavaScript]
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/units-of-measure/delete/6712f0a9c4d1e87b3a0f9911', {
  method: 'DELETE',
  headers: { 'api-key': process.env.BITO_API_KEY },
})
const { code, data } = await res.json()
```

```python [Python]
import os
import requests

res = requests.request(
    "DELETE",
    "https://api.bito.uz/integration-api/integration/api/v2/units-of-measure/delete/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/units-of-measure/delete/6712f0a9c4d1e87b3a0f9911');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'DELETE',
    CURLOPT_HTTPHEADER => ['api-key: ' . getenv('BITO_API_KEY')],
    CURLOPT_RETURNTRANSFER => true,
]);
$response = json_decode(curl_exec($ch), true);
```

:::

**Параметры пути**

| Параметр | Тип | Обязательно | Описание |
|---|---|---|---|
| `id` | `string` | Да |  |

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

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

**Ответ**

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

## GET /units-of-measure/get-all

Get all units-of-measures

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

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

::: code-group

```bash [curl]
curl -X GET 'https://api.bito.uz/integration-api/integration/api/v2/units-of-measure/get-all' \
  -H "api-key: $BITO_API_KEY"
```

```js [JavaScript]
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/units-of-measure/get-all', {
  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/units-of-measure/get-all",
    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/units-of-measure/get-all');
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);
```

:::

**Параметры запроса**

| Параметр | Тип | Обязательно | Описание |
|---|---|---|---|
| `search` | `string` | Нет | Search units-of-measure |
| `type` | `string` | Нет | Допустимые значения: `inventory`, `service` |
| `status` | `string` | Нет | Допустимые значения: `active`, `inactive` |

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

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

**Ответ**

```json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": [
    {
      "_id": "string",
      "name": "string",
      "code": "string",
      "short_name": "string",
      "status": "active",
      "system_code": "string",
      "decimal_count": 0,
      "type": "inventory",
      "is_default": false,
      "created_at": "2025-05-01T12:00:00Z",
      "updated_at": "2025-05-01T12:00:00Z"
    }
  ],
  "time": "2025-05-01T12:00:00Z"
}
```

## GET /units-of-measure/get-by-id/{id}

Get units-of-measure using its _id

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

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

::: code-group

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

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

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

**Ответ**

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

## GET /units-of-measure/get-deleted

Get deleted units-of-measure ids

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

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

::: code-group

```bash [curl]
curl -X GET 'https://api.bito.uz/integration-api/integration/api/v2/units-of-measure/get-deleted?deleted_at=DELETED_AT' \
  -H "api-key: $BITO_API_KEY"
```

```js [JavaScript]
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/units-of-measure/get-deleted?deleted_at=DELETED_AT', {
  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/units-of-measure/get-deleted?deleted_at=DELETED_AT",
    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/units-of-measure/get-deleted?deleted_at=DELETED_AT');
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);
```

:::

**Параметры запроса**

| Параметр | Тип | Обязательно | Описание |
|---|---|---|---|
| `deleted_at` | `string` | Да |  |

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

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

**Ответ**

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

## POST /units-of-measure/get-paging

Get units-of-measure by paging

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

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

::: code-group

```bash [curl]
curl -X POST 'https://api.bito.uz/integration-api/integration/api/v2/units-of-measure/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/units-of-measure/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/units-of-measure/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/units-of-measure/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` |
| `search` | `string` | Нет |  |
| `type` | `string` | Нет | Допустимые значения: `inventory`, `service` |
| `status` | `string` | Нет | Допустимые значения: `active`, `inactive` |
| `product_id` | `string` | Нет |  |
| `updated_at` | `string (date-time)` | Нет | Only records updated at or after this time. |

```json
{
  "page": 1,
  "limit": 20,
  "search": "string",
  "type": "inventory",
  "status": "active",
  "product_id": "64b7f4d9e2b3b6a0b7c5d7ff",
  "updated_at": "2025-05-01T12:00:00Z"
}
```

**Ответ**

`data.total` — общее количество записей, `data.data[]` — записи текущей страницы. Таблица ниже описывает одну запись.

| Поле | Тип | Описание |
|---|---|---|
| `name` | `string` |  |
| `code` | `string` |  |
| `short_name` | `string` |  |
| `status` | `string` | Допустимые значения: `active`, `inactive` |
| `system_code` | `string` |  |
| `decimal_count` | `integer` | По умолчанию: `0` |
| `type` | `string` | Допустимые значения: `inventory`, `service` |
| `updated_by_user` | `object` |  |
| `updated_by_user._id` | `string` |  |
| `updated_by_user.full_name` | `string` |  |
| `created_by_user` | `object` |  |
| `created_by_user._id` | `string` |  |
| `created_by_user.full_name` | `string` |  |
| `created_at` | `string (date-time)` |  |
| `updated_at` | `string (date-time)` |  |
| `is_default` | `boolean` |  |

```json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": {
    "total": 0,
    "data": [
      {
        "name": "string",
        "code": "string",
        "short_name": "string",
        "status": "active",
        "system_code": "string",
        "decimal_count": 0,
        "type": "inventory",
        "updated_by_user": {
          "_id": "string",
          "full_name": "string"
        },
        "created_by_user": {
          "_id": "string",
          "full_name": "string"
        },
        "created_at": "2025-05-01T12:00:00Z",
        "updated_at": "2025-05-01T12:00:00Z",
        "is_default": false
      }
    ]
  },
  "time": "2025-05-01T12:00:00Z"
}
```

---

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