# Discount

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

## POST /discount/create

This method allows adding discount into the account.

**Нужное разрешение:** `discount_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/discount/create' \
  -H "api-key: $BITO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "string",
  "organization_ids": [
    "string"
  ],
  "is_manual": false,
  "auto_attach": false,
  "apply_type": "percent",
  "live_type": "forever",
  "assign_type": "all",
  "value": 0,
  "is_all_categories": false
}'
```

```js [JavaScript]
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/discount/create', {
  method: 'POST',
  headers: { 'api-key': process.env.BITO_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    "name": "string",
    "organization_ids": [
      "string"
    ],
    "is_manual": false,
    "auto_attach": false,
    "apply_type": "percent",
    "live_type": "forever",
    "assign_type": "all",
    "value": 0,
    "is_all_categories": false
  }),
})
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/discount/create",
    headers={"api-key": os.environ["BITO_API_KEY"]},
    json={
        "name": "string",
        "organization_ids": [
            "string",
        ],
        "is_manual": False,
        "auto_attach": False,
        "apply_type": "percent",
        "live_type": "forever",
        "assign_type": "all",
        "value": 0,
        "is_all_categories": False,
    },
)
print(res.json())
```

```php [PHP]
<?php
$body = <<<'JSON'
{
  "name": "string",
  "organization_ids": [
    "string"
  ],
  "is_manual": false,
  "auto_attach": false,
  "apply_type": "percent",
  "live_type": "forever",
  "assign_type": "all",
  "value": 0,
  "is_all_categories": false
}
JSON;

$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/discount/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` | Да |  |
| `organization_ids` | `string[]` | Да |  |
| `auto_attach` | `boolean` | Да |  |
| `is_manual` | `boolean` | Да |  |
| `live_type` | `string` | Да | Допустимые значения: `forever`, `duration` |
| `assign_type` | `string` | Да | Допустимые значения: `all`, `specific` |
| `apply_type` | `string` | Да | Допустимые значения: `percent`, `cash` |
| `value` | `number` | Да |  |
| `currency_id` | `string` | Нет | Required when `apply_type` is `cash`. |
| `starting_date` | `string` | Нет | Required when `live_type` is `duration`. |
| `ending_date` | `string` | Нет | Required when `live_type` is `duration`. |
| `is_all_categories` | `boolean` | Да |  |
| `category_ids` | `string[]` | Нет |  |
| `item_added_ids` | `string[]` | Нет | Product ids |

```json
{
  "name": "string",
  "organization_ids": [
    "string"
  ],
  "auto_attach": false,
  "is_manual": false,
  "live_type": "forever",
  "assign_type": "all",
  "apply_type": "percent",
  "value": 0,
  "currency_id": "string",
  "starting_date": "string",
  "ending_date": "string",
  "is_all_categories": false,
  "category_ids": [
    "string"
  ],
  "item_added_ids": [
    "string"
  ]
}
```

**Ответ**

| Поле | Тип | Описание |
|---|---|---|
| `_id` | `string` | id of discount |
| `name` | `string` |  |
| `organization_ids` | `string[]` |  |
| `auto_attach` | `boolean` |  |
| `is_manual` | `boolean` |  |
| `state` | `string` | Допустимые значения: `not_started`, `active`, `expired` |
| `live_type` | `string` | Допустимые значения: `forever`, `duration` |
| `assign_type` | `string` | Допустимые значения: `all`, `specific` |
| `apply_type` | `string` | Допустимые значения: `percent`, `cash` |
| `value` | `number` |  |
| `currency_id` | `string` |  |
| `starting_date` | `string` |  |
| `ending_date` | `string` |  |
| `is_all_categories` | `boolean` |  |
| `category_ids` | `string[]` |  |
| `nested_category_ids` | `string[]` |  |
| `item_added_ids` | `string[]` |  |

```json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": {
    "_id": "string",
    "name": "string",
    "organization_ids": [
      "string"
    ],
    "auto_attach": false,
    "is_manual": false,
    "state": "not_started",
    "live_type": "forever",
    "assign_type": "all",
    "apply_type": "percent",
    "value": 0,
    "currency_id": "string",
    "starting_date": "string",
    "ending_date": "string",
    "is_all_categories": false,
    "category_ids": [
      "string"
    ],
    "nested_category_ids": [
      "string"
    ],
    "item_added_ids": [
      "string"
    ]
  },
  "time": "2025-05-01T12:00:00Z"
}
```

## PUT /discount/update

This method allows updating discount in the account.

**Нужное разрешение:** `discount_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/discount/update' \
  -H "api-key: $BITO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "string",
  "organization_ids": [
    "string"
  ],
  "is_manual": false,
  "auto_attach": false,
  "apply_type": "percent",
  "live_type": "forever",
  "assign_type": "all",
  "value": 0,
  "is_all_categories": false,
  "_id": "string"
}'
```

```js [JavaScript]
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/discount/update', {
  method: 'PUT',
  headers: { 'api-key': process.env.BITO_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    "name": "string",
    "organization_ids": [
      "string"
    ],
    "is_manual": false,
    "auto_attach": false,
    "apply_type": "percent",
    "live_type": "forever",
    "assign_type": "all",
    "value": 0,
    "is_all_categories": false,
    "_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/discount/update",
    headers={"api-key": os.environ["BITO_API_KEY"]},
    json={
        "name": "string",
        "organization_ids": [
            "string",
        ],
        "is_manual": False,
        "auto_attach": False,
        "apply_type": "percent",
        "live_type": "forever",
        "assign_type": "all",
        "value": 0,
        "is_all_categories": False,
        "_id": "string",
    },
)
print(res.json())
```

```php [PHP]
<?php
$body = <<<'JSON'
{
  "name": "string",
  "organization_ids": [
    "string"
  ],
  "is_manual": false,
  "auto_attach": false,
  "apply_type": "percent",
  "live_type": "forever",
  "assign_type": "all",
  "value": 0,
  "is_all_categories": false,
  "_id": "string"
}
JSON;

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

:::

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

| Поле | Тип | Обязательно | Описание |
|---|---|---|---|
| `name` | `string` | Да |  |
| `organization_ids` | `string[]` | Да |  |
| `auto_attach` | `boolean` | Да |  |
| `is_manual` | `boolean` | Да |  |
| `live_type` | `string` | Да | Допустимые значения: `forever`, `duration` |
| `assign_type` | `string` | Да | Допустимые значения: `all`, `specific` |
| `apply_type` | `string` | Да | Допустимые значения: `percent`, `cash` |
| `value` | `number` | Да |  |
| `currency_id` | `string` | Нет | Required when `apply_type` is `cash`. |
| `starting_date` | `string` | Нет | Required when `live_type` is `duration`. |
| `ending_date` | `string` | Нет | Required when `live_type` is `duration`. |
| `is_all_categories` | `boolean` | Да |  |
| `category_ids` | `string[]` | Нет |  |
| `item_added_ids` | `string[]` | Нет | Product ids |
| `_id` | `string` | Да | id of customer |

```json
{
  "name": "string",
  "organization_ids": [
    "string"
  ],
  "auto_attach": false,
  "is_manual": false,
  "live_type": "forever",
  "assign_type": "all",
  "apply_type": "percent",
  "value": 0,
  "currency_id": "string",
  "starting_date": "string",
  "ending_date": "string",
  "is_all_categories": false,
  "category_ids": [
    "string"
  ],
  "item_added_ids": [
    "string"
  ],
  "_id": "string"
}
```

**Ответ**

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

## DELETE /discount/delete/{id}

Delete a discount

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

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

::: code-group

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

```js [JavaScript]
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/discount/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/discount/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/discount/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 /discount/get-by-id/{id}

Get discount using its _id

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

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

::: code-group

```bash [curl]
curl -X GET 'https://api.bito.uz/integration-api/integration/api/v2/discount/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/discount/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/discount/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/discount/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 /discount/create](#post-discount-create).

## POST /discount/get-paging

Get discounts by paging

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

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

::: code-group

```bash [curl]
curl -X POST 'https://api.bito.uz/integration-api/integration/api/v2/discount/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/discount/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/discount/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/discount/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` |
| `apply_type` | `string` | Нет |  |
| `states` | `string` | Нет |  |
| `search` | `string` | Нет |  |
| `currency_id` | `string` | Нет |  |
| `is_expired` | `boolean` | Нет |  |
| `organization_ids` | `string[]` | Нет |  |

```json
{
  "page": 1,
  "limit": 20,
  "apply_type": "string",
  "states": "string",
  "search": "string",
  "currency_id": "string",
  "is_expired": false,
  "organization_ids": [
    "string"
  ]
}
```

**Ответ**

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

| Поле | Тип | Описание |
|---|---|---|
| `_id` | `string` | id of discount |
| `name` | `string` |  |
| `organization_ids` | `string[]` |  |
| `auto_attach` | `boolean` |  |
| `is_manual` | `boolean` |  |
| `state` | `string` | Допустимые значения: `not_started`, `active`, `expired` |
| `live_type` | `string` | Допустимые значения: `forever`, `duration` |
| `assign_type` | `string` | Допустимые значения: `all`, `specific` |
| `apply_type` | `string` | Допустимые значения: `percent`, `cash` |
| `value` | `number` |  |
| `currency_id` | `string` |  |
| `starting_date` | `string` |  |
| `ending_date` | `string` |  |
| `is_all_categories` | `boolean` |  |
| `category_ids` | `string[]` |  |
| `nested_category_ids` | `string[]` |  |
| `item_added_ids` | `string[]` |  |

```json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": {
    "total": 0,
    "data": [
      {
        "_id": "string",
        "name": "string",
        "organization_ids": [
          "string"
        ],
        "auto_attach": false,
        "is_manual": false,
        "state": "not_started",
        "live_type": "forever",
        "assign_type": "all",
        "apply_type": "percent",
        "value": 0,
        "currency_id": "string",
        "starting_date": "string",
        "ending_date": "string",
        "is_all_categories": false,
        "category_ids": [
          "string"
        ],
        "nested_category_ids": [
          "string"
        ],
        "item_added_ids": [
          "string"
        ]
      }
    ]
  },
  "time": "2025-05-01T12:00:00Z"
}
```

## POST /discount/get-all

Get all discounts

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

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

::: code-group

```bash [curl]
curl -X POST 'https://api.bito.uz/integration-api/integration/api/v2/discount/get-all' \
  -H "api-key: $BITO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "apply_type": "percent",
  "currency_id": "64e5b499189503e999999999",
  "organization_ids": [
    "64e5b499189503e999999999"
  ],
  "is_expired": false,
  "states": [
    "active"
  ]
}'
```

```js [JavaScript]
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/discount/get-all', {
  method: 'POST',
  headers: { 'api-key': process.env.BITO_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    "apply_type": "percent",
    "currency_id": "64e5b499189503e999999999",
    "organization_ids": [
      "64e5b499189503e999999999"
    ],
    "is_expired": false,
    "states": [
      "active"
    ]
  }),
})
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/discount/get-all",
    headers={"api-key": os.environ["BITO_API_KEY"]},
    json={
        "apply_type": "percent",
        "currency_id": "64e5b499189503e999999999",
        "organization_ids": [
            "64e5b499189503e999999999",
        ],
        "is_expired": False,
        "states": [
            "active",
        ],
    },
)
print(res.json())
```

```php [PHP]
<?php
$body = <<<'JSON'
{
  "apply_type": "percent",
  "currency_id": "64e5b499189503e999999999",
  "organization_ids": [
    "64e5b499189503e999999999"
  ],
  "is_expired": false,
  "states": [
    "active"
  ]
}
JSON;

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

:::

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

| Поле | Тип | Обязательно | Описание |
|---|---|---|---|
| `apply_type` | `string` | Нет | Допустимые значения: `percent`, `cash` |
| `currency_id` | `string` | Нет |  |
| `organization_ids` | `string[]` | Нет |  |
| `is_expired` | `boolean` | Нет |  |
| `states` | `string[]` | Нет |  |

```json
{
  "apply_type": "percent",
  "currency_id": "64e5b499189503e999999999",
  "organization_ids": [
    "64e5b499189503e999999999"
  ],
  "is_expired": false,
  "states": [
    "active"
  ]
}
```

**Ответ**

```json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": [
    {
      "_id": "string",
      "name": "string",
      "organization_ids": [
        "string"
      ],
      "auto_attach": false,
      "is_manual": false,
      "state": "not_started",
      "live_type": "forever",
      "assign_type": "all",
      "apply_type": "percent",
      "value": 0,
      "currency_id": "string",
      "starting_date": "string",
      "ending_date": "string",
      "is_all_categories": false,
      "category_ids": [
        "string"
      ],
      "nested_category_ids": [
        "string"
      ],
      "item_added_ids": [
        "string"
      ]
    }
  ],
  "time": "2025-05-01T12:00:00Z"
}
```

## GET /discount/get-deleted

Get deleted discount ids

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

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

::: code-group

```bash [curl]
curl -X GET 'https://api.bito.uz/integration-api/integration/api/v2/discount/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/discount/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/discount/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/discount/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"
}
```

---

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