# Person

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

## POST /person/get-by-id/{id}

Fetch a single person by ObjectId. Legal and natural persons are both stored as persons; the response is the aggregated legal- or natural-person record depending on the stored type.

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

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

::: code-group

```bash [curl]
curl -X POST 'https://api.bito.uz/integration-api/integration/api/v2/person/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/person/get-by-id/6712f0a9c4d1e87b3a0f9911', {
  method: 'POST',
  headers: { 'api-key': process.env.BITO_API_KEY },
})
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/person/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/person/get-by-id/6712f0a9c4d1e87b3a0f9911');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => ['api-key: ' . getenv('BITO_API_KEY')],
    CURLOPT_RETURNTRANSFER => true,
]);
$response = json_decode(curl_exec($ch), true);
```

:::

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

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

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

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

**Ответ**

| Поле | Тип | Описание |
|---|---|---|
| `number` | `number` |  |
| `type` | `string` |  |
| `name` | `string` |  |
| `short_name` | `string` |  |
| `status` | `string` | Допустимые значения: `active`, `inactive` |
| `phone_number` | `string` |  |
| `telegram_link` | `string` |  |
| `email` | `string` |  |
| `web_site` | `string` |  |
| `address` | `string` |  |
| `code` | `string` |  |
| `postal_code` | `string` |  |
| `inn` | `string` |  |
| `image` | `string` |  |
| `location` | `object` |  |
| `is_customer` | `boolean` |  |
| `is_supplier` | `boolean` |  |
| `is_default` | `boolean` |  |
| `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` |  |
| `owner` | `object` |  |
| `owner._id` | `string` |  |
| `owner.name` | `string` |  |
| `owner.short_name` | `string` |  |
| `manager` | `object` |  |
| `manager._id` | `string` |  |
| `manager.first_name` | `string` |  |
| `manager.last_name` | `string` |  |
| `created_at` | `string (date-time)` |  |
| `updated_at` | `string (date-time)` |  |
| `balance` | `number` |  |
| `balance_list` | `object[]` |  |
| `total_balance` | `number` |  |
| `customer` | `object` |  |
| `customer._id` | `string` |  |
| `customer.name` | `string` |  |
| `employee` | `object` |  |
| `employee._id` | `string` |  |
| `employee.name` | `string` |  |
| `supplier` | `object` |  |
| `supplier._id` | `string` |  |
| `supplier.name` | `string` |  |
| `delivery_address` | `string` |  |
| `responsible_id` | `string` |  |
| `responsible` | `object` |  |
| `responsible._id` | `string` |  |
| `responsible.full_name` | `string` |  |

```json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": {
    "number": 0,
    "type": "string",
    "name": "string",
    "short_name": "string",
    "status": "active",
    "phone_number": "string",
    "telegram_link": "string",
    "email": "string",
    "web_site": "string",
    "address": "string",
    "code": "string",
    "postal_code": "string",
    "inn": "string",
    "image": "string",
    "location": {},
    "is_customer": false,
    "is_supplier": false,
    "is_default": false,
    "updated_by_user": {
      "_id": "string",
      "full_name": "string"
    },
    "created_by_user": {
      "_id": "string",
      "full_name": "string"
    },
    "owner": {
      "_id": "string",
      "name": "string",
      "short_name": "string"
    },
    "manager": {
      "_id": "string",
      "first_name": "string",
      "last_name": "string"
    },
    "created_at": "2025-05-01T12:00:00Z",
    "updated_at": "2025-05-01T12:00:00Z",
    "balance": 0,
    "balance_list": [
      {}
    ],
    "total_balance": 0,
    "customer": {
      "_id": "string",
      "name": "string"
    },
    "employee": {
      "_id": "string",
      "name": "string"
    },
    "supplier": {
      "_id": "string",
      "name": "string"
    },
    "delivery_address": "string",
    "responsible_id": "string",
    "responsible": {
      "_id": "string",
      "full_name": "string"
    }
  },
  "time": "2025-05-01T12:00:00Z"
}
```

## POST /person/balance/get-paging

Paginated list of persons WITH their balances per organization and currency. Filter by type, status, organization_id and balance_type. Use /person/get-paging for a plain list without balance aggregation — it is considerably cheaper.

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

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

::: code-group

```bash [curl]
curl -X POST 'https://api.bito.uz/integration-api/integration/api/v2/person/balance/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/person/balance/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/person/balance/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/person/balance/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` |
| `type` | `string` | Нет | Допустимые значения: `legal`, `natural` |
| `status` | `string` | Нет | Допустимые значения: `active`, `inactive` |
| `organization_id` | `string` | Нет |  |
| `balance_type` | `string` | Нет | Filter by balance state.. Допустимые значения: `debt`, `credit`, `zero`, `not_zero` |
| `organization_ids` | `string[]` | Нет | Organization ObjectIds. |
| `balance_at` | `string (date-time)` | Нет |  |
| `is_customer` | `boolean` | Нет |  |
| `is_supplier` | `boolean` | Нет |  |
| `search` | `string` | Нет | Free-text search. |
| `updated_at` | `string (date-time)` | Нет | Only records updated at or after this time. |

```json
{
  "page": 1,
  "limit": 20,
  "type": "legal",
  "status": "active",
  "organization_id": "63f8b0c4e4b0d3a2f8e4b0c4",
  "balance_type": "not_zero",
  "organization_ids": [
    "64b7f4d9e2b3b6a0b7c5d7ff"
  ],
  "balance_at": "2025-05-01T12:00:00Z",
  "is_customer": false,
  "is_supplier": false,
  "search": "string",
  "updated_at": "2025-05-01T12:00:00Z"
}
```

**Ответ**

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

| Поле | Тип | Описание |
|---|---|---|
| `_id` | `string` |  |
| `name` | `string` |  |
| `last_name` | `string` |  |
| `first_name` | `string` |  |
| `type` | `boolean` |  |
| `person_id` | `string` |  |
| `phone_number` | `string` |  |
| `status` | `string` | Допустимые значения: `active`, `inactive` |
| `code` | `string` |  |
| `balance_list` | `object[]` |  |

```json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": {
    "total": 0,
    "data": [
      {
        "_id": "string",
        "name": "string",
        "last_name": "string",
        "first_name": "string",
        "type": false,
        "person_id": "string",
        "phone_number": "string",
        "status": "active",
        "code": "string",
        "balance_list": [
          {}
        ]
      }
    ]
  },
  "time": "2025-05-01T12:00:00Z"
}
```

## POST /person/get-paging

Paginated list of persons — the shared identity record behind customers, suppliers and employees. Returns a light projection (_id, name, first_name, last_name, type, phone_number, status, code). Filter by type, status, organization_id/organization_ids, is_customer, is_supplier, or free-text search. Use /person/balance/get-paging when balances are needed.

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

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

::: code-group

```bash [curl]
curl -X POST 'https://api.bito.uz/integration-api/integration/api/v2/person/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/person/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/person/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/person/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` | Нет | Free-text search over name / phone number / code. |
| `type` | `string` | Нет | Filter by person type.. Допустимые значения: `legal`, `natural` |
| `status` | `string` | Нет | Filter by person status.. Допустимые значения: `active`, `inactive` |
| `organization_id` | `string` | Нет | Restrict to persons attached to this organization. |
| `organization_ids` | `string[]` | Нет | Restrict to persons attached to any of these organizations. |
| `is_customer` | `boolean` | Нет | Keep only persons that are also customers. |
| `is_supplier` | `boolean` | Нет | Keep only persons that are also suppliers. |
| `phone_number` | `string` | Нет |  |
| `updated_at` | `string (date-time)` | Нет | Only records updated at or after this time. |

```json
{
  "page": 1,
  "limit": 20,
  "search": "string",
  "type": "natural",
  "status": "active",
  "organization_id": "63f8b0c4e4b0d3a2f8e4b0c4",
  "organization_ids": [
    "63f8b0c4e4b0d3a2f8e4b0c4"
  ],
  "is_customer": false,
  "is_supplier": false,
  "phone_number": "string",
  "updated_at": "2025-05-01T12:00:00Z"
}
```

**Ответ**

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

| Поле | Тип | Описание |
|---|---|---|
| `_id` | `string` |  |
| `name` | `string` | Display name. For legal persons this is the company name; for natural persons the assembled full name. |
| `first_name` | `string` |  |
| `last_name` | `string` |  |
| `type` | `string` | Допустимые значения: `legal`, `natural` |
| `phone_number` | `string` |  |
| `status` | `string` | Допустимые значения: `active`, `inactive` |
| `code` | `string` |  |

```json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": {
    "total": 0,
    "data": [
      {
        "_id": "string",
        "name": "string",
        "first_name": "string",
        "last_name": "string",
        "type": "legal",
        "phone_number": "string",
        "status": "active",
        "code": "string"
      }
    ]
  },
  "time": "2025-05-01T12:00:00Z"
}
```

---

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